@@ -66,6 +66,7 @@ typedef struct
6666{
6767 const char * name ;
6868 uint8_t version ;
69+ uint8_t create_healthcheck ;
6970 pp_info_t pp_info_in ;
7071 uint8_t * raw_bytes_in ;
7172 uint32_t raw_bytes_in_length ;
@@ -447,40 +448,40 @@ int main()
447448 },
448449 .add_tlvs = {
449450 {
450- .type = PP2_SUBTYPE_SSL_VERSION ,
451+ .type = PP2_SUBTYPE_SSL_VERSION ,
451452 .value_len = 8 ,
452- .value = (uint8_t * ) "TLSv1.2"
453+ .value = (uint8_t * )"TLSv1.2"
453454 },
454455 {
455456 .type = PP2_SUBTYPE_SSL_CN ,
456457 .value_len = 18 ,
457- .value = (uint8_t * ) "proxy-protocol.com"
458+ .value = (uint8_t * )"proxy-protocol.com"
458459 },
459460 {
460461 .type = PP2_SUBTYPE_SSL_CIPHER ,
461462 .value_len = 28 ,
462- .value = (uint8_t * ) "ECDHE-RSA-AES128-GCM-SHA256"
463+ .value = (uint8_t * )"ECDHE-RSA-AES128-GCM-SHA256"
463464 },
464465 {
465466 .type = PP2_SUBTYPE_SSL_SIG_ALG ,
466467 .value_len = 7 ,
467- .value = (uint8_t * ) "SHA256"
468+ .value = (uint8_t * )"SHA256"
468469 },
469470 {
470471 .type = PP2_SUBTYPE_SSL_KEY_ALG ,
471472 .value_len = 8 ,
472- .value = (uint8_t * ) "RSA2048"
473+ .value = (uint8_t * )"RSA2048"
473474 },
474475 {
475476 .type = PP2_TYPE_AWS ,
476477 .subtype = PP2_SUBTYPE_AWS_VPCE_ID ,
477478 .value_len = 24 ,
478- .value = (uint8_t * ) "vpce-24d8ezjk38bchilm4m"
479+ .value = (uint8_t * )"vpce-24d8ezjk38bchilm4m"
479480 },
480481 {
481482 .type = PP2_TYPE_CRC32C ,
482483 .value_len = 4 ,
483- .value = (uint8_t * ) "\x43\x84\x86\x4e"
484+ .value = (uint8_t * )"\x43\x84\x86\x4e"
484485 },
485486 },
486487 .pp_info_out_expected = tests [9 ].pp_info_in ,
@@ -511,27 +512,27 @@ int main()
511512 {
512513 .type = PP2_SUBTYPE_SSL_VERSION ,
513514 .value_len = 8 ,
514- .value = (uint8_t * ) "TLSv1.2"
515+ .value = (uint8_t * )"TLSv1.2"
515516 },
516517 {
517518 .type = PP2_SUBTYPE_SSL_CN ,
518519 .value_len = 11 ,
519- .value = (uint8_t * ) "example.com"
520+ .value = (uint8_t * )"example.com"
520521 },
521522 {
522523 .type = PP2_SUBTYPE_SSL_CIPHER ,
523524 .value_len = 28 ,
524- .value = (uint8_t * ) "ECDHE-RSA-AES128-GCM-SHA256"
525+ .value = (uint8_t * )"ECDHE-RSA-AES128-GCM-SHA256"
525526 },
526527 {
527528 .type = PP2_SUBTYPE_SSL_SIG_ALG ,
528529 .value_len = 7 ,
529- .value = (uint8_t * ) "SHA256"
530+ .value = (uint8_t * )"SHA256"
530531 },
531532 {
532533 .type = PP2_SUBTYPE_SSL_KEY_ALG ,
533534 .value_len = 8 ,
534- .value = (uint8_t * ) "RSA2048"
535+ .value = (uint8_t * )"RSA2048"
535536 },
536537 },
537538 },
@@ -544,6 +545,15 @@ int main()
544545 },
545546 .pp_info_out_expected = tests [11 ].pp_info_in ,
546547 },
548+ {
549+ .name = "v2 PROXY protocol header: pp2_create_healthcheck_hdr() and parse - LOCAL, AF_UNSPEC" ,
550+ .create_healthcheck = 1 ,
551+ .pp_info_out_expected = {
552+ .address_family = ADDR_FAMILY_UNSPEC ,
553+ .transport_protocol = TRANSPORT_PROTOCOL_UNSPEC ,
554+ .pp2_info .local = 1
555+ },
556+ },
547557 };
548558
549559 /* Run tests */
@@ -574,8 +584,16 @@ int main()
574584 }
575585 }
576586
577- uint8_t * pp_hdr = pp_create_hdr (tests [i ].version , & tests [i ].pp_info_in , & pp_hdr_len , & error );
578- pp_info_clear (& tests [i ].pp_info_in );
587+ uint8_t * pp_hdr = NULL ;
588+ if (tests [i ].create_healthcheck )
589+ {
590+ pp_hdr = pp2_create_healthcheck_hdr (& pp_hdr_len , & error );
591+ }
592+ else
593+ {
594+ pp_hdr = pp_create_hdr (tests [i ].version , & tests [i ].pp_info_in , & pp_hdr_len , & error );
595+ pp_info_clear (& tests [i ].pp_info_in );
596+ }
579597 if (!pp_hdr
580598 || error != ERR_NULL
581599 || (alignment > 1 && pp_hdr_len % alignment ))
0 commit comments