action validate

Mode: Configuration Mode

Description:

When the user input values cannot be validated using simple ddl syntax check (using flags or regular-expression check using match), a C function can be defined to allow additional validations. It also allow error messages to be issued just before values are assigned to attributes.

Example:

src/junos/lib/ddl/junos-actions/junos_foreign.c

        /* mgd_validate_source_address:                              */
        /* Verifies that the IPv4 source address is not a multicast  */
        /* or broadcast address                                      */
        DDL_ACTION_FUNCTION(mgd_validate_source_address)
        {
            char *srcaddr = daap->daa_gram_data->gd_current;

            if (valid_ipv4_hostaddr(srcaddr))
                return 0;

            js_error("source address can not be a broadcast or multicast address");
            return EXPORT_ERROR;
        }

src/junos/lib/ddl/input/exampled.cnf.dd

        object newbie {
            help "Newbie settings";

            attribute source-address {
                help "Testing action validate source-address";
                type ipv4addr;
                action validate mgd mgd_validate_source_address;
            }
        }

Display:

        user@router# set example newbie source-address ?
        Possible completions:
          <source-address>     Testing action validate source-address
        [edit]
        user@router# set example newbie source-address 224.0.0.1
        error: invalid value: 224.0.0.1
 
        [edit]
        user@router# set example newbie source-address 1.1.1.1      

        [edit]
        user@router# show example
        newbie {
            source-address 1.1.1.1;
        }

        [edit]

Topics for further reading:

See also:

Reference (to programmers guide/style guide):


2007-2008 Juniper Networks, Inc. All rights reserved. The information contained herein is confidential information of Juniper Networks, Inc., and may not be used, disclosed, distributed, modified, or copied without the prior written consent of Juniper Networks, Inc. in an express license. This information is subject to change by Juniper Networks, Inc. Juniper Networks, the Juniper Networks logo, and JUNOS are trademarks of Juniper Networks, Inc.
Generated on Sun May 30 20:23:12 2010 for DDL Reference Guide by doxygen 1.4.5