module ietf-tcp-server {
  yang-version 1.1;
  namespace "urn:ietf:params:xml:ns:yang:ietf-tcp-server";
  prefix tcps;

  import ietf-inet-types {
    prefix inet;
    reference
      "RFC 6991: Common YANG Data Types";
  }

  import ietf-tcp-common {
    prefix tcpcmn;
    reference
      "RFC 9643: YANG Groupings for TCP Clients and TCP Servers";
  }

  organization
    "IETF NETCONF (Network Configuration) Working Group and the
     IETF TCP Maintenance and Minor Extensions (TCPM) Working Group";

  contact
    "WG Web:   https://datatracker.ietf.org/wg/netconf
               https://datatracker.ietf.org/wg/tcpm
     WG List:  NETCONF WG list <mailto:netconf@ietf.org>
               TCPM WG list <mailto:tcpm@ietf.org>
     Authors:  Kent Watsen <mailto:kent+ietf@watsen.net>
               Michael Scharf
               <mailto:michael.scharf@hs-esslingen.de>";

  description
    "This module defines reusable groupings for TCP servers that
     can be used as a basis for specific TCP server instances.

     Copyright (c) 2024 IETF Trust and the persons identified
     as authors of the code.  All rights reserved.

     Redistribution and use in source and binary forms, with
     or without modification, is permitted pursuant to, and
     subject to the license terms contained in, the Revised
     BSD License set forth in Section 4.c of the IETF Trust's
     Legal Provisions Relating to IETF Documents
     (https://trustee.ietf.org/license-info).

     This version of this YANG module is part of RFC 9643
     (https://www.rfc-editor.org/info/rfc9643); see the RFC
     itself for full legal notices.";

  revision 2024-10-10 {
    description
      "Initial version.";
    reference
      "RFC 9643: YANG Groupings for TCP Clients and TCP Servers";
  }

  // Features

  feature tcp-server-keepalives {
    description
      "TCP keepalive parameters are configurable for
       TCP servers on the server implementing this feature.";
    reference
      "RFC 9293: Transmission Control Protocol (TCP)";
  }

  // Groupings

  grouping tcp-server-grouping {
    description
      "A reusable grouping for configuring a TCP server.

       Note that this grouping uses fairly typical descendant
       node names such that a stack of 'uses' statements will
       have name conflicts.  It is intended that the consuming
       data model will resolve the issue (e.g., by wrapping
       the 'uses' statement in a container called
       'tcp-server-parameters').  This model purposely does
       not do this itself so as to provide maximum flexibility
       to consuming models.";
    list local-bind {
      key "local-address";
      min-elements 1;
      description
        "A list of bind (listen) points for this server
         instance.  A server instance may have multiple
         bind points to support, e.g., the same port in
         different address families or different ports
         in the same address family.";
      leaf local-address {
        type inet:ip-address;
        description
          "The local IP address to listen on for incoming
           TCP client connections.  To configure listening
           on all IPv4 addresses, the value must be '0.0.0.0'
           (INADDR_ANY).  To configure listening on all IPv6
           addresses, the value must be '::' (INADDR6_ANY).";
      }
      leaf local-port {
        type inet:port-number;
        description
          "The local port number to listen on for incoming TCP
           client connections.";
      }
    }
    uses tcpcmn:tcp-common-grouping {
      refine "keepalives" {
        if-feature "tcp-server-keepalives";
        description
          "An 'if-feature' statement so that implementations
           can choose to support TCP server keepalives.";
      }
    }
  }
}