+// SPDX-License-Identifier: GPL-2.0-or-later
/* BGP scripting foo
* Copyright (C) 2020 NVIDIA Corporation
* Quentin Young
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * 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; see the file COPYING; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
- * MA 02110-1301 USA
*/
#include <zebra.h>
void lua_decode_attr(lua_State *L, int idx, struct attr *attr)
{
- lua_getfield(L, -1, "metric");
+ lua_getfield(L, idx, "metric");
attr->med = lua_tointeger(L, -1);
lua_pop(L, 1);
- lua_getfield(L, -1, "ifindex");
+ lua_getfield(L, idx, "ifindex");
attr->nh_ifindex = lua_tointeger(L, -1);
lua_pop(L, 1);
- lua_getfield(L, -1, "aspath");
- attr->aspath = aspath_str2aspath(lua_tostring(L, -1));
+ lua_getfield(L, idx, "aspath");
+ attr->aspath = aspath_str2aspath(lua_tostring(L, -1),
+ bgp_get_asnotation(NULL));
lua_pop(L, 1);
- lua_getfield(L, -1, "localpref");
+ lua_getfield(L, idx, "localpref");
attr->local_pref = lua_tointeger(L, -1);
lua_pop(L, 1);
+ lua_pop(L, 1);
}
void *lua_toattr(lua_State *L, int idx)