函数约定提供了有关函数约定的一般信息。没有讨论每种受支持的语言的详细区别和标准语法。Spirent HLTAPI的设计使得Tcl、Python和Perl的HLTAPI共享相同的函数、参数和功能。唯一的区别是每个HLTAPI所使用的语言。
下面的三个HLTAPI代码片段在Tcl、Python和Perl中执行相同的操作。代码片段在指定端口上创建OSPFv2路由器。我们传递了8个参数来设置该设备。
# HLTAPI for Tcl
set device_ret0 [sth::emulation_ospf_config \
-port_handle $port(1) \
-intf_ip_addr 134.231.242.112 \
-hello_interval 10 \
-router_priority 10 \
-session_type ospfv2 \
-gateway_ip_addr 134.231.242.2 \
-area_id 10.01.12.24 \
-mode create \
]
# HLTAPI for Python
device_ret0 = sth.emulation_ospf_config (
port_handle = '$port(1)',
intf_ip_addr = '134.231.242.112',
hello_interval = '10',
router_priority = '10',
session_type = 'ospfv2',
gateway_ip_addr = '134.231.242.2',
area_id = '10.01.12.24',
mode = 'create');
# HLTAPI for Perl
my %device_ret0 = sth::emulation_ospf_config (
port_handle => '$port(1)',
intf_ip_addr => '134.231.242.112',
hello_interval => '10',
router_priority => '10',
session_type => 'ospfv2',
gateway_ip_addr => '134.231.242.2',
area_id => '10.01.12.24',
mode => 'create');