@@ -68,6 +68,12 @@ extern "C" {
68
68
# endif /* !BUILDING_NGHTTP3 */
69
69
#endif /* !defined(WIN32) */
70
70
71
+ #ifdef _MSC_VER
72
+ # define NGHTTP3_ALIGN (N ) __declspec(align(N))
73
+ #else /* !_MSC_VER */
74
+ # define NGHTTP3_ALIGN (N ) __attribute__((aligned(N)))
75
+ #endif /* !_MSC_VER */
76
+
71
77
/**
72
78
* @typedef
73
79
*
@@ -1937,12 +1943,12 @@ typedef struct nghttp3_settings {
1937
1943
* Extended CONNECT Method (see :rfc:`9220`). Client ignores this
1938
1944
* field.
1939
1945
*/
1940
- int enable_connect_protocol ;
1946
+ uint8_t enable_connect_protocol ;
1941
1947
/**
1942
1948
* :member:`h3_datagram`, if set to nonzero, enables HTTP/3
1943
1949
* Datagrams (see :rfc:`9297`).
1944
1950
*/
1945
- int h3_datagram ;
1951
+ uint8_t h3_datagram ;
1946
1952
} nghttp3_settings ;
1947
1953
1948
1954
/**
@@ -2431,12 +2437,15 @@ NGHTTP3_EXTERN uint64_t nghttp3_conn_get_frame_payload_left(nghttp3_conn *conn,
2431
2437
*/
2432
2438
#define NGHTTP3_URGENCY_LEVELS (NGHTTP3_URGENCY_LOW + 1)
2433
2439
2440
+ #define NGHTTP3_PRI_V1 1
2441
+ #define NGHTTP3_PRI_VERSION NGHTTP3_PRI_V1
2442
+
2434
2443
/**
2435
2444
* @struct
2436
2445
*
2437
2446
* :type:`nghttp3_pri` represents HTTP priority.
2438
2447
*/
2439
- typedef struct nghttp3_pri {
2448
+ typedef struct NGHTTP3_ALIGN ( 8 ) nghttp3_pri {
2440
2449
/**
2441
2450
* :member:`urgency` is the urgency of a stream, it must be in
2442
2451
* [:macro:`NGHTTP3_URGENCY_HIGH`, :macro:`NGHTTP3_URGENCY_LOW`],
@@ -2449,7 +2458,7 @@ typedef struct nghttp3_pri {
2449
2458
* incrementally. If inc is 1, it can be processed incrementally.
2450
2459
* Other value is not permitted.
2451
2460
*/
2452
- int inc ;
2461
+ uint8_t inc ;
2453
2462
} nghttp3_pri ;
2454
2463
2455
2464
/**
@@ -2466,26 +2475,53 @@ typedef struct nghttp3_pri {
2466
2475
* This function returns 0 if it succeeds, or one of the following
2467
2476
* negative error codes:
2468
2477
*
2478
+ * :macro:`NGHTTP3_ERR_INVALID_ARGUMENT`
2479
+ * |stream_id| is not a client initiated bidirectional stream ID.
2469
2480
* :macro:`NGHTTP3_ERR_STREAM_NOT_FOUND`
2470
2481
* Stream not found.
2471
2482
*/
2472
- NGHTTP3_EXTERN int nghttp3_conn_get_stream_priority (nghttp3_conn * conn ,
2473
- nghttp3_pri * dest ,
2474
- int64_t stream_id );
2483
+ NGHTTP3_EXTERN int nghttp3_conn_get_stream_priority_versioned (
2484
+ nghttp3_conn * conn , int pri_version , nghttp3_pri * dest , int64_t stream_id );
2475
2485
2476
2486
/**
2477
2487
* @function
2478
2488
*
2479
- * `nghttp3_conn_set_stream_priority` updates priority of a stream
2480
- * denoted by |stream_id| with the value pointed by |pri|.
2489
+ * `nghttp3_conn_set_client_stream_priority` updates priority of a
2490
+ * stream denoted by |stream_id| with the value pointed by |data| of
2491
+ * length |datalen|, which should be a serialized :rfc:`9218` priority
2492
+ * field value. |stream_id| must identify client initiated
2493
+ * bidirectional stream.
2494
+ *
2495
+ * This function must not be called if |conn| is initialized as
2496
+ * server.
2497
+ *
2498
+ * This function returns 0 if it succeeds, or one of the following
2499
+ * negative error codes:
2500
+ *
2501
+ * :macro:`NGHTTP3_ERR_INVALID_ARGUMENT`
2502
+ * |stream_id| is not a client initiated bidirectional stream ID.
2503
+ * :macro:`NGHTTP3_ERR_STREAM_NOT_FOUND`
2504
+ * Stream not found.
2505
+ * :macro:`NGHTTP3_ERR_NOMEM`
2506
+ * Out of memory.
2507
+ */
2508
+ NGHTTP3_EXTERN int nghttp3_conn_set_client_stream_priority (nghttp3_conn * conn ,
2509
+ int64_t stream_id ,
2510
+ const uint8_t * data ,
2511
+ size_t datalen );
2512
+
2513
+ /**
2514
+ * @function
2515
+ *
2516
+ * `nghttp3_conn_set_server_stream_priority` updates priority of a
2517
+ * stream denoted by |stream_id| with the value pointed by |pri|.
2481
2518
* |stream_id| must identify client initiated bidirectional stream.
2482
2519
*
2483
- * Both client and server can update stream priority with this
2484
- * function .
2520
+ * This function must not be called if |conn| is initialized as
2521
+ * client .
2485
2522
*
2486
- * If server updates stream priority with this function, it completely
2487
- * overrides stream priority set by client and the attempts to update
2488
- * priority by client are ignored.
2523
+ * This function completely overrides stream priority set by client
2524
+ * and the attempts to update priority by client are ignored.
2489
2525
*
2490
2526
* This function returns 0 if it succeeds, or one of the following
2491
2527
* negative error codes:
@@ -2497,9 +2533,9 @@ NGHTTP3_EXTERN int nghttp3_conn_get_stream_priority(nghttp3_conn *conn,
2497
2533
* :macro:`NGHTTP3_ERR_NOMEM`
2498
2534
* Out of memory.
2499
2535
*/
2500
- NGHTTP3_EXTERN int nghttp3_conn_set_stream_priority ( nghttp3_conn * conn ,
2501
- int64_t stream_id ,
2502
- const nghttp3_pri * pri );
2536
+ NGHTTP3_EXTERN int nghttp3_conn_set_server_stream_priority_versioned (
2537
+ nghttp3_conn * conn , int64_t stream_id , int pri_version ,
2538
+ const nghttp3_pri * pri );
2503
2539
2504
2540
/**
2505
2541
* @function
@@ -2544,21 +2580,11 @@ NGHTTP3_EXTERN int nghttp3_check_header_value(const uint8_t *value, size_t len);
2544
2580
/**
2545
2581
* @function
2546
2582
*
2547
- * `nghttp3_http_parse_priority` parses priority HTTP header field
2548
- * stored in the buffer pointed by |value| of length |len|. If it
2549
- * successfully processed header field value, it stores the result
2550
- * into |*dest|. This function just overwrites what it sees in the
2551
- * header field value and does not initialize any field in |*dest|.
2552
- *
2553
- * This function returns 0 if it succeeds, or one of the following
2554
- * negative error codes:
2555
- *
2556
- * :macro:`NGHTTP3_ERR_INVALID_ARGUMENT`
2557
- * The function could not parse the provided value.
2583
+ * `nghttp3_conn_is_drained` returns nonzero if
2584
+ * `nghttp3_conn_shutdown` has been called, and there is no active
2585
+ * remote streams. This function is for server use only.
2558
2586
*/
2559
- NGHTTP3_EXTERN int nghttp3_http_parse_priority (nghttp3_pri * dest ,
2560
- const uint8_t * value ,
2561
- size_t len );
2587
+ NGHTTP3_EXTERN int nghttp3_conn_is_drained (nghttp3_conn * conn );
2562
2588
2563
2589
/**
2564
2590
* @function
@@ -2662,6 +2688,24 @@ NGHTTP3_EXTERN int nghttp3_err_is_fatal(int liberr);
2662
2688
(CALLBACKS), NGHTTP3_SETTINGS_VERSION, \
2663
2689
(SETTINGS), (MEM), (USER_DATA))
2664
2690
2691
+ /*
2692
+ * `nghttp3_conn_set_server_stream_priority` is a wrapper around
2693
+ * `nghttp3_conn_set_server_stream_priority_versioned` to set the
2694
+ * correct struct version.
2695
+ */
2696
+ #define nghttp3_conn_set_server_stream_priority (CONN , STREAM_ID , PRI ) \
2697
+ nghttp3_conn_set_server_stream_priority_versioned( \
2698
+ (CONN), (STREAM_ID), NGHTTP3_PRI_VERSION, (PRI))
2699
+
2700
+ /*
2701
+ * `nghttp3_conn_get_stream_priority` is a wrapper around
2702
+ * `nghttp3_conn_get_stream_priority_versioned` to set the correct
2703
+ * struct version.
2704
+ */
2705
+ #define nghttp3_conn_get_stream_priority (CONN , DEST , STREAM_ID ) \
2706
+ nghttp3_conn_get_stream_priority_versioned((CONN), NGHTTP3_PRI_VERSION, \
2707
+ (DEST), (STREAM_ID))
2708
+
2665
2709
#ifdef __cplusplus
2666
2710
}
2667
2711
#endif
0 commit comments