@@ -423,7 +423,7 @@ int main()
423423 .pp_info_out_expected = tests [8 ].pp_info_in ,
424424 },
425425 {
426- .name = "v2 PROXY protocol header: create and parse - PROXY, TCP over IPv4. TLVs: "
426+ .name = "v2 PROXY protocol header: create and parse - PROXY, TCP over IPv4. Aligned, padded. TLVs: "
427427 "PP2_TYPE_SSL, PP2_SUBTYPE_SSL_VERSION, PP2_SUBTYPE_SSL_CN, PP2_SUBTYPE_SSL_CIPHER,"
428428 "PP2_SUBTYPE_SSL_SIG_ALG, PP2_SUBTYPE_SSL_KEY_ALG, PP2_TYPE_AWS(PP2_SUBTYPE_AWS_VPCE_ID), PP2_TYPE_CRC32C" ,
429429 .version = 2 ,
@@ -435,13 +435,14 @@ int main()
435435 .src_port = 42332 ,
436436 .dst_port = 8080 ,
437437 .pp2_info = {
438- .crc32c = 1 ,
438+ .align_padding = 2 ,
439439 .pp2_ssl_info = {
440440 .ssl = 1 ,
441441 .cert_in_connection = 1 ,
442442 .cert_in_session = 1 ,
443443 .cert_verified = 1 ,
444- }
444+ },
445+ .crc32c = 1
445446 }
446447 },
447448 .add_tlvs = {
@@ -452,9 +453,8 @@ int main()
452453 },
453454 {
454455 .type = PP2_SUBTYPE_SSL_CN ,
455- .value_len = 11 ,
456- /* example.com */
457- .value = (uint8_t * ) "\x65\x78\x61\x6d\x70\x6c\x65\x2e\x63\x6f\x6d"
456+ .value_len = 18 ,
457+ .value = (uint8_t * ) "proxy-protocol.com"
458458 },
459459 {
460460 .type = PP2_SUBTYPE_SSL_CIPHER ,
@@ -480,7 +480,7 @@ int main()
480480 {
481481 .type = PP2_TYPE_CRC32C ,
482482 .value_len = 4 ,
483- .value = (uint8_t * ) "\x72\x45\x29\xd8 "
483+ .value = (uint8_t * ) "\x75\x40\xf1\x2f "
484484 },
485485 },
486486 .pp_info_out_expected = tests [9 ].pp_info_in ,
@@ -516,8 +516,7 @@ int main()
516516 {
517517 .type = PP2_SUBTYPE_SSL_CN ,
518518 .value_len = 11 ,
519- /* example.com */
520- .value = (uint8_t * ) "\x65\x78\x61\x6d\x70\x6c\x65\x2e\x63\x6f\x6d"
519+ .value = (uint8_t * ) "example.com"
521520 },
522521 {
523522 .type = PP2_SUBTYPE_SSL_CIPHER ,
@@ -561,6 +560,7 @@ int main()
561560 else
562561 {
563562 uint16_t pp_hdr_len ;
563+ uint16_t pow = 1 << tests [i ].pp_info_in .pp2_info .align_padding ;
564564 int32_t error ;
565565
566566 if (tests [i ].add_tlvs [0 ].type )
@@ -576,7 +576,9 @@ int main()
576576
577577 uint8_t * pp_hdr = pp_create_hdr (tests [i ].version , & tests [i ].pp_info_in , & pp_hdr_len , & error );
578578 pp_info_clear (& tests [i ].pp_info_in );
579- if (!pp_hdr || error != ERR_NULL )
579+ if (!pp_hdr
580+ || error != ERR_NULL
581+ || (pow > 1 && pp_hdr_len % pow ))
580582 {
581583 printf ("FAILED\n" );
582584 pp_info_clear (& pp_info_out );
0 commit comments