
  PROCEDURE [INLINE] nlp$osi_get_outbound_capacity
    (    cl_connection: ^nlt$cl_connection;
     VAR current_connection_capacity: nat$data_length);

?? PUSH (LISTEXT := ON) ??
?? RIGHT := 110 ??
*copy nlh$osi_get_outbound_capacity

{ This procedure determines the outbound capacity for the specified connection
{ using an algorithm that takes into account connection class, number of active priority
{ connections and maximum CCPDU size. The capacity returned is either zero or the maximum
{ TA user PDU size. If no capacity is available due to insufficient buffer resouces, a
{ timer will be started. If capacity is available when the timer expires and the sender is
{ waiting, a 'clear to send' will be sent to the sender; if capacity is still unavailable due to
{ insufficient buffers the timer will be reset.

{ When the number of available network buffers becomes less than the number reserved for priority
{ connections the normal flow control window is closed.  The number of buffers reserved for priority
{ connections is equivalent to the number of active priority connections.

{ When the number of available network buffers becomes less than half the number of active connections,
{ capacity will be allocated only if the connection has credits outstanding from the device.

    CONST
      sixty_seconds = 60000000; { Sixty seconds in microseconds 60*1000*1000.

    VAR
      available_buffers: integer,
      connection: ^nlt$cc_connection,
      layer_active: boolean;

    current_connection_capacity := 0;
    nlp$cl_get_layer_connection (nlc$channel_connection_layer, cl_connection, layer_active, connection);
    IF layer_active THEN
      IF (connection^.send_credits > 0) OR ((((connection^.send_buffer.out + (nlc$cc_send_buffer_limit - 1)) -
            connection^.send_buffer.inn) MOD nlc$cc_send_buffer_limit) > 0) THEN
        available_buffers := (nlv$bm_buffer_pool [nlc$bm_large_buffer_index].count +
              (nlv$bm_allocat_buffer_threshold - nlv$bm_buffer_pool [nlc$bm_large_buffer_index].
              dynamic_buffers));
        IF connection^.class = nlc$cc_normal_class THEN
          available_buffers := available_buffers - nlv$cl_priority_connect_count -
                (nlp$cl_active_connections () DIV 2);
        IFEND;
        IF connection^.send_credits = 0 THEN
          available_buffers := available_buffers - (nlp$cl_active_connections () DIV 2);
        IFEND;
        IF available_buffers >= connection^.buffers_per_credit THEN
          current_connection_capacity := connection^.device_specific_attributes.maximum_data_length -
                nlc$lower_layer_overhead;
        IFEND;
        IF current_connection_capacity = 0 THEN
          nlp$select_timer (sixty_seconds, 0, connection^.no_buffers_for_user_capacity);
        IFEND;
      IFEND;
    IFEND;
  PROCEND nlp$osi_get_outbound_capacity;

*copyc nat$data_fragments
*copyc nlc$bm_buffer_pool_index
*copyc nlt$bm_buffer_count
*copyc nlt$cc_connection
*copyc nlt$cl_connection
*copyc nlp$cl_active_connections
*copyc nlp$cl_get_layer_connection
*copyc nlp$select_timer
*copyc nlv$bm_allocat_buffer_threshold
*copyc nlv$bm_buffer_pool
*copyc nlv$cl_priority_connect_count
?? POP ??
