yast/yast-network

View on GitHub
src/scrconf/routes.scr

Summary

Maintainability
Test Coverage
/** Copyright (c) [2019] SUSE LLC
 *
 * All Rights Reserved.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of version 2 of the GNU General Public License as published
 * by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, contact SUSE LLC.
 *
 * To contact SUSE LLC about this file by physical or electronic mail, you may
 * find current contact information at www.suse.com.
 */

/**
 * File:    routes.scr
 * Summary:    Agent for /etc/sysconfig/network/routes
 * Author:    Michal Svec <msvec@suse.cz>
 * Access:    read / write
 * See:        sysconfig.rpm
 *
 * General syntax:
 *     10.10.0.0    0.0.0.0        255.255.0.0    eth0
 *     default        10.10.0.8    0.0.0.0        eth0
 *     ...
 *
 *   Read(.routes)
 *   -> [
 *     $[
 *    "destination":"10.10.0.0",
 *      "device":"eth0",
 *      "gateway":"0.0.0.0",
 *      "netmask":"255.255.0.0"
 *    ],
 *    $[
 *    "destination":"default",
 *    "gateway":"10.10.0.8"
 *    ],
 *  ...
 *  ]
 *
 * $Id$
 *
 * <p>Reads/writes <tt>/etc/sysconfig/network/routes</tt>. For more details
 * see its own documentation.</p>
 *
 * Returns/Takes a <b>list of maps</b>. Each map (list-entry) corresponds
 * with one entry in the file. Keys for the maps are: "destination", "gateway",
 * "netmask", "device"
 *
 * <p><b>Warning!</b> The additional parameters to route are not supported
 * by this agent (for details see routes(5)).
 *
 */
.routes

`ag_anyagent(
    `Description(
    (`File("/etc/sysconfig/network/routes")),    // real file name
    "#\n",                        // comment
    false,                        // read-only?
    (`List(
        `Tuple(
        `destination(`String("^ \t\n")),
        `Whitespace(),
        `gateway(`String("^ \t\n")),
        `Whitespace(),
        `netmask(`String("^ \t\n")),
        `Optional(`Whitespace()),
        `Optional(`device(`String("^ \t\n"))),
        `Optional(`Whitespace()),
        `Optional(`extrapara(`String("^\n")))
        ),
    "\n"
    ))
    )
)