145 unsigned int line ) {
160 #define uri_ok( uri, expected ) uri_okx ( uri, expected, __FILE__, __LINE__ ) 170 unsigned int line ) {
180 #define uri_parse_ok( test ) uri_parse_okx ( test, __FILE__, __LINE__ ) 190 unsigned int line ) {
197 okx (
len == (
sizeof ( buf ) - 1 ), file, line );
207 #define uri_format_ok( test ) uri_format_okx ( test, __FILE__, __LINE__ ) 217 unsigned int line ) {
221 okx ( dup !=
NULL, file, line );
226 #define uri_dup_ok( test ) uri_dup_okx ( test, __FILE__, __LINE__ ) 236 unsigned int line ) {
242 #define uri_parse_format_dup_ok( test ) \ 243 uri_parse_format_dup_okx ( test, __FILE__, __LINE__ ) 253 unsigned int line ) {
266 #define uri_port_ok( test ) uri_port_okx ( test, __FILE__, __LINE__ ) 276 const char *file,
unsigned int line ) {
278 struct uri *relative;
286 okx ( relative !=
NULL, file, line );
289 if (
base && relative ) {
291 okx ( resolved !=
NULL, file, line );
307 #define uri_resolve_ok( test ) uri_resolve_okx ( test, __FILE__, __LINE__ ) 317 const char *file,
unsigned int line ) {
322 okx ( resolved !=
NULL, file, line );
324 okx (
strcmp ( resolved,
test->resolved ) == 0, file, line );
330 #define uri_resolve_path_ok( test ) \ 331 uri_resolve_path_okx ( test, __FILE__, __LINE__ ) 341 unsigned int line ) {
352 okx (
len == (
sizeof ( buf ) - 1 ), file, line );
357 #define uri_pxe_ok( test ) uri_pxe_okx ( test, __FILE__, __LINE__ ) 367 unsigned int line ) {
368 struct uri *old_cwuri;
405 #define uri_churi_ok( test ) uri_churi_okx ( test, __FILE__, __LINE__ ) 416 struct uri *
uri,
const char *file,
417 unsigned int line ) {
439 #define uri_params_list_ok( test ) \ 440 uri_params_list_okx ( test, __FILE__, __LINE__ ) 450 unsigned int line ) {
461 for ( list =
test->list ; list->
key ; list++ ) {
479 okx ( dup !=
NULL, file, line );
489 #define uri_params_ok( test ) uri_params_okx ( test, __FILE__, __LINE__ ) 498 "http://boot.ipxe.org/demo/boot.php",
499 { .scheme =
"http", .host =
"boot.ipxe.org",
500 .path =
"/demo/boot.php", .epath =
"/demo/boot.php" },
505 "mailto:ipxe-devel@lists.ipxe.org",
506 { .scheme =
"mailto", .opaque =
"ipxe-devel@lists.ipxe.org" },
511 "http://boot.ipxe.org",
512 { .scheme =
"http", .host =
"boot.ipxe.org" },
517 "/var/lib/tftpboot/pxelinux.0",
518 { .path =
"/var/lib/tftpboot/pxelinux.0",
519 .epath =
"/var/lib/tftpboot/pxelinux.0" },
525 { .path =
"/hello world?", .epath =
"/hello%20world%3F" },
530 "http://anon:password@example.com:3001/~foo/cgi-bin/foo.pl?a=b&c=d#bit",
534 .password =
"password",
535 .host =
"example.com",
537 .path =
"/~foo/cgi-bin/foo.pl",
538 .epath =
"/~foo/cgi-bin/foo.pl",
546 "https://test.ipxe.org/wtf%3F%0A?kind%23of/uri%20is#this%3F",
549 .host =
"test.ipxe.org",
551 .epath =
"/wtf%3F%0A",
552 .equery =
"kind%23of/uri%20is",
553 .efragment =
"this%3F",
564 "https://test%2eipxe.org/wt%66%3f\n?kind%23of/uri is#this?",
567 .host =
"test.ipxe.org",
569 .epath =
"/wt%66%3f\n",
570 .equery =
"kind%23of/uri is",
571 .efragment =
"this?",
577 "http://[2001:ba8:0:1d4::6950:5845]/",
580 .host =
"[2001:ba8:0:1d4::6950:5845]",
588 "http://[2001:ba8:0:1d4::6950:5845]:8001/boot",
591 .host =
"[2001:ba8:0:1d4::6950:5845]",
600 "http://[fe80::69ff:fe50:5845%25net0]/ipxe",
603 .host =
"[fe80::69ff:fe50:5845%net0]",
616 "http://[fe80::69ff:fe50:5845%net0]/ipxe",
619 .host =
"[fe80::69ff:fe50:5845%net0]",
627 "iscsi:10.253.253.1::::iqn.2010-04.org.ipxe:rabbit",
630 .opaque =
"10.253.253.1::::iqn.2010-04.org.ipxe:rabbit",
636 "file:boot/script.ipxe",
639 .opaque =
"boot/script.ipxe",
645 "file:/boot/script.ipxe",
648 .path =
"/boot/script.ipxe",
649 .epath =
"/boot/script.ipxe",
655 "file://hpilo/boot/script.ipxe",
659 .path =
"/boot/script.ipxe",
660 .epath =
"/boot/script.ipxe",
666 "/boot/52:54:00:12:34:56/boot.ipxe",
668 .path =
"/boot/52:54:00:12:34:56/boot.ipxe",
669 .epath =
"/boot/52:54:00:12:34:56/boot.ipxe",
675 "http://192.168.0.1:8080/boot.php",
682 "http://192.168.0.1/boot.php",
696 "/var/lib/tftpboot/pxe/pxelinux.0",
697 "./../ipxe/undionly.kpxe",
698 "/var/lib/tftpboot/ipxe/undionly.kpxe",
703 "/test/cgi-bin.pl/boot.ipxe",
710 "/var/lib/tftpboot/ipxe.pxe",
711 "../../../../../../../foo",
724 "http://boot.ipxe.org/demo/boot.php?vendor=10ec&device=8139",
726 "http://boot.ipxe.org/demo/initrd.img",
731 "http://boot.ipxe.org/demo/boot.php",
732 "ftp://192.168.0.1/boot.ipxe",
733 "ftp://192.168.0.1/boot.ipxe",
738 "http://boot.ipxe.org/demo/boot.php#test",
740 "http://boot.ipxe.org/demo/vmlinuz",
745 "http://10.253.253.1/test.pl?mac=02-00-69-50-58-45",
746 "?mac=00-1f-16-bc-fe-2f",
747 "http://10.253.253.1/test.pl?mac=00-1f-16-bc-fe-2f",
752 "http://192.168.0.254/test#foo",
754 "http://192.168.0.254/test#bar",
759 "http://192.168.0.1/path/to/me",
761 "http://192.168.0.1/path/to/me",
766 "http://192.168.0.1/path/to/me",
768 "http://192.168.0.1/path/to/",
777 .sin_addr = { .s_addr =
htonl ( 0xc0a80003 ) },
780 "http://not.a.tftp/uri",
783 .host =
"not.a.tftp",
787 "http://not.a.tftp/uri",
796 .sin_addr = { .s_addr =
htonl ( 0xc0a80002 ) },
802 .host =
"192.168.0.2",
803 .path =
"//absolute/path",
804 .epath =
"//absolute/path",
806 "tftp://192.168.0.2//absolute/path",
815 .sin_addr = { .s_addr =
htonl ( 0xc0a80003 ) },
821 .host =
"192.168.0.3",
822 .path =
"/relative/path",
823 .epath =
"/relative/path",
825 "tftp://192.168.0.3/relative/path",
834 .sin_addr = { .s_addr =
htonl ( 0x0a000006 ) },
837 "C:\\tftpboot\\icky#path",
841 .path =
"/C:\\tftpboot\\icky#path",
842 .epath =
"/C:\\tftpboot\\icky#path",
844 "tftp://10.0.0.6/C:\\tftpboot\\icky#path",
853 .sin_addr = { .s_addr =
htonl ( 0xc0a80001 ) },
854 .sin_port =
htons ( 4069 ),
860 .host =
"192.168.0.1",
862 .path =
"//another/path",
863 .epath =
"//another/path",
865 "tftp://192.168.0.1:4069//another/path",
871 "http://boot.ipxe.org/demo/boot.php",
872 "http://boot.ipxe.org/demo/boot.php",
875 "?vendor=10ec&device=8139",
876 "http://boot.ipxe.org/demo/boot.php?vendor=10ec&device=8139",
879 "fedora/fedora.ipxe",
880 "http://boot.ipxe.org/demo/fedora/fedora.ipxe",
884 "http://boot.ipxe.org/demo/fedora/vmlinuz",
887 "http://local/boot/initrd.img",
888 "http://local/boot/initrd.img",
891 "modules/8139too.ko",
892 "http://local/boot/modules/8139too.ko",
914 "f59fac00-758f-498f-9fe5-87d790045d94",
926 "http://boot.ipxe.org/demo/boot.php##params",
929 .host =
"boot.ipxe.org",
930 .path =
"/demo/boot.php",
931 .epath =
"/demo/boot.php",
946 "LXTQ20Z1139322762F2000",
958 "http://192.168.100.4:3001/register##params=foo",
961 .host =
"192.168.100.4",
964 .epath =
"/register",
const char * equery
Query (with original URI encoding)
static struct uri_test uri_ipv6_local
IPv6 URI with link-local address.
A URI parsing/formatting test.
unsigned int default_port
Default port number.
static void uri_put(struct uri *uri)
Decrement URI reference count.
static struct uri_test uri_ipv6
IPv6 URI.
static struct uri * uri_get(struct uri *uri)
Increment URI reference count.
static struct uri_resolve_test uri_absolute
Absolute URI resolution test.
static void uri_churi_okx(struct uri_churi_test *test, const char *file, unsigned int line)
Report current working URI test result.
const char * string
URI string.
const char * string
URI string (for display only; cannot be reparsed)
const char * filename
Filename.
#define for_each_param(param, params)
Iterate over all request parameters in a list.
uint32_t first
First block in range.
static struct uri_port_test uri_explicit_port
URI with port number.
union uri_pxe_test::@432 server
Server address.
static void uri_resolve_okx(struct uri_resolve_test *test, const char *file, unsigned int line)
Report URI resolution test result.
const char * string
URI string.
static struct uri_pxe_test uri_pxe_relative_path
PXE URI with relative path.
struct uri * pxe_uri(struct sockaddr *sa_server, const char *filename)
Construct URI from server address and filename.
static struct uri_test uri_http_escaped
HTTP URI with escaped characters.
static void uri_okx(struct uri *uri, struct uri *expected, const char *file, unsigned int line)
Report URI equality test result.
static struct uri_test uri_empty
Empty URI.
A request parameter list.
#define uri_parse_format_dup_ok(test)
static struct uri_pxe_test uri_pxe_absolute
PXE URI with absolute URI.
static struct uri_params_test_list uri_params_list[]
Request parameter URI test list.
static struct uri_params_test uri_params
Request parameter URI test.
static struct uri_test uri_file_volume
File URI with volume name.
Self-test infrastructure.
const char * name
Test set name.
static struct uri_test uri_file_relative
File URI with relative (opaque) path.
static struct uri_pxe_test uri_pxe_port
PXE URI with custom port.
static struct uri_resolve_test uri_fragment
Fragment URI resolution test.
Uniform Resource Identifiers.
static void uri_test_exec(void)
Perform URI self-test.
sa_family_t sin_family
Socket address family (part of struct sockaddr)
#define uri_port_ok(test)
static struct uri_resolve_test uri_query
Query URI resolution test.
#define uri_resolve_ok(test)
const char * port
Port number.
static struct uri_resolve_test uri_relative_path
Path resolution test with "." and ".." elements.
static void uri_format_okx(struct uri_test *test, const char *file, unsigned int line)
Report URI formatting test result.
static struct uri_resolve_test uri_absolute_path
Path resolution test with absolute path.
const char * scheme
Scheme.
static struct uri_test uri_boot_ipxe_org
Basic HTTP URI.
#define okx(success, file, line)
Report test result.
void churi(struct uri *uri)
Change working URI.
static struct uri_resolve_test uri_directory_path
Path resolution test terminating with directory.
static struct uri_test uri_iscsi
iSCSI URI
const char * relative
Relative path or URI.
const char * base
Base path or URI.
static struct uri_test uri_http_escaped_improper
HTTP URI with improperly escaped characters.
const char * path
Path (after URI decoding)
static void uri_params_list_okx(struct uri_params_test *test, struct uri *uri, const char *file, unsigned int line)
Report request parameter URI test list result.
static struct uri_resolve_test uri_excessive_path
Path resolution test with excessive ".." elements.
Transport-network layer interface.
size_t format_uri(const struct uri *uri, char *buf, size_t len)
Format URI.
struct parameters * create_parameters(const char *name)
Create request parameter list.
static struct uri_churi_test uri_churi[]
Current working URI test.
char * format_uri_alloc(const struct uri *uri)
Format URI.
static struct uri_test uri_http_all
HTTP URI with all the trimmings.
struct self_test uri_test __self_test
URI self-test.
char * resolve_path(const char *base_path, const char *relative_path)
Resolve base+relative path.
struct parameters * params
Request parameters.
static struct uri_test uri_colons
Relative URI with colons in path.
static struct uri_resolve_test uri_cwd
Current directory URI resolution test.
Generalized socket address structure.
A request parameter URI test.
static struct uri_test uri_ipv6_port
IPv6 URI with port.
static void(* free)(struct refcnt *refcnt))
static struct uri_resolve_test uri_absolute_uri_path
Absolute path URI resolution test.
struct hv_monitor_parameter param[4][32]
Parameters.
struct uri * uri_dup(const struct uri *uri)
Duplicate URI.
size_t strlen(const char *src)
Get length of string.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
static void uri_port_okx(struct uri_port_test *test, const char *file, unsigned int line)
Report URI port number test result.
struct list_head list
List of request parameters.
A current working URI test.
static struct uri_params_test uri_named_params
Named request parameter URI test.
const char * host
Host name.
#define PARAMETER_FORM
Request parameter is a form parameter.
A URI or path resolution test.
#define uri_params_ok(test)
const char * expected
Expected new working URI.
static struct uri_test uri_path
Basic path-only URI.
static struct uri_test uri_host
Basic host-only URI.
static struct uri_resolve_test uri_self
Empty relative URI resolution test.
static void uri_dup_okx(struct uri *uri, const char *file, unsigned int line)
Report URI duplication test result.
uint8_t formatted[5]
Formatted area.
static void uri_pxe_okx(struct uri_pxe_test *test, const char *file, unsigned int line)
Report URI PXE test result.
const char * efragment
Fragment (with original URI encoding)
static struct uri_test uri_mailto
Basic opaque URI.
static struct uri_resolve_test uri_relative
Relative URI resolution test.
const char * opaque
Opaque part.
const char * string
URI string.
#define uri_churi_ok(test)
int strcmp(const char *first, const char *second)
Compare strings.
static void uri_resolve_path_okx(struct uri_resolve_test *test, const char *file, unsigned int line)
Report path resolution test result.
static struct uri_pxe_test uri_pxe_absolute_path
PXE URI with absolute path.
static struct uri_test uri_file_absolute
File URI with absolute path.
unsigned int uri_port(const struct uri *uri, unsigned int default_port)
Get port from URI.
const char * password
Password.
const char * epath
Path (with original URI encoding)
static struct uri_test uri_path_escaped
Path-only URI with escaped characters.
const char * user
User name.
static void uri_params_okx(struct uri_params_test *test, const char *file, unsigned int line)
Report request parameter URI test result.
const char * name
Parameter list name.
A Uniform Resource Identifier.
A request parameter URI test list.
struct uri * resolve_uri(const struct uri *base_uri, struct uri *relative_uri)
Resolve base+relative URI.
static struct uri_resolve_test uri_simple_path
Simple path resolution test.
unsigned int port
Expected port number.
struct parameter * add_parameter(struct parameters *params, const char *key, const char *value, unsigned int flags)
Add request parameter.
static struct uri_params_test_list uri_named_params_list[]
Named request parameter URI test list.
#define uri_resolve_path_ok(test)
const char * resolved
Expected resolved path or URI.
struct uri * cwuri
Current working URI.
static int uristrcmp(const char *first, const char *second)
Compare two URI component strings.
#define NULL
NULL pointer (VOID *)
static void uri_parse_format_dup_okx(struct uri_test *test, const char *file, unsigned int line)
Report URI combined parsing and formatting test result.
static struct uri_port_test uri_default_port
URI without port number.
#define uri_parse_ok(test)
#define PARAMETER_HEADER
Request parameter is a header parameter.
static __always_inline int off_t userptr_t second
static struct uri_pxe_test uri_pxe_icky
PXE URI with path containing special characters.
static struct uri_test uri_ipv6_local_non_conforming
IPv6 URI with link-local address not conforming to RFC 6874.
const char * relative
Relative URI.
#define AF_INET
IPv4 Internet addresses.
struct uri * parse_uri(const char *uri_string)
Parse URI.
static void uri_parse_okx(struct uri_test *test, const char *file, unsigned int line)
Report URI parsing test result.
struct uri_params_test_list * list
Parameter list.