?? NEWTITLE := 'NOS/VE Network Access : Channel Connection Timer Monitor' ??
MODULE nlm$cc_timer_monitor;
?? RIGHT := 110 ??

{ PURPOSE:
{   The purpose of this module is to monitor all Channel Connection timers
{   associated with a particular connection, and if an expired timer is found,
{   perform the actions necessary.
{
{ DESIGN:
{   This module is designed to reside in the OSF$JOB_TEMPLATE_23D library and
{   to execute in the NAM/VE timer task.
{
?? TITLE := 'Global Declarations Referenced by This Module', EJECT ??
?? PUSH (LISTEXT := ON) ??
*copyc nlt$cc_connection
*copyc nlt$cl_connection
?? POP ??
*copyc nlp$cancel_timer
*copyc nlp$cc_grant_credits
*copyc nlp$cl_get_layer_connection
*copyc nlp$osi_get_outbound_capacity
*copyc nlp$timer_expired
*copyc oss$job_paged_literal
*copyc nav$network_procedures
?? OLDTITLE ??
?? NEWTITLE := 'Global Declarations Declared by This Module', EJECT ??

  VAR
    clear_to_send: [READ, oss$job_paged_literal] nlt$cc_event := [nlc$cc_clear_to_send_event];

?? OLDTITLE ??
?? NEWTITLE := '[XDCL] nlp$cc_monitor_timers', EJECT ??
*copy nlh$cc_monitor_timers

  PROCEDURE [XDCL] nlp$cc_monitor_timers
    (    current_time: integer;
         cl_connection: ^nlt$cl_connection);

    VAR
      connection: ^nlt$cc_connection,
      current_capacity: nat$data_length,
      layer_active: boolean;

    nlp$cl_get_layer_connection (nlc$channel_connection_layer, cl_connection, layer_active, connection);
    IF layer_active AND (connection^.device_specific_attributes.state = nlc$cc_open) THEN
      IF nlp$timer_expired (current_time, connection^.no_buffers_for_peer_credit) THEN
        nlp$cancel_timer (connection^.no_buffers_for_peer_credit);
        nlp$cc_grant_credits (connection);
      IFEND;
      IF nlp$timer_expired (current_time, connection^.no_buffers_for_user_capacity) THEN
        nlp$osi_get_outbound_capacity (cl_connection, current_capacity);
        IF (current_capacity > 0) AND cl_connection^.message_sender.active THEN
          nlp$cancel_timer (connection^.no_buffers_for_user_capacity);
          nav$network_procedures [connection^.event_processor].
                cc_event_processor^ (cl_connection, clear_to_send, connection^.accumulated_message_buffers);
        IFEND;
      IFEND;
    IFEND;

  PROCEND nlp$cc_monitor_timers;
MODEND nlm$cc_timer_monitor;

