module ietf-udp-client {
  yang-version 1.1;
  namespace
    "urn:ietf:params:xml:ns:yang:ietf-udp-client";
  prefix udpc;
  import ietf-inet-types {
    prefix inet;
    reference
      "RFC 6991: Common YANG Data Types";
  }

  organization "IETF NETCONF (Network Configuration) Working Group";
  contact
    "WG Web:   <http:/tools.ietf.org/wg/netconf/>
     WG List:  <mailto:netconf@ietf.org>

     Authors:  Alex Huang Feng
               <mailto:alex.huang-feng@insa-lyon.fr>
               Pierre Francois
               <mailto:pierre.francois@insa-lyon.fr>";
  description
    "Defines a generic grouping for UDP-based client applications.

    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-to-be; see the RFC
    itself for full legal notices.";

  revision 2024-06-27 {
    description
      "Initial revision";
    reference
      "RFC-to-be: YANG Groupings for UDP Clients and UDP Servers";
  }

  feature local-binding-supported {
    description
      "Indicates that the UDP client supports configuring local
       bindings (i.e., the local address and local port) for
       UDP clients.";
  }

  grouping udp-client-grouping {
    description
      "A reusable grouping for configuring a UDP client.

      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
      'udp-client-parameters').  This model purposely does
      not do this itself so as to provide maximum flexibility
      to consuming models.";

    leaf remote-address {
      type inet:host;
      mandatory true;
      description
        "The IP address or hostname of the remote UDP server.
        If a domain name is configured, then the DNS resolution should
        happen on each connection attempt. If the DNS resolution
        results in multiple IP addresses, the IP addresses
        are tried according to local preference order until
        a connection has been established or until all IP
        addresses have failed.";
    }

    leaf remote-port {
      type inet:port-number;
      description
        "The port number of the remote UDP server.";
    }

    leaf local-address {
      if-feature "local-binding-supported";
      type inet:ip-address;
      description
        "The local IP address to bind to when sending UDP
        messages to the remote server. INADDR_ANY ('0.0.0.0') or
        INADDR6_ANY ('0:0:0:0:0:0:0:0' a.k.a. '::') may be used
        so that the server can bind to any IPv4 or IPv6 address.";
    }

    leaf local-port {
      if-feature "local-binding-supported";
      type inet:port-number;
      description
        "The local port number to bind to when sending UDP
        messages to the remote server.";
    }
  }
}
