1    /*
     2     * Copyright (c) 2012, Texas Instruments Incorporated
     3     * All rights reserved.
     4     *
     5     * Redistribution and use in source and binary forms, with or without
     6     * modification, are permitted provided that the following conditions
     7     * are met:
     8     *
     9     * *  Redistributions of source code must retain the above copyright
    10     *    notice, this list of conditions and the following disclaimer.
    11     *
    12     * *  Redistributions in binary form must reproduce the above copyright
    13     *    notice, this list of conditions and the following disclaimer in the
    14     *    documentation and/or other materials provided with the distribution.
    15     *
    16     * *  Neither the name of Texas Instruments Incorporated nor the names of
    17     *    its contributors may be used to endorse or promote products derived
    18     *    from this software without specific prior written permission.
    19     *
    20     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    21     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
    22     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    23     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
    24     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    25     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
    26     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
    27     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
    28     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    29     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
    30     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    31     * */
    32    /*
    33     *  ======== Dns.xdc ========
    34     *
    35     *  Dns module definition and initial values
    36     */
    37    
    38    /*!
    39     *  ======== Dns ========
    40     *  NDK module used for creating and configuring a DNS server. 
    41     *  
    42     *  The Dns module can be used to configure and create a DNS server in
    43     *  an NDK program.
    44     *  
    45     *  In order to configure a DNS server, users must create a Dns module
    46     *  parameters structure, which contains all of the instance properties of a
    47     *  Dns instance.  Once the parameter structure is created, it may be used
    48     *  to change the properties of the DNS server that's being created.
    49     *  
    50     *  Users are able to create multiple DNS servers by creating multiple Dns
    51     *  module instances, and configuring each one.  However, if multiple Dns
    52     *  instances are created, one must be careful to ensure that they all
    53     *  have been configured to have unique and free port numbers.
    54     *
    55     */  
    56    
    57    @Template("./Dns.xdt")
    58    
    59    metaonly module Dns {
    60    
    61        /*! Function signature for CISARGS struct service reporting function */
    62        typedef Void (*dnsServiceFxn)(Int, Int, Int, Void *);
    63    
    64        /*! Type used to specify bits in mode */
    65        typedef Bits16 CisFlags;
    66    
    67        /*! Specifies if the IfIdx field is valid. */
    68        const CisFlags CIS_FLG_IFIDXVALID        = 0x0001;
    69    
    70        /*!
    71         *  Requests that IfIdx be resolved to an IP address before service
    72         *  execution is initiated.
    73         */
    74        const CisFlags CIS_FLG_RESOLVEIP         = 0x0002;
    75    
    76        /*! Specifies that the service should be invoked by IP address */
    77        const CisFlags CIS_FLG_CALLBYIP          = 0x0004;
    78    
    79        /*!
    80         *  A service that is dependent on a valid IP address (as determined by the
    81         *  RESOLVEIP flag) is shut down if the IP address becomes invalid.
    82         *
    83         *  When this flag is set, the service will be restarted when a new address
    84         *  becomes available. Otherwise; the service will not be restarted.
    85         */
    86        const CisFlags CIS_FLG_RESTARTIPTERM     = 0x0008;
    87    
    88        /*! Used to specify an external DNS Server */
    89        config String externDnsServIp = null;
    90    
    91        /*!
    92         *  ======== create ========
    93         *  Creates an Dns instance.
    94         */
    95        create();
    96    
    97    instance:
    98        /*!
    99         *  Set of flags which represent the desired behavior of the DNS Server.
   100         *  
   101         *  The following flag values may be set either individually, or by or-ing
   102         *  flags together:
   103         * @p(blist)
   104         *    - CIS_FLG_IFIDXVALID - specifies if the IfIdx field is valid.
   105         *  
   106         *    - CIS_FLG_RESOLVEIP - Requests that IfIdx be resolved to an IP
   107         *      address before service execution is initiated.
   108         *  
   109         *    - CIS_FLG_CALLBYIP - Specifies that the service should be invoked by
   110         *      IP address
   111         *  
   112         *    - CIS_FLG_RESTARTIPTERM - A service that is dependent on a valid IP
   113         *      address.
   114         * @p
   115         */
   116        config CisFlags mode = 0;
   117    
   118        /*!
   119         *  The physical device index on which the DNS server shall be
   120         *  executed.  Must be greater than zero.
   121         */
   122        config Int ifIdx = 1;
   123    
   124        /*! 
   125         *  The IP address on which to initiate this service.
   126         *  
   127         *  To accept a connection from any IP, specify INADDR_ANY.
   128         */ 
   129        config String ipAddr = "INADDR_ANY";
   130    
   131        /*! Dns service reporting function. */
   132        config dnsServiceFxn pCbSrv = '&ti_ndk_config_Global_serviceReport';
   133    
   134        /*! @_nodoc
   135         *
   136         * internal use only.  Intermediate variables mapped to Grace checkboxes,
   137         * used to update 'mode' flags variable.
   138         */
   139        config Bool IfIdXValid = false;
   140    
   141        /*! @_nodoc
   142         *
   143         * internal use only.  Intermediate variables mapped to Grace checkboxes,
   144         * used to update 'mode' flags variable.
   145         */
   146        config Bool ResolveIP = false;
   147    
   148        /*! @_nodoc
   149         *
   150         * internal use only.  Intermediate variables mapped to Grace checkboxes,
   151         * used to update 'mode' flags variable.
   152         */
   153        config Bool CallByIP = false;
   154    
   155        /*! @_nodoc
   156         *
   157         * internal use only.  Intermediate variables mapped to Grace checkboxes,
   158         * used to update 'mode' flags variable.
   159         */
   160        config Bool RestartIPTerm = false;
   161    }