?? RIGHT := 110 ??
?? NEWTITLE := 'NAM/VE: Connection Manager' ??
MODULE nlm$cl_connection_manager_r3;
?? RIGHT := 110 ??

{
{   PURPOSE:
{     The prime purpose of this module is to isolate the knowledge of the structures required
{     to access a specific connection.  Secondarily, the module contains service procedures to
{     support the connection establishment phase.
{
{     This module utilizes services provided by the system core connection manager to fulfill
{     its obligations.
{
{   DESIGN:
{     This module is designed to reside on the  OSF$JOB_TEMPLATE_23D library.
{
{     The service procedure for connection establishment, create connection, restrict the knowledge
{     of the mechanics of the internal connection structure.
{
?? NEWTITLE := 'Global Declarations Referenced by This Module', EJECT ??
*copyc nlt$cl_connection
*copyc nlp$cl_assign_connection
*copyc nav$network_paged_heap
*copyc nlv$cl_connection_layer_templat
?? OLDTITLE ??
?? TITLE := '  [XDCL] nlp$cl_create_connection', EJECT ??

  PROCEDURE [XDCL] nlp$cl_create_connection
    (    application_layer: nlt$cl_application_layer;
     VAR cl_connection: ^nlt$cl_connection);

*copy nlh$cl_create_connection

    VAR
      connection_layer_template_p: ^nlt$cl_connection_layer_templat,
      layer: nlt$cl_layer_name,
      layer_connection: ^array [1 .. * ] of cell,
      layer_connections: ^nlt$cl_layer_connections,
      layer_name: ^nlt$cl_layer_name,
      required_space: integer;

    required_space := 0;
    connection_layer_template_p := ^nlv$cl_connection_layer_templat [application_layer];
    FOR layer := application_layer TO UPPERVALUE (nlt$cl_layer_name) DO
      IF connection_layer_template_p^.path [layer] THEN
        required_space := required_space + connection_layer_template_p^.connection [layer].
              description_size + #SIZE (nlt$cl_layer_name);
      IFEND;
    FOREND;

    ALLOCATE layer_connections: [[REP required_space OF cell]] IN nav$network_paged_heap^;
    IF (layer_connections <> NIL) THEN
      nlp$cl_assign_connection (application_layer, layer_connections, cl_connection);
      IF (cl_connection <> NIL) THEN
        RESET layer_connections;
        FOR layer := application_layer TO UPPERVALUE (nlt$cl_layer_name) DO
          IF connection_layer_template_p^.path [layer] THEN
            NEXT layer_name IN layer_connections;
            layer_name^ := layer;
            NEXT layer_connection: [1 .. connection_layer_template_p^.connection [layer].description_size] IN
                  layer_connections;
          IFEND;
        FOREND;
      ELSE
        FREE layer_connections IN nav$network_paged_heap^;
      IFEND;
    ELSE
      cl_connection := NIL;
    IFEND;

  PROCEND nlp$cl_create_connection;
?? OLDTITLE ??
MODEND nlm$cl_connection_manager_r3;
