1
0
Fork 0
This repository has been archived on 2022-02-17. You can view files and clone it, but cannot push or open issues or pull requests.
osmo-st-binding/OsmoVTY.st

140 lines
3.3 KiB
Smalltalk

"Copyright placeholder"
CStruct subclass: vty_app_info [
<category: 'libosmovty'>
<comment: 'I represent the vty_app_info... some structs are wrong'>
<declaration: #(
#(#name #string)
#(#version #string)
#(#copyright #string)
#(#tall_ctx #(#ptr #int))
#(#go_parent_cb #(#ptr #int))
#(#is_config_node #(#ptr #int))) >
]
CStruct subclass: vty_vector [
<category: 'libosmovty'>
<comment: 'I am the struct _vector class'>
"the index is wrong but we do not need to access it"
<declaration: #(
#(#active #uInt)
#(#alloced #uInt)
#(#index #(#ptr #int))) >
]
CStruct subclass: vty_cmd_element [
<category: 'libosmovty'>
<comment: 'I represent the lowlevel command'>
<declaration: #(
#(#name #string)
#(#func #(#ptr #int))
#(#doc #string)
#(#daemon #int)
#(#strvec #(#ptr #{vty_vector}))
#(#cmdsize #uInt)
#(#config #string)
#(#subconfig #(#ptr #{vty_vector}))
#(#attr #uChar))>
]
CStruct subclass: vty_cmd_node [
<comment: 'I provide access to a cmd_node'>
<category: 'libosmovty'>
<declaration: #(
#(#node #int)
#(#prompt #string)
#(#vtysh #int)
#(#func #(#ptr #int))
#(#cmd_vector #(#ptr #{vty_vector}))) >
]
Object subclass: NodeType [
<category: 'libosmovty'>
NodeType class >> AUTH_NODE [
^ 0
]
NodeType class >> VIEW_NODE [
^ 1
]
NodeType class >> AUTH_ENABLE_NODE [
^ 2
]
NodeType class >> ENABLE_NODE [
^ 3
]
NodeType class >> CONFIG_NODE [
^ 4
]
NodeType class >> SERVICE_NODE [
^ 5
]
NodeType class >> DEBUG_NODE [
^ 6
]
NodeType class >> VTY_NODE [
^ 7
]
]
Object subclass: OSMOVTY [
<comment: 'I provide access to the VTY code'>
<category: 'libosmovty'>
OSMOVTY class >> initialize [
DLD addLibrary: 'libosmovty.so.0'
]
OSMOVTY class >> vty_init: app_info [
<cCall: 'vty_init' returning: #void args: #(#cObject) >
]
OSMOVTY class >> vty_read_config_file: file_name priv: priv [
<cCall: 'vty_read_config_file' returning: #int args: #(#string (#ptr #long)) >
]
OSMOVTY class >> telnet_init: tall_context priv: priv port: aPort [
<cCall: 'telnet_init' returning: #int args: #(#cObject #cObject #int) >
]
OSMOVTY class >> install_node: aNode func: aFunc [
<cCall: 'install_node' returning: #void args: #(#cObject #cObject) >
]
OSMOVTY class >> install_default: aNode [
<cCall: 'install_default' returning: #void args: #(#int) >
]
OSMOVTY class >> install_element: aNode cmd: aCmd [
<cCall: 'install_element' returning: #void args: #(#int #{vty_cmd_element}) >
]
OSMOVTY class >> install_element_ve: aCmd [
<cCall: 'install_element_ve' returning: #void args: #(#{vty_cmd_element}) >
]
OSMOVTY class >> initWith: aName version: aVersion license: aLicense port: aPort [
| app_info |
app_info := vty_app_info new.
app_info name value: aName.
app_info version value: aVersion.
app_info copyright value: aLicense.
OSMOVTY vty_init: app_info.
OSMOVTY telnet_init: nil priv: nil port: 4444.
]
]
Eval [
OSMOVTY initialize.
]