summaryrefslogtreecommitdiffstats
path: root/data/mnet/Common
diff options
context:
space:
mode:
Diffstat (limited to 'data/mnet/Common')
-rw-r--r--data/mnet/Common/Alarm/Makefile47
-rw-r--r--data/mnet/Common/Alarm/include/AlarmTask.h151
-rw-r--r--data/mnet/Common/Alarm/include/alarm.h168
-rw-r--r--data/mnet/Common/Alarm/include/alarm_interface.h127
-rw-r--r--data/mnet/Common/Alarm/src/Makefile44
-rw-r--r--data/mnet/Common/Alarm/src/alarm_diskFile.cpp198
-rw-r--r--data/mnet/Common/Alarm/src/alarm_event.cpp196
-rw-r--r--data/mnet/Common/Alarm/src/alarm_main.cpp187
-rw-r--r--data/mnet/Common/Alarm/src/alarm_message.cpp101
-rw-r--r--data/mnet/Common/Alarm/src/alarm_modules.cpp441
-rw-r--r--data/mnet/Common/Alarm/src/alarm_socket.cpp445
-rw-r--r--data/mnet/Common/Alarm/src/alarm_sysCmd.cpp173
-rw-r--r--data/mnet/Common/Java/AlarmApplet/Alarm.java102
-rw-r--r--data/mnet/Common/Java/AlarmApplet/AlarmStatusApplet.java139
-rw-r--r--data/mnet/Common/Java/AlarmApplet/AlarmStatusData.java139
-rw-r--r--data/mnet/Common/Java/AlarmApplet/AlarmStatusPanel.java53
-rw-r--r--data/mnet/Common/Java/AlarmApplet/AlarmStatusTable.java221
-rw-r--r--data/mnet/Common/Java/AlarmApplet/AlarmStatusTableModel.java34
-rw-r--r--data/mnet/Common/Java/AlarmApplet/AlarmStatusTablePopupMenu.java126
-rw-r--r--data/mnet/Common/Java/AlarmApplet/AlarmTCPThread.java469
-rw-r--r--data/mnet/Common/Java/AlarmApplet/FilterFrame.java337
-rw-r--r--data/mnet/Common/Java/AlarmApplet/FilterObject.java35
-rw-r--r--data/mnet/Common/Java/AlarmApplet/Makefile41
-rw-r--r--data/mnet/Common/Java/AlarmApplet/com/jetcell/MibWM/Makefile40
-rw-r--r--data/mnet/Common/Java/Images/Jetcelllogo.jpgbin0 -> 4437 bytes
-rw-r--r--data/mnet/Common/Java/Images/app_icon.GIFbin0 -> 8585 bytes
-rw-r--r--data/mnet/Common/Java/Images/app_icon2.GIFbin0 -> 13151 bytes
-rw-r--r--data/mnet/Common/Java/Images/cisco.JPGbin0 -> 14010 bytes
-rw-r--r--data/mnet/Common/Java/Images/cisco2.JPGbin0 -> 11456 bytes
-rw-r--r--data/mnet/Common/Java/Images/ciscologo.jpgbin0 -> 4437 bytes
-rw-r--r--data/mnet/Common/Java/Images/clear.gifbin0 -> 370 bytes
-rw-r--r--data/mnet/Common/Java/Images/cowbell.wavbin0 -> 1398 bytes
-rw-r--r--data/mnet/Common/Java/Images/critical.gifbin0 -> 341 bytes
-rw-r--r--data/mnet/Common/Java/Images/filler.gifbin0 -> 76 bytes
-rw-r--r--data/mnet/Common/Java/Images/gmc.jpgbin0 -> 6954 bytes
-rw-r--r--data/mnet/Common/Java/Images/grey.gifbin0 -> 145 bytes
-rw-r--r--data/mnet/Common/Java/Images/indeterminate.gifbin0 -> 477 bytes
-rw-r--r--data/mnet/Common/Java/Images/indeterminate2.gifbin0 -> 145 bytes
-rw-r--r--data/mnet/Common/Java/Images/information.gifbin0 -> 897 bytes
-rw-r--r--data/mnet/Common/Java/Images/line-01.gifbin0 -> 6199 bytes
-rw-r--r--data/mnet/Common/Java/Images/line-02.gifbin0 -> 6308 bytes
-rw-r--r--data/mnet/Common/Java/Images/logo.gifbin0 -> 1231 bytes
-rw-r--r--data/mnet/Common/Java/Images/logo.jpgbin0 -> 4437 bytes
-rw-r--r--data/mnet/Common/Java/Images/logo1.gifbin0 -> 1231 bytes
-rw-r--r--data/mnet/Common/Java/Images/major.gifbin0 -> 341 bytes
-rw-r--r--data/mnet/Common/Java/Images/minor.gifbin0 -> 337 bytes
-rw-r--r--data/mnet/Common/Java/Images/minus.gifbin0 -> 840 bytes
-rw-r--r--data/mnet/Common/Java/Images/normal.gifbin0 -> 370 bytes
-rw-r--r--data/mnet/Common/Java/Images/notify.wavbin0 -> 119384 bytes
-rw-r--r--data/mnet/Common/Java/Images/plus.gifbin0 -> 845 bytes
-rw-r--r--data/mnet/Common/Java/Images/scritical.gifbin0 -> 341 bytes
-rw-r--r--data/mnet/Common/Java/Images/sinformation.gifbin0 -> 897 bytes
-rw-r--r--data/mnet/Common/Java/Images/smajor.gifbin0 -> 341 bytes
-rw-r--r--data/mnet/Common/Java/Images/sminor.gifbin0 -> 337 bytes
-rw-r--r--data/mnet/Common/Java/Images/undrkunstrukson.gifbin0 -> 29257 bytes
-rw-r--r--data/mnet/Common/Java/Images/vipercell.gifbin0 -> 21761 bytes
-rw-r--r--data/mnet/Common/Java/Images/wireless.jpgbin0 -> 47266 bytes
-rw-r--r--data/mnet/Common/Java/Images/wireless1.JPGbin0 -> 5825 bytes
-rw-r--r--data/mnet/Common/Java/Java/AlarmApplet.java177
-rw-r--r--data/mnet/Common/Java/Java/AlarmCommThread.java121
-rw-r--r--data/mnet/Common/Java/Java/ConfigApplet.java53
-rw-r--r--data/mnet/Common/Java/Java/ConfigAppletBeanInfo.java70
-rw-r--r--data/mnet/Common/Java/Java/Makefile69
-rw-r--r--data/mnet/Common/Java/Java/SubscriberApplet.java58
-rw-r--r--data/mnet/Common/Java/Java/SubscriberAppletBeanInfo.java69
-rw-r--r--data/mnet/Common/Java/Makefile58
-rw-r--r--data/mnet/Common/Java/Text/AlarmCode.English154
-rw-r--r--data/mnet/Common/Java/com/jetcell/MibWM/AlarmData.java216
-rw-r--r--data/mnet/Common/Java/com/jetcell/MibWM/AlarmMessageMap.java131
-rw-r--r--data/mnet/Common/Java/com/jetcell/MibWM/AlarmPanel.java467
-rw-r--r--data/mnet/Common/Java/com/jetcell/MibWM/AlarmTable.java588
-rw-r--r--data/mnet/Common/Java/com/jetcell/MibWM/AlarmTableModel.java43
-rw-r--r--data/mnet/Common/Java/com/jetcell/MibWM/AlarmTablePopupMenu.java218
-rw-r--r--data/mnet/Common/Java/com/jetcell/MibWM/AlarmTableSorter.java97
-rw-r--r--data/mnet/Common/Java/com/jetcell/MibWM/BaseTable.java312
-rw-r--r--data/mnet/Common/Java/com/jetcell/MibWM/ImageLoader.java136
-rw-r--r--data/mnet/Common/Java/com/jetcell/MibWM/Makefile38
-rw-r--r--data/mnet/Common/Java/com/jetcell/MibWM/TableMap.java104
-rw-r--r--data/mnet/Common/Java/com/jetcell/MibWM/TablePopupMenu.java195
-rw-r--r--data/mnet/Common/Java/com/jetcell/MibWM/TableSorter.java360
-rw-r--r--data/mnet/Common/Java/com/jetcell/MibWM/TextClipboard.java80
-rw-r--r--data/mnet/Common/Java/com/jetcell/MibWM/TextComponentPopupMenu.java280
-rw-r--r--data/mnet/Common/Java/com/jetcell/MibWM/Util.java779
-rw-r--r--data/mnet/Common/Java/com/jetcell/MibWM/WMTextField.java156
-rw-r--r--data/mnet/Common/Java/java.mk60
-rw-r--r--data/mnet/Common/Os/Makefile28
-rw-r--r--data/mnet/Common/Os/include/JCMsgQDefs.h40
-rw-r--r--data/mnet/Common/Os/loadmodule/LoadModule.cpp195
-rw-r--r--data/mnet/Common/Os/loadmodule/Makefile62
-rw-r--r--data/mnet/Common/Os/src/JCCTimer.cpp91
-rw-r--r--data/mnet/Common/Os/src/JCModule.cpp470
-rw-r--r--data/mnet/Common/Os/src/JCMsgQueue.cpp197
-rw-r--r--data/mnet/Common/Os/src/JCMutex.cpp43
-rw-r--r--data/mnet/Common/Os/src/JCTask.cpp193
-rw-r--r--data/mnet/Common/Os/src/Makefile62
-rw-r--r--data/mnet/Common/Os/test/Makefile65
-rw-r--r--data/mnet/Common/Os/test/MsgQTest.cpp91
-rw-r--r--data/mnet/Common/Pm/Makefile47
-rw-r--r--data/mnet/Common/Pm/src/Makefile61
-rw-r--r--data/mnet/Common/Pm/src/pm_common.cpp406
-rw-r--r--data/mnet/Common/apm/include/apmdefs.h51
-rw-r--r--data/mnet/Common/bssgp/Makefile47
-rw-r--r--data/mnet/Common/bssgp/src/Makefile61
-rw-r--r--data/mnet/Common/bssgp/src/bssgp_decoder.cpp2520
-rw-r--r--data/mnet/Common/bssgp/src/bssgp_encoder.cpp1814
-rw-r--r--data/mnet/Common/bssgp/src/bssgp_ie_decoder.cpp2818
-rw-r--r--data/mnet/Common/bssgp/src/bssgp_ie_encoder.cpp2295
-rw-r--r--data/mnet/Common/bssgp/src/bssgp_net.cpp442
-rw-r--r--data/mnet/Common/bssgp/src/bssgp_util.cpp424
-rw-r--r--data/mnet/Common/bssgp/win32test/bssgpwin32.cpp524
-rw-r--r--data/mnet/Common/bssgp/win32test/gprstest/gprstest.mak238
-rw-r--r--data/mnet/Common/cdr/Makefile47
-rw-r--r--data/mnet/Common/cdr/certificate/Readme.txt2
-rw-r--r--data/mnet/Common/cdr/certificate/ca.pem18
-rw-r--r--data/mnet/Common/cdr/certificate/ca_cert/cakey.pem18
-rw-r--r--data/mnet/Common/cdr/certificate/cdrpwd.datbin0 -> 32 bytes
-rw-r--r--data/mnet/Common/cdr/certificate/cert.pem50
-rw-r--r--data/mnet/Common/cdr/certificate/key.pem18
-rw-r--r--data/mnet/Common/cdr/include/CdrBase.h179
-rw-r--r--data/mnet/Common/cdr/include/CdrCommon.h132
-rw-r--r--data/mnet/Common/cdr/include/CdrInterface.h87
-rw-r--r--data/mnet/Common/cdr/include/CdrModule.h200
-rw-r--r--data/mnet/Common/cdr/include/CdrMsg.h112
-rw-r--r--data/mnet/Common/cdr/include/CdrRef.h38
-rw-r--r--data/mnet/Common/cdr/include/CdrRefSem.h42
-rw-r--r--data/mnet/Common/cdr/include/CdrRemClientSocket.h61
-rw-r--r--data/mnet/Common/cdr/include/CdrShellIntf.h39
-rw-r--r--data/mnet/Common/cdr/include/ConnList.h98
-rw-r--r--data/mnet/Common/cdr/include/msgProc.h47
-rw-r--r--data/mnet/Common/cdr/src/CdrRef.cpp49
-rw-r--r--data/mnet/Common/cdr/src/Makefile61
-rw-r--r--data/mnet/Common/cdr/src/readme.txt1
-rw-r--r--data/mnet/Common/cdr/src_client/CdrApi.cpp159
-rw-r--r--data/mnet/Common/cdr/src_client/CdrBase.cpp222
-rw-r--r--data/mnet/Common/cdr/src_client/CdrMain.cpp212
-rw-r--r--data/mnet/Common/cdr/src_client/CdrModule.cpp521
-rw-r--r--data/mnet/Common/cdr/src_client/CdrRefSem.cpp42
-rw-r--r--data/mnet/Common/cdr/src_client/CdrRemClientSocket.cpp71
-rw-r--r--data/mnet/Common/cdr/src_client/CdrSSA.cpp124
-rw-r--r--data/mnet/Common/cdr/src_client/CdrSystem.cpp98
-rw-r--r--data/mnet/Common/cdr/src_client/Makefile61
-rw-r--r--data/mnet/Common/cdr/src_client/readme.txt1
-rw-r--r--data/mnet/Common/cdr/src_server/ConnList.cpp177
-rw-r--r--data/mnet/Common/cdr/src_server/Makefile62
-rw-r--r--data/mnet/Common/cdr/src_test/simulator.cpp278
-rw-r--r--data/mnet/Common/cli/Makefile47
-rw-r--r--data/mnet/Common/cli/include/address.h188
-rw-r--r--data/mnet/Common/cli/include/cfg_end.h49
-rw-r--r--data/mnet/Common/cli/include/cfg_exit.h42
-rw-r--r--data/mnet/Common/cli/include/cli_parser_api.h18
-rw-r--r--data/mnet/Common/cli/include/cli_parser_private.h11
-rw-r--r--data/mnet/Common/cli/include/cli_private.h114
-rw-r--r--data/mnet/Common/cli/include/config.h389
-rw-r--r--data/mnet/Common/cli/include/debug.h70
-rw-r--r--data/mnet/Common/cli/include/debug_macros.h70
-rw-r--r--data/mnet/Common/cli/include/defs.h127
-rw-r--r--data/mnet/Common/cli/include/exec_clear.h47
-rw-r--r--data/mnet/Common/cli/include/exec_configure.h47
-rw-r--r--data/mnet/Common/cli/include/exec_debug.h46
-rw-r--r--data/mnet/Common/cli/include/exec_debug_all.h41
-rw-r--r--data/mnet/Common/cli/include/exec_disable.h55
-rw-r--r--data/mnet/Common/cli/include/exec_enable.h58
-rw-r--r--data/mnet/Common/cli/include/exec_exit.h45
-rw-r--r--data/mnet/Common/cli/include/exec_help.h44
-rw-r--r--data/mnet/Common/cli/include/exec_show.h35
-rw-r--r--data/mnet/Common/cli/include/exec_undebug.h33
-rw-r--r--data/mnet/Common/cli/include/imc.h538
-rw-r--r--data/mnet/Common/cli/include/imsg.h179
-rw-r--r--data/mnet/Common/cli/include/macros.h652
-rw-r--r--data/mnet/Common/cli/include/mutex.h23
-rw-r--r--data/mnet/Common/cli/include/nv.h21
-rw-r--r--data/mnet/Common/cli/include/parser.h263
-rw-r--r--data/mnet/Common/cli/include/parser_ModNum.h13
-rw-r--r--data/mnet/Common/cli/include/parser_actions.h591
-rw-r--r--data/mnet/Common/cli/include/parser_api.h13
-rw-r--r--data/mnet/Common/cli/include/parser_commands.h27
-rw-r--r--data/mnet/Common/cli/include/parser_debug.h36
-rw-r--r--data/mnet/Common/cli/include/parser_debug_flags.h13
-rw-r--r--data/mnet/Common/cli/include/parser_defs_config.h28
-rw-r--r--data/mnet/Common/cli/include/parser_defs_exec.h86
-rw-r--r--data/mnet/Common/cli/include/parser_errno.h53
-rw-r--r--data/mnet/Common/cli/include/parser_if.h135
-rw-r--r--data/mnet/Common/cli/include/parser_init.h38
-rw-r--r--data/mnet/Common/cli/include/parser_input.h84
-rw-r--r--data/mnet/Common/cli/include/parser_modes.h8
-rw-r--r--data/mnet/Common/cli/include/parser_privilege.h19
-rw-r--r--data/mnet/Common/cli/include/parser_sim.h33
-rw-r--r--data/mnet/Common/cli/include/parser_util.h21
-rw-r--r--data/mnet/Common/cli/include/parsertypes.h145
-rw-r--r--data/mnet/Common/cli/include/platdef.h229
-rw-r--r--data/mnet/Common/cli/include/pstypes.h82
-rw-r--r--data/mnet/Common/cli/include/psvxif.h252
-rw-r--r--data/mnet/Common/cli/include/sys_debug.h20
-rw-r--r--data/mnet/Common/cli/include/ttyutil.h88
-rw-r--r--data/mnet/Common/cli/include/vxworks_cfg_chain.h157
-rw-r--r--data/mnet/Common/cli/include/vxworks_exec_chain.h229
-rw-r--r--data/mnet/Common/cli/include/vxworks_show_chain.h145
-rw-r--r--data/mnet/Common/cli/src/Makefile63
-rw-r--r--data/mnet/Common/cli/src/basic_exec_chain.c733
-rw-r--r--data/mnet/Common/cli/src/cfg_chain.c360
-rw-r--r--data/mnet/Common/cli/src/chain.c267
-rw-r--r--data/mnet/Common/cli/src/cli_parser_init.c379
-rw-r--r--data/mnet/Common/cli/src/cli_shellLib.c729
-rw-r--r--data/mnet/Common/cli/src/command2.c635
-rw-r--r--data/mnet/Common/cli/src/command_chain.c73
-rw-r--r--data/mnet/Common/cli/src/debug.c342
-rw-r--r--data/mnet/Common/cli/src/exec.c389
-rw-r--r--data/mnet/Common/cli/src/exec_chain.c160
-rw-r--r--data/mnet/Common/cli/src/imc.c513
-rw-r--r--data/mnet/Common/cli/src/imsg.c138
-rw-r--r--data/mnet/Common/cli/src/ip_address.c958
-rw-r--r--data/mnet/Common/cli/src/parser.c2062
-rw-r--r--data/mnet/Common/cli/src/parser_actions.c3486
-rw-r--r--data/mnet/Common/cli/src/parser_input.c1432
-rw-r--r--data/mnet/Common/cli/src/parser_modes.c534
-rw-r--r--data/mnet/Common/cli/src/parser_print.c687
-rw-r--r--data/mnet/Common/cli/src/parser_printf.c981
-rw-r--r--data/mnet/Common/cli/src/parser_privilege.c322
-rw-r--r--data/mnet/Common/cli/src/parser_util.c268
-rw-r--r--data/mnet/Common/cli/src/queue.c513
-rw-r--r--data/mnet/Common/cli/src/show_chain.c220
-rw-r--r--data/mnet/Common/cli/src/sys_debug.c261
-rw-r--r--data/mnet/Common/cli/src/usrScript.c73
-rw-r--r--data/mnet/Common/cli/src/util.c866
-rw-r--r--data/mnet/Common/cli/vxsh/Makefile103
-rw-r--r--data/mnet/Common/cli/vxsh/vxsh.c9
-rw-r--r--data/mnet/Common/gglink/Makefile47
-rw-r--r--data/mnet/Common/gglink/src/Makefile61
-rw-r--r--data/mnet/Common/gglink/src/gglink.cpp1178
-rw-r--r--data/mnet/Common/include/CdrDbg.h130
-rw-r--r--data/mnet/Common/include/JCErr.h60
-rw-r--r--data/mnet/Common/include/JCStdDef.h103
-rw-r--r--data/mnet/Common/include/MnetProductId.h102
-rw-r--r--data/mnet/Common/include/NetBuffer.h118
-rw-r--r--data/mnet/Common/include/Os/JCCTimer.h117
-rw-r--r--data/mnet/Common/include/Os/JCModule.h88
-rw-r--r--data/mnet/Common/include/Os/JCMsgQueue.h91
-rw-r--r--data/mnet/Common/include/Os/JCMutex.h44
-rw-r--r--data/mnet/Common/include/Os/JCTask.h131
-rw-r--r--data/mnet/Common/include/Pm/pm_common.h209
-rw-r--r--data/mnet/Common/include/SmsPP/smspp_inf.h84
-rw-r--r--data/mnet/Common/include/VCLOGGING.H283
-rw-r--r--data/mnet/Common/include/bssgp/bssgp_api.h600
-rw-r--r--data/mnet/Common/include/bssgp/bssgp_decoder.h68
-rw-r--r--data/mnet/Common/include/bssgp/bssgp_encoder.h69
-rw-r--r--data/mnet/Common/include/bssgp/bssgp_ie_decoder.h77
-rw-r--r--data/mnet/Common/include/bssgp/bssgp_ie_encoder.h75
-rw-r--r--data/mnet/Common/include/bssgp/bssgp_net.h83
-rw-r--r--data/mnet/Common/include/bssgp/bssgp_prot.h180
-rw-r--r--data/mnet/Common/include/bssgp/bssgp_unitdata.h221
-rw-r--r--data/mnet/Common/include/bssgp/bssgp_util.h97
-rw-r--r--data/mnet/Common/include/cdr/CdrSSA.h77
-rw-r--r--data/mnet/Common/include/dbgfunc.h40
-rw-r--r--data/mnet/Common/include/defs.h127
-rw-r--r--data/mnet/Common/include/gglink/gglink_api.h336
-rw-r--r--data/mnet/Common/include/gplink/gplink_prot.h62
-rw-r--r--data/mnet/Common/include/gprsdefs.h34
-rw-r--r--data/mnet/Common/include/oam_api.h323
-rw-r--r--data/mnet/Common/include/oam_trap.h93
-rw-r--r--data/mnet/Common/include/socket/GenClientSocket.h79
-rw-r--r--data/mnet/Common/include/socket/GenSecServerSocket.h59
-rw-r--r--data/mnet/Common/include/socket/GenServerSocket.h74
-rw-r--r--data/mnet/Common/include/socket/GenSocket.h131
-rw-r--r--data/mnet/Common/include/socket/GenSocketSSL.h218
-rw-r--r--data/mnet/Common/include/socket/SslIntf.h41
-rw-r--r--data/mnet/Common/include/subsc/SubscGPRSInfoType.h69
-rw-r--r--data/mnet/Common/include/subsc/SubscINProfileType.h47
-rw-r--r--data/mnet/Common/include/subsc/SubscInfoType.h619
-rw-r--r--data/mnet/Common/include/subsc/SubscInfoUtil.h254
-rw-r--r--data/mnet/Common/include/table.h121
-rw-r--r--data/mnet/Common/include/vxTemplate/vxTemplateIF.h33
-rw-r--r--data/mnet/Common/logging/Makefile47
-rw-r--r--data/mnet/Common/logging/src/Makefile61
-rw-r--r--data/mnet/Common/logging/src/debug.cpp140
-rw-r--r--data/mnet/Common/logging/src/logging.cpp901
-rw-r--r--data/mnet/Common/netBuffer/Makefile34
-rw-r--r--data/mnet/Common/netBuffer/src/Makefile61
-rw-r--r--data/mnet/Common/netBuffer/src/NetBuffer.cpp407
-rw-r--r--data/mnet/Common/rsa/src_stub/makefile61
-rw-r--r--data/mnet/Common/rsa/src_stub/ssl_stub.c257
-rw-r--r--data/mnet/Common/snmp/Asn1/mnet-traps.mib0
-rw-r--r--data/mnet/Common/snmp/Makefile47
-rw-r--r--data/mnet/Common/snmp/src/Makefile63
-rw-r--r--data/mnet/Common/snmp/src/api_init.c85
-rw-r--r--data/mnet/Common/snmp/src/link_list.c316
-rw-r--r--data/mnet/Common/snmp/src/oam_api.c1274
-rw-r--r--data/mnet/Common/snmp/src/snmpLocalIoLib.c327
-rw-r--r--data/mnet/Common/snmp/src/snmp_fileio.c492
-rw-r--r--data/mnet/Common/snmp/src/snmp_trap.c437
-rw-r--r--data/mnet/Common/snmp/src/table.c1129
-rw-r--r--data/mnet/Common/snmp/src/vipermib.c1768
-rw-r--r--data/mnet/Common/socket/Makefile47
-rw-r--r--data/mnet/Common/socket/include/CallBackSSL.h35
-rw-r--r--data/mnet/Common/socket/src/GenClientSocket.cpp236
-rw-r--r--data/mnet/Common/socket/src/GenSecServerSocket.cpp110
-rw-r--r--data/mnet/Common/socket/src/GenServerSocket.cpp210
-rw-r--r--data/mnet/Common/socket/src/GenSocket.cpp403
-rw-r--r--data/mnet/Common/socket/src/GenSocketSSL.cpp167
-rw-r--r--data/mnet/Common/socket/src/Makefile61
-rw-r--r--data/mnet/Common/socket/src_ssl/GenSocketSSL_lib.cpp968
-rw-r--r--data/mnet/Common/socket/src_ssl/Makefile61
-rw-r--r--data/mnet/Common/socket/src_ssl/ssl_intf.cpp235
-rw-r--r--data/mnet/Common/socket/src_stub/GenSocketSSL_stub.cpp95
-rw-r--r--data/mnet/Common/socket/src_stub/Makefile61
-rw-r--r--data/mnet/Common/socket/src_stub/ssl_intf.cpp23
-rw-r--r--data/mnet/Common/subsc/Makefile47
-rw-r--r--data/mnet/Common/subsc/src/Makefile61
-rw-r--r--data/mnet/Common/subsc/src/SubscInfo.cpp200
-rw-r--r--data/mnet/Common/subsc/src/SubscInfoMsgDecoder.cpp610
-rw-r--r--data/mnet/Common/subsc/src/SubscInfoMsgEncoder.cpp459
-rw-r--r--data/mnet/Common/subsc/src/SubscInfoUtil.cpp1814
-rw-r--r--data/mnet/Common/vxTemplate/Makefile47
-rw-r--r--data/mnet/Common/vxTemplate/include/vxTemplate.h33
-rw-r--r--data/mnet/Common/vxTemplate/src/Makefile61
-rw-r--r--data/mnet/Common/vxTemplate/src/vxTemplate.c34
315 files changed, 70206 insertions, 0 deletions
diff --git a/data/mnet/Common/Alarm/Makefile b/data/mnet/Common/Alarm/Makefile
new file mode 100644
index 0000000..cad5689
--- /dev/null
+++ b/data/mnet/Common/Alarm/Makefile
@@ -0,0 +1,47 @@
+##########################################################
+#
+# (c) Copyright Cisco 2000
+# All Rights Reserved
+#
+# Use Examples:
+#
+# Case 1:
+# make all VOB=GP10 -
+# Places .out in VOB/bin directory
+#
+# Case 2:
+# make all VOB=GP10 APPDIR=Host\<Application Name>\<Source Directory> -
+# Places .o file(s) in VOB\$(APPDIR)\bin directory.
+#
+# <Application Name> = Name of Application directory
+# <Source Directory> = application sub directory where the calling
+# Makefile resides.
+#
+# Example: make all VOB=GP10 APPDIR=Host\vxTemplate\src
+#
+# (OPTIONAL) Append REPLACE - Replaces the List of directories
+# to be used in the SUBDIRS variable
+#
+# Example: make all VOB=GP10 APPDIR=Host\vxTemplate\src REPLACE=src
+#
+# Note: This make file must reference a VOB that
+# has a defs.mk in the top level directory.
+#
+##########################################################
+
+SUBDIRS = src
+
+# TOP_OF_VOB must be defined before including l3defs.mk
+TOP_OF_VOB = ..\..
+
+VOBDIR = $(TOP_OF_VOB)/$(VOB)
+
+# Allows a sub-set of the source code directories to be used
+
+ifneq ($(REPLACE),)
+ SUBDIRS = $(REPLACE)
+endif
+
+include $(VOBDIR)/l3defs.mk
+
+
diff --git a/data/mnet/Common/Alarm/include/AlarmTask.h b/data/mnet/Common/Alarm/include/AlarmTask.h
new file mode 100644
index 0000000..09bb68c
--- /dev/null
+++ b/data/mnet/Common/Alarm/include/AlarmTask.h
@@ -0,0 +1,151 @@
+/*********************************************************************/
+/* */
+/* (c) Copyright Cisco 2000 */
+/* All Rights Reserved */
+/* */
+/*********************************************************************/
+
+/*********************************************************************/
+/* */
+/* Version : 1.0 */
+/* Status : Under development */
+/* File : AlarmTask.h */
+/* Author(s) : Bhawani Sapkota */
+/* Create Date : 9/18/2000 */
+/* Description : This file contains Alarm task routines */
+/* */
+/*********************************************************************/
+/* REVISION HISTORY
+/*___________________________________________________________________*/
+/*----------+--------+-----------------------------------------------*/
+/* Name | Date | Reason */
+/*----------+--------+-----------------------------------------------*/
+/* Bhawani |09/28/00| Initial Draft */
+/*----------+--------+-----------------------------------------------*/
+/*********************************************************************/
+
+#ifndef _ALARMTASK_H_
+#define _ALARMTASK_H_ /* include once only */
+
+#include "Alarm.h"
+
+
+/* Include product specific code here */
+#if defined (MNET_PRODUCT_SPECIFIC_GS)
+#include "GSOsTune.h"
+#elif defined (MNET_PRODUCT_SPECIFIC_GMC)
+#include "vclogging.h"
+#elif defined (MNET_PRODUCT_SPECIFIC_GP10)
+#include "Logging/vclogging.h"
+#endif
+
+typedef struct _AlarmEntry_t
+{
+ AlarmCode_t code; // last error code
+ int id; // first alarm ID
+ Alarm_severity_t severity; // severity
+ ubyte4 utc; // outstanding since this time
+ int count;
+ struct _AlarmEntry_t *next;
+}AlarmEntry_t;
+
+
+class AlarmTask:public JCTask {
+public:
+
+ AlarmTask(char *);
+ ~AlarmTask();
+
+ int InitAlarmTask();
+
+ static int bootupTimeoutHandler();
+ static int entryPoint();
+
+ static int AlarmMain(void);
+ static char *srcName();
+
+ static AlarmTask *theAlarmTask;
+
+ // disk operation
+ STATUS saveAlarm(const char* msg);
+ STATUS renameOldLogFile();
+ STATUS getLastId(unsigned long *id);
+ int generateNextId();
+
+ AlarmEntry_t *findAlarmEntry(MNET_MODULE_ID mid, AlarmCode_t errorCode);
+ bool addAlarmEntry(MNET_MODULE_ID mid, MibTag moduleErrorTag, AlarmCode_t code, char *arg1=NULL, char *arg2=NULL);
+ bool delAlarmEntry(MNET_MODULE_ID mid, MibTag moduleErrorTag, AlarmCode_t code);
+ EnableDisableState_t updateOperationalState();
+
+
+ // module handling
+ AlarmCode_t getMdlStatus(MNET_MODULE_ID mid);
+ AlarmEntry_t *allocEntry(MNET_MODULE_ID id);
+
+ void printStatus();
+ void getOutstandingAlarmCount(ubyte1 &, ubyte1 &, ubyte1 &);
+
+ // message q operation
+ JC_STATUS msgqSend( unsigned int msgType, char * buffer, unsigned int nBytes);
+ JC_STATUS alarmSend(InterModuleAlarmMsgType_t mtype,
+ MNET_MODULE_ID mid,
+ MibTag moduleErrorTag=0,
+ AlarmCode_t alarm_code=EC_COMMON_NOERROR,
+ char *arg1=NULL,
+ char *arg2=NULL
+ );
+
+ //AMS Operation
+ bool sendSummaryUpdateToAms();
+ void reportNewAlarm(int id, MNET_MODULE_ID mid, AlarmCode_t ecode,
+ Alarm_severity_t severity, char * arg1=0, char * arg2=0);
+
+ //Operational State Management
+ EnableDisableState_t getOperationState();
+ void setOperationState(EnableDisableState_t opstate );
+
+ // Mib access control status
+ EnableDisableState_t getMibAcessControlState();
+ void setMibAcessControlState(EnableDisableState_t opstate);
+
+ void updateModuleLastError(MNET_MODULE_ID mid, MibTag moduleErrorTag);
+ void setModuleLastError(MibTag moduleErrorTag, AlarmCode_t alarm_code);
+
+ // startup and quit
+ void quit();
+ int startup();
+ void closeSocket();
+
+
+private:
+ JCMsgQueue *jcMsgQ;
+ JCCTimer *initTimer;
+ char *_mnetbase; /* holds MNET_BASE environment variable */
+ char *_logfilename; /* holds absolute path of the logfilename */
+
+ char *_sourceName; /* holds the source name */
+ char *_sourceType; /* type of the source (Gp, Gmc, Itp, */
+
+ char *_msgRecvBuff; /* holds received message */
+ AlarmEntry_t *_ms[MNET_MAX_MODULE_IDS]; /* current module Alarm Status */
+ AlarmEntry_t *_ap; /* Alarm pools */
+
+ int _statistics[2][Alarm_max_severity];
+
+ void populateSourceName();
+
+ //status variables
+ bool _quit;
+ bool _mibAccessState;
+
+ static bool isOneCreated;
+
+ // Disallow the following functions
+ AlarmTask();
+ AlarmTask(const AlarmTask&);
+ AlarmTask& operator=(const AlarmTask&);
+ int operator== (const AlarmTask&) const;
+};
+
+
+#endif
diff --git a/data/mnet/Common/Alarm/include/alarm.h b/data/mnet/Common/Alarm/include/alarm.h
new file mode 100644
index 0000000..ba5edd0
--- /dev/null
+++ b/data/mnet/Common/Alarm/include/alarm.h
@@ -0,0 +1,168 @@
+/*********************************************************************/
+/* */
+/* (c) Copyright Cisco 2000 */
+/* All Rights Reserved */
+/* */
+/*********************************************************************/
+
+/*********************************************************************/
+/* */
+/* Version : 1.0 */
+/* Status : Under development */
+/* File : AlarmTask.h */
+/* Author(s) : Bhawani Sapkota */
+/* Create Date : 9/18/2000 */
+/* Description : This file contains alarm task basic defination */
+/* routines */
+/* */
+/*********************************************************************/
+/* REVISION HISTORY
+/*___________________________________________________________________*/
+/*----------+--------+-----------------------------------------------*/
+/* Name | Date | Reason */
+/*----------+--------+-----------------------------------------------*/
+/* Bhawani |07/14/00| Initial Draft */
+/* Bhawani |11/20/00| resturctured to share among GP, GMS and GS */
+/*----------+--------+-----------------------------------------------*/
+/*********************************************************************/
+
+
+#if !defined(_ALARM_H_)
+#define _ALARM_H_
+
+#include "AlarmCode.h"
+#include "Os/JCMsgQueue.h"
+#include "Os/JCModule.h"
+#include "Os/JCCTimer.h"
+#include "Os/JCTask.h"
+
+#include "alarm_prodSpec.h"
+
+typedef unsigned short ubyte2;
+typedef unsigned long ubyte4;
+typedef unsigned char ubyte1;
+
+typedef short sbyte2;
+typedef long sbyte4;
+
+
+#define ALARM_q_maxMsgs 32
+#define ALARM_q_maxMsgLength 100
+#define ALARM_q_option MSG_Q_PRIORITY
+#define ALARM_q_timeout 18000 /* 5 minutes */
+
+#define ALARM_task_name "tAlarm"
+#define ALARM_mib_lock_timeout 7200 /* 2 minutes */
+
+#define ALARM_record_length 70
+#define ALARM_max_records 58
+#define ALARM_max_outstanding 50
+
+
+/* It is assumeed that current working directory is ViperCall */
+
+#define ALARM_logFile "/Alarm/alarm.log"
+#define ALARM_logFileMaxSize 128
+#define ALARM_dirChar '/'
+
+#define ALARM_maxMsgSize 1024
+#define ALARM_defaultRecvBuffer 128
+#define ALARM_optionalArgSize 40
+
+
+#define ALARM_monStation "QSEvent"
+#define ALARM_mchResponse "mchResponse"
+
+typedef enum Alarm_severity
+{
+ Alarm_critical=0,
+ Alarm_major,
+ Alarm_minor,
+ Alarm_info,
+ Alarm_max_severity
+} Alarm_severity_t;
+
+
+typedef enum
+{
+ InterModuleAlarmMsgTypeClearAlarm = 0,
+ InterModuleAlarmMsgTypeRaiseAlarm,
+ InterModuleAlarmMsgTypeShutdown,
+ InterModuleAlarmMsgTypeReboot
+}InterModuleAlarmMsgType_t;
+
+
+typedef struct
+{
+ ubyte1 senderId; /* message originator */
+ InterModuleAlarmMsgType_t msgType; /* message type (MT_TRAP) */
+ MNET_MODULE_ID srcModuleId; /* Alarm source module ID */
+ MibTag errorTag; /* This module's ErrorTag */
+ AlarmCode_t code; /* Alarm code */
+ char arg1[ALARM_optionalArgSize]; /* argument 1 */
+ char arg2[ALARM_optionalArgSize]; /* argument 2 */
+}InterModuleAlarmMsg_t;
+
+
+typedef enum
+{
+ stateDisabled=0,
+ stateEnabled=1
+} EnableDisableState_t;
+
+
+/* Printing and sending to logging module */
+void alarm_print(char *format, ...);
+
+#ifdef _UT
+void HexDumper(ubyte1 *buffer, int length);
+#define alarm_debug(XX) printf("[ALARM TRACE] %s ->", fname); alarm_print XX
+#define alarm_error(XX) printf("[Alarm Error] %s ->", fname); alarm_print XX
+#define alarm_warning(XX) printf("[Alarm Warning] %s ->", fname); alarm_print XX
+#define alarm_dump(x,y); HexDumper(x, y);
+#define alarm_fenter(XX); static char fname[] = XX;
+#define alarm_fexit();
+#else
+#define alarm_fenter(XXX); \
+ DBG_FUNC(XXX, MY_LOGID); \
+ DBG_ENTER(); \
+
+#define alarm_fexit(); DBG_LEAVE();
+
+#define alarm_debug(XX) DBG_TRACE XX
+#define alarm_error(XX) DBG_ERROR XX
+#define alarm_warning(XX) DBG_WARNING XX
+#define alarm_dump(x,y); DBG_HEXDUMP(x,y);
+#endif
+
+
+/* defined at alarm_main module */
+int alarmTask();
+int alarm_taskCreate();
+void alarm_taskQuit ();
+void alarm_msgPrint(char *format, ...);
+void alarm_rebootHandler ( int startType );
+
+
+/* In file alarm_modules.cpp */
+void alarm_rptMdlStatus(int id, int mid, int ecode, int severity=Alarm_critical,
+ char* arg1= (char *) NULL, char* arg2= (char *) NULL);
+void alarm_printStatus();
+
+
+/* In file alarm_message.cpp */
+void alarm_processMsg(char *inComingMsg);
+
+/* It will go to alarm_event.cpp */
+void alarm_clientMsg (char *, short, unsigned long);
+void alarm_broadcast(const char *msg);
+int alarm_generateNextId();
+
+
+/* alarm_diskFile.cpp */
+STATUS alarm_renameOldLogFile();
+
+/* TimeSync api from Time Sync module */
+extern void time_syncTime();
+
+#endif
diff --git a/data/mnet/Common/Alarm/include/alarm_interface.h b/data/mnet/Common/Alarm/include/alarm_interface.h
new file mode 100644
index 0000000..9d30b45
--- /dev/null
+++ b/data/mnet/Common/Alarm/include/alarm_interface.h
@@ -0,0 +1,127 @@
+/*********************************************************************/
+/* */
+/* (c) Copyright Cisco 2000 */
+/* All Rights Reserved */
+/* */
+/*********************************************************************/
+
+/*********************************************************************/
+/* */
+/* Version : 1.0 */
+/* Status : Under development */
+/* File : AlarmTask.h */
+/* Author(s) : Bhawani Sapkota */
+/* Create Date : 9/18/2000 */
+/* Description : This file contains interface defination between */
+/* Alarm Source (GP, GMC, GS) and Alarm Monitoring */
+/* Server (APM1) */
+/* */
+/*********************************************************************/
+/* REVISION HISTORY
+/*___________________________________________________________________*/
+/*----------+--------+-----------------------------------------------*/
+/* Name | Date | Reason */
+/*----------+--------+-----------------------------------------------*/
+/* Bhawani |07/14/00| Initial Draft */
+/* Bhawani |11/20/00| resturctured to share among GP, GMS and GS */
+/* Bhawani |12/05/00| Added UDP server and client port so that the */
+/* | | server and clients can reside on the same IP */
+/* Bhawani |12/05/00| swaped the server and client port to make the */
+/* | | original port as the server port. */
+/*----------+--------+-----------------------------------------------*/
+/*********************************************************************/
+
+
+#if !defined(_ALARM_INTERFACE_H_)
+#define _ALARM_INTERFACE_H_
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+#define ALARM_viperCellNameMaxSize 41
+#define ALARM_viperCellIpMaxSize 16
+#define ALARM_unknownAlarmId 0x00
+
+/* Alarm Server's IP address is Gate Keeper's IP address */
+
+/* Alarm Client/Server's Universal UPD ports */
+#define ALARM_interfaceUdpPortClient 12791
+#define ALARM_interfaceUdpPortServer 11788
+
+#define ALARM_periodicUpdateInterval 300 /* seconds */
+
+
+/* Alarm Source Type */
+#define ALARM_srcTypViperCell 128
+#define ALARM_srcTypViperBase 129
+
+
+/* Alarm Message Type */
+#define ALARM_msgTypSummaryUpdate 1
+#define ALARM_msgTypAlarmEvent 2
+
+typedef char sbyte1;
+typedef short sbyte2;
+typedef long sbyte4;
+
+typedef unsigned char ubyte1;
+typedef unsigned short ubyte2;
+typedef unsigned long ubyte4;
+
+/* Message header */
+typedef struct AlarmInterfaceMsgHeader_{
+ ubyte1 alarmSrcType;
+ ubyte1 alarmMsgType;
+ ubyte2 alarmMsgLen;
+}AlarmInterfaceMsgHeader;
+
+#define ALARM_interfaceMsgHdrLen 4
+
+/* Summary update data */
+typedef struct AlarmSummaryUpdateData_{
+ ubyte4 alarmSrcIp;
+ sbyte1 alarmSrcName[ALARM_viperCellNameMaxSize];
+ ubyte1 alarmCriticalCount;
+ ubyte1 alarmMajorCount;
+ ubyte1 alarmMinorCount;
+}AlarmSummaryUpdateData;
+
+#define ALARM_summaryUpdateDataLen (7 + ALARM_viperCellNameMaxSize)
+#define ALARM_summaryUpdateMsgLen (ALARM_interfaceMsgHdrLen + ALARM_summaryUpdateDataLen + sizeof(long))
+
+#define ALARM_eventDataLen (28 + ALARM_viperCellNameMaxSize)
+#define ALARM_eventMsgLen (ALARM_interfaceMsgHdrLen + ALARM_eventDataLen + sizeof(long))
+
+
+/* Stubs for new event data */
+typedef struct AlarmEventData_ {
+ ubyte4 alarmId;
+ ubyte4 alarmCode;
+ ubyte4 alarmTimestamp;
+ ubyte4 alarmSrcIp;
+ sbyte1 alarmSrcModuleName[ALARM_viperCellNameMaxSize];
+ ubyte4 alarmSrcModuleId;
+ ubyte4 opt1;
+ ubyte4 opt2;
+}AlarmEventData;
+
+
+/* Alarm Complete message */
+typedef long Align;
+typedef struct Alarm
+{
+ AlarmInterfaceMsgHeader hdr;
+ union {
+ AlarmSummaryUpdateData summaryUpdateData;
+ AlarmEventData eventData;
+ }body;
+ Align x;
+}AlarmViperCellToAmsMsg;
+
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif /* _ALARM_INTERFACE_H_ */
diff --git a/data/mnet/Common/Alarm/src/Makefile b/data/mnet/Common/Alarm/src/Makefile
new file mode 100644
index 0000000..146a01d
--- /dev/null
+++ b/data/mnet/Common/Alarm/src/Makefile
@@ -0,0 +1,44 @@
+
+##########################################################
+#
+# (c) Copyright Cisco 2000
+# All Rights Reserved
+#
+# Use Examples:
+#
+# Case 1:
+# make all VOB=GP10 -
+# Places .out in VOB/bin directory
+#
+# Case 2:
+# make all VOB=GP10 APPDIR=Host\<Application Name>\<Source Directory> -
+# Places .o file(s) in VOB\$(APPDIR)\bin directory.
+#
+# <Application Name> = Name of Application directory
+# <Source Directory> = application sub directory where the calling
+# Makefile resides.
+#
+# Example: make all VOB=GP10 APPDIR=Host\vxTemplate\src
+#
+#
+# Note: This make file must reference a VOB that
+# has a defs.mk in the top level directory.
+#
+##########################################################
+
+# TOP_OF_VOB must be defined before including l3defs.mk
+TOP_OF_VOB = ..\..
+
+# Name of this App's Directory
+THIS_APP_DIR = Alarm
+
+VOB2DIR = $(TOP_OF_VOB)\..\$(VOB)
+BINDIR = ..\bin
+
+include $(VOB2DIR)\l3defs.mk
+
+all: $(MODULE_OBJS)
+
+cleanall:
+ @for %f in ($(notdir $(MODULE_OBJS))) do \
+ $(RM) ..\bin\%f
diff --git a/data/mnet/Common/Alarm/src/alarm_diskFile.cpp b/data/mnet/Common/Alarm/src/alarm_diskFile.cpp
new file mode 100644
index 0000000..e7d2564
--- /dev/null
+++ b/data/mnet/Common/Alarm/src/alarm_diskFile.cpp
@@ -0,0 +1,198 @@
+
+/*********************************************************************/
+/* */
+/* (c) Copyright Cisco 2000 */
+/* All Rights Reserved */
+/* */
+/*********************************************************************/
+
+/*********************************************************************/
+/* */
+/* Version : 1.0 */
+/* Status : Under development */
+/* File : AlarmTask.h */
+/* Author(s) : Bhawani Sapkota */
+/* Create Date : 07/11/99 */
+/* Description : This file contains routines to perform disk I/O to */
+/* save alarm to the disk file. */
+/* */
+/*********************************************************************/
+/* REVISION HISTORY
+/*___________________________________________________________________*/
+/*----------+--------+-----------------------------------------------*/
+/* Name | Date | Reason */
+/*----------+--------+-----------------------------------------------*/
+/* Bhawani |09/28/00| Initial Draft */
+/* Bhawani |11/20/00| resturctured to share among GP, GMS and GS */
+/*----------+--------+-----------------------------------------------*/
+/*********************************************************************/
+#include "AlarmTask.h"
+
+#include "dirent.h"
+#include "stat.h"
+#include "time.h"
+#include "string.h"
+static unsigned long CyclicFileRecordIndex = 0;
+
+STATUS AlarmTask::saveAlarm(const char* msg)
+{
+ FILE *alarmfd;
+
+ alarm_fenter("AlarmTask::saveAlarm");
+
+ // Opens for reading and writing;
+ alarmfd = fopen(_logfilename, "r+");
+ if (alarmfd == NULL)
+ {
+ alarm_error(("Could not open alarm log file %s (Reason: %s)\n", _logfilename, strerror(errno)));
+ alarm_fexit();
+ return ERROR;
+ }
+
+ long fpos = ALARM_record_length*CyclicFileRecordIndex++;
+ CyclicFileRecordIndex = CyclicFileRecordIndex%ALARM_max_records;
+
+ fseek(alarmfd, fpos, SEEK_SET);
+
+ fputs(msg, alarmfd);
+ fclose(alarmfd);
+ alarm_debug(("Alarm Message successfully saved\n"));
+ alarm_fexit();
+ return OK;
+}
+
+STATUS AlarmTask::renameOldLogFile()
+{
+ struct stat fileStat;
+
+ alarm_fenter("alarm_renameOldLogFile");
+
+ /* check if old Alarrm log file exists */
+ if (stat (_logfilename, &fileStat) == OK)
+ {
+ /* The file exist */
+ struct tm localTime;
+ struct tm *ltime = &localTime;
+ time_t longTime;
+ char *pdest;
+ char newFileName[ALARM_logFileMaxSize];
+
+ longTime = time(NULL);
+
+ ltime = localtime(&longTime);
+
+ strcpy(newFileName, _logfilename);
+
+ /* Assumes that file name is long enough */
+ pdest = strrchr(newFileName, ALARM_dirChar);
+ if( pdest != NULL )
+ {
+ sprintf(pdest+1, "AlarmLogAsOf_%d-%d-%d,%d:%d", ltime->tm_mon+1, ltime->tm_mday,
+ ltime->tm_year+1900,ltime->tm_hour, ltime->tm_min);
+ } else {
+ sprintf(newFileName, "AlarmLogAsOf_%d-%d-%d,%d:%d", ltime->tm_mon+1, ltime->tm_mday,
+ ltime->tm_year+1900,ltime->tm_hour, ltime->tm_min);
+ }
+ alarm_debug(("Renaming %s file to %s\n", _logfilename, newFileName));
+ if (rename(_logfilename, newFileName) == ERROR)
+ {
+
+ /* rename failed */
+ FILE *alarmfd;
+
+ alarm_error(("Could not rename old file (Reason: %s)\n", strerror(errno)));
+ alarm_warning(("Truncating the old alarm file: %s\n", _logfilename));
+
+ alarmfd = fopen(_logfilename, "w");
+ if (alarmfd == NULL)
+ {
+ alarm_error(("Could not truncate file(Reason: %s)\n",strerror(errno)));
+ } else {
+ fclose(alarmfd);
+ }
+
+ } else {
+ alarm_debug(("Old alarm file successfully renamed to %s\n", newFileName));
+ }
+
+ } else {
+ alarm_warning(("Old alarm log file \"%s\" does not exist.\n", _logfilename));
+ }
+
+ alarm_fexit();
+ return OK;
+
+}
+
+
+STATUS AlarmTask::getLastId(unsigned long *id)
+{
+ FILE *alarmfd;
+ struct stat statBuff;
+ alarm_fenter("AlarmTask::getLastId");
+ STATUS status;
+
+
+ status = stat(_logfilename, &statBuff);
+
+
+ if ( status == ERROR // file does not exist
+ || statBuff.st_size == 0 // newly created
+ || statBuff.st_size % ALARM_record_length != 0 // corrupt file
+ || statBuff.st_size > ALARM_max_records*ALARM_record_length // corrupt file
+ )
+ {
+ // if size is a zero, there was no alarm file
+ *id = 1;
+ CyclicFileRecordIndex = 0;
+ alarmfd = fopen(_logfilename, "w"); // truncate file
+ if (alarmfd != NULL)
+ fclose(alarmfd);
+ else
+ {
+ alarm_error(("Could not create %s for writing: %s\n", _logfilename, strerror(errno)));
+ }
+
+ } else {
+
+ alarm_debug(("Current Alarm disk file size = %d\n", statBuff.st_size));
+
+ if (statBuff.st_size < ALARM_max_records*ALARM_record_length)
+ {
+
+ // the size less then max size
+ CyclicFileRecordIndex = statBuff.st_size / ALARM_record_length;
+ *id = CyclicFileRecordIndex+1;
+ } else {
+ unsigned long id1, id2, i;
+
+ alarmfd= fopen(_logfilename, "r");
+ if (alarmfd == NULL)
+ {
+ alarm_error(("Cannot open() Alarm disk file %s to read (Reason: %s)\n", _logfilename, strerror(errno)));
+ *id =1;
+ CyclicFileRecordIndex = 0;
+ status = ERROR;
+ } else {
+ // file is ALARM_max_records*ALARM_record_length size
+ fseek(alarmfd, 0, SEEK_SET);
+ fscanf(alarmfd, "%u", &id1);
+ for(i=1; i< ALARM_max_records; i++)
+ {
+ fseek(alarmfd, i*ALARM_record_length, SEEK_SET);
+ fscanf(alarmfd, "%u", &id2);
+ if(id1> id2)
+ {
+ break;
+ } else {
+ id1 = id2;
+ }
+ }
+ CyclicFileRecordIndex = i % ALARM_max_records;
+ *id = id1+1;
+ }
+ }
+ }
+ alarm_fexit();
+ return status;
+}
diff --git a/data/mnet/Common/Alarm/src/alarm_event.cpp b/data/mnet/Common/Alarm/src/alarm_event.cpp
new file mode 100644
index 0000000..1fb3713
--- /dev/null
+++ b/data/mnet/Common/Alarm/src/alarm_event.cpp
@@ -0,0 +1,196 @@
+
+/*********************************************************************/
+/* */
+/* (c) Copyright Cisco 2000 */
+/* All Rights Reserved */
+/* */
+/*********************************************************************/
+
+/*********************************************************************/
+/* */
+/* Version : 1.0 */
+/* Status : Under development */
+/* File : AlarmTask.h */
+/* Author(s) : Bhawani Sapkota */
+/* Create Date : 07/11/99 */
+/* Description : contains alarm module message that interact with */
+/* other module . */
+/* */
+/*********************************************************************/
+/* REVISION HISTORY
+/*___________________________________________________________________*/
+/*----------+--------+-----------------------------------------------*/
+/* Name | Date | Reason */
+/*----------+--------+-----------------------------------------------*/
+/* Bhawani |07/11/99| Initial Draft */
+/* Bhawani |11/20/00| resturctured to share among GP, GMS and GS */
+/*----------+--------+-----------------------------------------------*/
+
+#ifndef _ALARM_EVENT_CPP_
+#define _ALARM_EVENT_CPP_
+
+#include "AlarmTask.h"
+
+void alarm_clientMsg ( char * message, // the message from the client
+ short size, // size of the message
+ unsigned long clientId // unique client ID of the requester client
+ )
+{
+
+ alarm_fenter("alarm_clientMsg");
+ alarm_debug(("Message receive from client (ID = %d)", clientId));
+ alarm_debug(("%s\n", message));
+ alarm_fexit();
+}
+
+
+void alarm_broadcast(const char *msg)
+{
+ int len;
+ alarm_fenter("alarm_broadcast");
+ fflush(stdout);
+
+ len = strlen(msg);
+ //TcpSrvSendResponse(msg, len, kAlarmGpName);
+ alarm_debug(("Alarm message was sent\n"));
+ alarm_fexit();
+}
+
+JC_STATUS AlarmTask::msgqSend(unsigned int msgType, char * buffer, unsigned int nBytes)
+{
+ return jcMsgQ->JCMsgQSend(this->jcMsgQ, msgType, MY_MODULE_ID, buffer, nBytes, JC_NO_WAIT, JC_MSG_Q_FIFO);
+}
+
+
+JC_STATUS AlarmTask::alarmSend
+ (
+ InterModuleAlarmMsgType_t mtype,
+ MNET_MODULE_ID mid,
+ MibTag moduleErrorTag,
+ AlarmCode_t alarm_code,
+ char *arg1,
+ char *arg2
+ )
+{
+ InterModuleAlarmMsg_t alarmMsg;
+
+ memset(&alarmMsg, 0, sizeof(InterModuleAlarmMsg_t));
+
+ alarmMsg.errorTag = moduleErrorTag;
+ alarmMsg.code = alarm_code;
+ alarmMsg.senderId = (ubyte1) MY_MODULE_ID;
+ alarmMsg.msgType = mtype;
+ alarmMsg.srcModuleId = mid;
+
+ if (NULL != arg1)
+ {
+ strncpy(alarmMsg.arg1, arg1, ALARM_optionalArgSize-1);
+ }
+
+ if (NULL != arg2)
+ {
+ strncpy(alarmMsg.arg2, arg2, ALARM_optionalArgSize-1);
+ }
+
+ return AlarmTask::theAlarmTask->msgqSend
+ (InterModuleAlarmMsgTypeRaiseAlarm,
+ (char *) &alarmMsg,
+ sizeof(InterModuleAlarmMsg_t));
+
+}
+
+extern "C" JC_STATUS alarm_raise(MNET_MODULE_ID mid, MibTag moduleErrorTag, AlarmCode_t alarm_code)
+{
+ return AlarmTask::theAlarmTask->alarmSend(InterModuleAlarmMsgTypeRaiseAlarm, mid, moduleErrorTag, alarm_code);
+
+}
+
+extern "C" JC_STATUS alarm_raise_args(MNET_MODULE_ID mid, MibTag moduleErrorTag, AlarmCode_t alarm_code, int arg1, int arg2)
+{
+ char pszArg1[ALARM_optionalArgSize];
+ char pszArg2[ALARM_optionalArgSize];
+ sprintf (pszArg1, "%d", arg1);
+ sprintf (pszArg2, "%d", arg2);
+
+ return AlarmTask::theAlarmTask->alarmSend(InterModuleAlarmMsgTypeRaiseAlarm, mid, moduleErrorTag, alarm_code, pszArg1, pszArg2);
+
+}
+
+extern "C" JC_STATUS alarm_clear(MNET_MODULE_ID mid, MibTag moduleErrorTag, AlarmCode_t alarm_code)
+{
+ return AlarmTask::theAlarmTask->alarmSend(InterModuleAlarmMsgTypeClearAlarm, mid, moduleErrorTag, alarm_code);
+}
+
+EnableDisableState_t AlarmTask::getOperationState()
+{
+ long opState;
+ oam_getMibIntVar(MY_MIB_OPERATION_STATE, &opState);
+ return (EnableDisableState_t) opState;
+}
+
+
+
+void AlarmTask::setOperationState(EnableDisableState_t opstate )
+{
+ EnableDisableState_t state = getOperationState();
+
+ if(state != opstate)
+ {
+ oam_setMibIntVar(MY_MODULE_ID, MY_MIB_OPERATION_STATE, opstate);
+ }
+}
+
+
+EnableDisableState_t AlarmTask::getMibAcessControlState()
+{
+ long opState;
+ oam_getMibIntVar(MY_MIB_ACCESS_CONTROL_TAG, &opState);
+ return (EnableDisableState_t) opState;
+}
+
+
+void AlarmTask::setMibAcessControlState(EnableDisableState_t opstate )
+{
+ EnableDisableState_t state = getMibAcessControlState();
+ alarm_fenter("AlarmTask::setMibAcessControlState");
+
+ if(state != opstate)
+ {
+ oam_setMibIntVar(MY_MODULE_ID, MY_MIB_ACCESS_CONTROL_TAG, opstate);
+ }
+
+ // local mib status
+ _mibAccessState = (opstate == stateEnabled);
+
+ if (_mibAccessState)
+ {
+ // This is the first time
+ initTimer->cancelTimer();
+ alarm_debug (("Mib access is now enabled\n"));
+ }
+ alarm_fexit();
+}
+
+void AlarmTask::setModuleLastError(MibTag moduleErrorTag, AlarmCode_t alarm_code)
+{
+ oam_setMibIntVar(MY_MODULE_ID, moduleErrorTag, alarm_code);
+}
+
+void AlarmTask::populateSourceName()
+{
+ const int kDisplayStringSize = 256;
+ char name[kDisplayStringSize];
+
+ memset(name, 0, kDisplayStringSize);
+ oam_getMibByteAry(MY_MIB_SOURCE_NAME, (ubyte1 *) name, kDisplayStringSize-1);
+ _sourceName = new char[strlen(name+1)];
+ strcpy(_sourceName, name);
+}
+
+char * AlarmTask::srcName()
+{
+ return theAlarmTask->_sourceName;
+}
+
+
+#endif /* _ALARM_EVENT_CPP_ */ \ No newline at end of file
diff --git a/data/mnet/Common/Alarm/src/alarm_main.cpp b/data/mnet/Common/Alarm/src/alarm_main.cpp
new file mode 100644
index 0000000..19682dc
--- /dev/null
+++ b/data/mnet/Common/Alarm/src/alarm_main.cpp
@@ -0,0 +1,187 @@
+/*********************************************************************/
+/* */
+/* (c) Copyright Cisco 2000 */
+/* All Rights Reserved */
+/* */
+/*********************************************************************/
+
+/*********************************************************************/
+/* */
+/* Version : 1.0 */
+/* Status : Under development */
+/* File : AlarmTask.h */
+/* Author(s) : Bhawani Sapkota */
+/* Create Date : 9/18/2000 */
+/* Description : This file contains main routines for the alarm task */
+/* */
+/*********************************************************************/
+/* REVISION HISTORY
+/*___________________________________________________________________*/
+/*----------+--------+-----------------------------------------------*/
+/* Name | Date | Reason */
+/*----------+--------+-----------------------------------------------*/
+/* Bhawani |09/28/00| Initial Draft */
+/* Bhawani |11/20/00| resturctured to share among GP, GMS and GS */
+/*----------+--------+-----------------------------------------------*/
+/*********************************************************************/
+
+
+#include "AlarmTask.h"
+#include "ctype.h"
+
+#if defined( _TCP_SERVER_EXIST)
+#include "TcpServer/TcpSrvApi.h"
+#endif
+
+AlarmTask * AlarmTask::theAlarmTask = NULL;
+
+bool AlarmTask::isOneCreated = false;
+
+AlarmTask::~AlarmTask()
+{
+ alarm_fenter("AlarmTask::~AlarmTask");
+ alarm_debug(("Alarm Task instance is being deleted"));
+ delete jcMsgQ;
+ delete initTimer;
+ alarm_fexit();
+}
+
+int AlarmTask::entryPoint()
+{
+
+ return theAlarmTask->startup();
+
+}
+
+int AlarmTask::startup()
+{
+ int status;
+ unsigned int msgType;
+ MNET_MODULE_ID senderId;
+ unsigned int recvMsgsize;
+
+
+ alarm_fenter("alarmTask");
+
+ // Rename the old alarm file
+ // alarm_renameOldLogFile();
+
+#if defined( _TCP_SERVER_EXIST)
+
+ // Register TCP server call back function
+ TcpSrvRegHand(kAlarmGpName, // Client Group Name (<= kClientGpNameMax)
+ alarm_clientMsg); // Function pointer to be called
+
+#endif
+
+ /* now go into the message loop */
+ JCTaskEnterLoop();
+ _quit = false;
+
+ while(_quit == false)
+ {
+
+ /* get message from queue; if necessary wait for a maximum of ALARM_q_timeout ticks */
+ status = jcMsgQ->JCMsgQReceive(&jcMsgQ, &msgType, &senderId, _msgRecvBuff, &recvMsgsize, ALARM_q_timeout);
+ if (status == ERROR)
+ {
+ if (errno == S_objLib_OBJ_TIMEOUT)
+ {
+
+ /* Send heartbeat message to AMS in case it was down and now it has been up */
+ sendSummaryUpdateToAms();
+ continue;
+ }
+
+ }
+ else
+ {
+
+ alarm_processMsg(_msgRecvBuff);
+ sendSummaryUpdateToAms();
+ }
+ }
+
+ JCTaskNormExit();
+
+ closeSocket();
+
+ isOneCreated = false;
+ //delete theAlarmTask;
+ theAlarmTask = NULL;
+
+ /* The application need to unsunscribe trap before exiting. */
+ alarm_debug(("Alarm Task is exiting ... \n"));
+ alarm_fexit();
+ return OK;
+}
+
+
+/* print alarm messages */
+void alarm_print(char *format, ...)
+{
+ va_list marker;
+ va_start( marker, format ); /* Initialize variable arguments. */
+ vprintf(format, marker);
+ fflush(stdout);
+ va_end( marker ); /* Reset variable arguments. */
+ return;
+
+}
+
+#ifdef _UT
+void HexDumper(ubyte1 *buffer, int length )
+/*++ Purpose:
+Put the inbound data in a hex dump format
+Arguments:
+buffer - points to the extension control block
+length - specifies the number of bytes to dump --*/
+{
+ int size;
+ int i;
+ int dwPos = 0;
+ while (length > 0) {
+ //
+ // Take min of 16 or length
+ //
+ size = min(16, length );
+ //
+ // Build text line
+ //
+ printf(" %04X ", dwPos );
+ for (i = 0; i < size; i++)
+ {
+ printf("%02X ", buffer[i] );
+ }
+ //
+ // Add spaces for short lines
+ //
+ while (i < 16)
+ {
+ printf(" " );
+ i++;
+ }
+ //
+ // Add ASCII chars
+ //
+ for (i = 0; i < size; i++)
+ {
+ if (isprint(buffer[i]))
+ {
+ printf("%c", buffer[i] );
+ } else {
+ printf("." );
+ }
+ }
+
+ printf("\n");
+ //
+ // Advance positions
+ //
+ length -= size;
+ dwPos += size;
+ buffer += size;
+ }
+}
+#endif /* _UT */
+
diff --git a/data/mnet/Common/Alarm/src/alarm_message.cpp b/data/mnet/Common/Alarm/src/alarm_message.cpp
new file mode 100644
index 0000000..a629ba6
--- /dev/null
+++ b/data/mnet/Common/Alarm/src/alarm_message.cpp
@@ -0,0 +1,101 @@
+
+/*********************************************************************/
+/* */
+/* (c) Copyright Cisco 2000 */
+/* All Rights Reserved */
+/* */
+/*********************************************************************/
+
+/*********************************************************************/
+/* */
+/* Version : 1.0 */
+/* Status : Under development */
+/* File : AlarmTask.h */
+/* Author(s) : Bhawani Sapkota */
+/* Create Date : 9/18/2000 */
+/* Description : This file contains alarm task message processing */
+/* routines */
+/* */
+/*********************************************************************/
+/* REVISION HISTORY
+/*___________________________________________________________________*/
+/*----------+--------+-----------------------------------------------*/
+/* Name | Date | Reason */
+/*----------+--------+-----------------------------------------------*/
+/* Bhawani |07/14/00| Initial Draft */
+/* Bhawani |11/20/00| resturctured to share among GP, GMS and GS */
+/*----------+--------+-----------------------------------------------*/
+/*********************************************************************/
+
+
+
+#ifndef _ALARM_MESSAGE_CPP_
+#define _ALARM_MESSAGE_CPP_
+
+#include "AlarmTask.h"
+
+
+void alarm_processTrap(TrapMsg *trapMsg)
+{
+ /* The Oam Message */
+ MibTag tag = trapMsg->mibTag;
+ int table = MIB_TBL(tag);
+ int mid = MIB_ITM(tag) - 1; // need to do this
+
+ alarm_fenter("alarm_processOamMsg");
+
+ alarm_fexit();
+ return;
+}
+
+void alarm_processAlarmMsg(InterModuleAlarmMsg_t * alarmMsg)
+{
+ alarm_fenter("alarm_processAlarmMsg");
+ switch(alarmMsg->msgType)
+ {
+
+ case InterModuleAlarmMsgTypeClearAlarm:
+ AlarmTask::theAlarmTask->delAlarmEntry(alarmMsg->srcModuleId, alarmMsg->errorTag, alarmMsg->code);
+ break;
+
+ case InterModuleAlarmMsgTypeRaiseAlarm:
+ AlarmTask::theAlarmTask->addAlarmEntry(alarmMsg->srcModuleId, alarmMsg->errorTag, alarmMsg->code, alarmMsg->arg1, alarmMsg->arg2);
+ break;
+
+ case InterModuleAlarmMsgTypeShutdown:
+ AlarmTask::theAlarmTask->quit();
+ break;
+
+ case InterModuleAlarmMsgTypeReboot:
+ AlarmTask::theAlarmTask->quit();
+ break;
+
+ default:
+ alarm_warning(("Not recognized alarm message type (message type = %d)", alarmMsg->msgType));
+ break;
+ }
+ alarm_fexit();
+ return;
+}
+
+void alarm_processMsg(char *inComingMsg)
+{
+ /* process the trap message here*/
+ alarm_fenter("alarm_processMsg");
+ alarm_debug(("A new message has just arrived.\n"));
+
+ switch(inComingMsg[0])
+ {
+ case MNET_MODULE_SNMP:
+ alarm_processTrap((TrapMsg *) inComingMsg);
+ break;
+ case MY_MODULE_ID:
+ alarm_processAlarmMsg((InterModuleAlarmMsg_t *) inComingMsg);
+ break;
+ default:
+ alarm_error(("Message from unsupported module (ID = %d)\n", inComingMsg[0]));
+ }
+ alarm_fexit();
+}
+
+#endif /* _ALARM_MESSAGE_CPP_ */ \ No newline at end of file
diff --git a/data/mnet/Common/Alarm/src/alarm_modules.cpp b/data/mnet/Common/Alarm/src/alarm_modules.cpp
new file mode 100644
index 0000000..3d3fb6f
--- /dev/null
+++ b/data/mnet/Common/Alarm/src/alarm_modules.cpp
@@ -0,0 +1,441 @@
+/*********************************************************************/
+/* */
+/* (c) Copyright Cisco 2000 */
+/* All Rights Reserved */
+/* */
+/*********************************************************************/
+
+/*********************************************************************/
+/* */
+/* Version : 1.0 */
+/* Status : Under development */
+/* File : AlarmTask.h */
+/* Author(s) : Bhawani Sapkota */
+/* Create Date : 9/18/2000 */
+/* Description : This file contains alarm task module handling */
+/* routines */
+/* */
+/*********************************************************************/
+/* REVISION HISTORY
+/*___________________________________________________________________*/
+/*----------+--------+-----------------------------------------------*/
+/* Name | Date | Reason */
+/*----------+--------+-----------------------------------------------*/
+/* Bhawani |07/14/00| Initial Draft */
+/* Bhawani |11/20/00| resturctured to share among GP, GMS and GS */
+/*----------+--------+-----------------------------------------------*/
+/*********************************************************************/
+
+#ifndef _ALARM_MODULE_CPP_
+#define _ALARM_MODULE_CPP_
+
+#include "AlarmTask.h"
+#include <time.h>
+
+Alarm_severity_t getSeverity(AlarmCode_t acode)
+{
+ Alarm_severity_t severity = Alarm_info;
+ int tmp = (acode & 0xFFFF);
+
+
+ if (tmp < ALARM_CRITICAL_START_POINT)
+ {
+ severity = Alarm_info;
+ } else if (tmp < ALARM_MAJOR_START_POINT) {
+ severity = Alarm_critical;
+ } else if (tmp < ALARM_MINOR_START_POINT) {
+ severity = Alarm_major;
+ } else if (tmp < ALARM_INFO_START_POINT) {
+ severity = Alarm_minor;
+ } else {
+ severity = Alarm_info;
+ }
+ return severity;
+}
+
+
+int AlarmTask::generateNextId()
+{
+ alarm_fenter("AlarmTask::generateNextId");
+ static unsigned long id = 0;
+
+ if(id == 0)
+ {
+ getLastId( &id);
+ alarm_debug(("Last Module ID = %d\n", id ));
+ }
+ alarm_fexit();
+ return id++;
+}
+
+
+AlarmCode_t AlarmTask::getMdlStatus(MNET_MODULE_ID mid)
+{
+ if (mid >=0 && mid < MNET_MAX_MODULE_IDS)
+ {
+ if (_ms[mid])
+ return (_ap[mid].code);
+ }
+ return EC_COMMON_NOERROR;
+}
+
+AlarmEntry_t *AlarmTask::allocEntry(MNET_MODULE_ID mid)
+{
+ int i = 0;
+
+ while ( _ap[i].code != EC_COMMON_NOERROR)
+ {
+ if ( i == ALARM_max_outstanding)
+ return NULL;
+ i++;
+ }
+
+
+ _ap[i].next = NULL;
+ if (mid >=0 && mid < MNET_MAX_MODULE_IDS)
+ {
+ if (_ms[mid] == NULL)
+ {
+ _ms[mid] = &_ap[i];
+ }
+ else
+ {
+ AlarmEntry_t * tmpentry = _ms[mid];
+
+ while ( tmpentry->next != NULL)
+ tmpentry = tmpentry->next;
+
+ tmpentry->next = &_ap[i];
+ }
+ return &_ap[i];
+ }
+ return NULL;
+}
+
+EnableDisableState_t AlarmTask::updateOperationalState()
+{
+ int i = 0;
+ EnableDisableState_t state = stateEnabled;
+
+ while ((state == stateEnabled) && (i < MNET_MAX_MODULE_IDS))
+ {
+ AlarmEntry_t * tmpentry = _ms[i];
+ while(tmpentry)
+ {
+ if (tmpentry->severity == Alarm_critical)
+ {
+ state = stateDisabled;
+ break;
+ }
+ tmpentry = tmpentry->next;
+ }
+ i++;
+ }
+ if ( (state == stateEnabled) && (i == MNET_MAX_MODULE_IDS))
+ {
+ // enable operational state
+ setOperationState(stateEnabled);
+
+ // set mib control state enable (in case this is first time)
+ if (_mibAccessState == false)
+ {
+ setMibAcessControlState(stateEnabled);
+ }
+
+ } else {
+ // disable operation state
+ setOperationState(stateDisabled);
+ }
+ return state;
+}
+
+
+void AlarmTask::updateModuleLastError(MNET_MODULE_ID mid, MibTag moduleErrorTag)
+{
+
+ AlarmEntry_t * curnode = _ms[mid];
+ AlarmCode_t errorcode = EC_COMMON_NOERROR;
+ alarm_fenter("AlarmTask::updateModuleLastError");
+
+ while(curnode)
+ {
+ errorcode = curnode->code;
+ curnode = curnode->next;
+ }
+
+ setModuleLastError(moduleErrorTag, errorcode);
+ alarm_fexit();
+}
+
+
+
+bool AlarmTask::addAlarmEntry(MNET_MODULE_ID mid, MibTag moduleErrorTag, AlarmCode_t errorCode, char *arg1, char *arg2)
+{
+ bool status = true;
+ Alarm_severity_t severity;
+ int id;
+ AlarmEntry_t *aentry;
+
+ alarm_fenter("addAlarmEntry");
+
+
+ aentry = findAlarmEntry(mid, errorCode);
+
+ if (aentry != NULL)
+ {
+ alarm_warning(("Alarm (code = 0x%06x) was raised %d times by %s, since UTC %s",
+ errorCode, ++aentry->count, GetMnetModuleName(mid), ctime(&aentry->utc)));
+ return true;
+ }
+
+ severity = getSeverity(errorCode);
+
+ if (severity < Alarm_max_severity)
+ {
+ _statistics[0][severity]++;
+ _statistics[1][severity]++;
+ }
+
+ switch (severity)
+ {
+ case Alarm_critical:
+ /* disable Network Elelemt Operational state if it is not already disabled */
+ setOperationState(stateDisabled);
+ case Alarm_major:
+ case Alarm_minor:
+ case Alarm_info:
+ aentry = allocEntry(mid);
+ id = generateNextId();
+
+ if (aentry )
+ {
+ aentry->count = 1;
+ aentry->code = errorCode;
+ aentry->id = id;
+ aentry->severity = severity;
+ aentry->utc = time(NULL);
+ } else {
+ alarm_error(("Too many alarm entries.\n"));
+ }
+
+ updateModuleLastError(mid, moduleErrorTag);
+ reportNewAlarm(id, mid, errorCode, severity, arg1, arg2);
+ break;
+
+ default:
+ alarm_error(("Illegle Severity code\n"));
+ break;
+ }
+ alarm_fexit();
+ return status;
+}
+
+
+AlarmEntry_t * AlarmTask::findAlarmEntry(MNET_MODULE_ID mid, AlarmCode_t errorCode)
+{
+ AlarmEntry_t * curnode = _ms[mid];
+
+ while (curnode )
+ {
+ if (curnode->code == errorCode)
+ return curnode;
+ curnode= curnode->next;
+ }
+ return NULL;
+}
+
+
+
+bool AlarmTask::delAlarmEntry(MNET_MODULE_ID mid, MibTag moduleErrorTag, AlarmCode_t errorCode)
+{
+ bool status = true;
+ char prevAlarm[20];
+ char prevId[20];
+ AlarmCode_t lastError = (AlarmCode_t) 0;
+ Alarm_severity_t severity;
+ int lastId = 0;
+
+ memset(prevAlarm, 0, 20);
+
+
+ if ((mid >=0) && (mid < MNET_MAX_MODULE_IDS))
+ {
+ AlarmEntry_t * curnode = _ms[mid];
+ AlarmEntry_t * prevnode = curnode;
+
+ if (errorCode == EC_COMMON_NOERROR)
+ {
+ // clear all the error for this module
+ _ms[mid] = NULL;
+ while (curnode )
+ {
+ prevnode = curnode;
+ curnode = curnode->next;
+
+ severity = getSeverity(prevnode->code);
+
+ if (severity < Alarm_max_severity)
+ {
+ _statistics[1][severity]--;
+ }
+ lastError = prevnode->code;
+ lastId = prevnode->id;
+ prevnode->code = EC_COMMON_NOERROR;
+ prevnode->next = NULL;
+ }
+ } else {
+
+ while (curnode && (curnode->code != errorCode))
+ {
+ prevnode = curnode;
+ curnode = curnode->next;
+ }
+
+ if (curnode)
+ {
+ if (curnode == prevnode)
+ {
+ // the first node
+ _ms[mid] = curnode->next;
+ } else {
+ prevnode->next = curnode->next;
+ }
+
+ severity = getSeverity(curnode->code);
+
+ if (severity < Alarm_max_severity)
+ {
+ _statistics[1][severity]--;
+ }
+ lastError = prevnode->code;
+ lastId = prevnode->id;
+ curnode->code = EC_COMMON_NOERROR;
+ curnode->next = NULL;
+ }
+ }
+ int id = generateNextId();
+ sprintf(prevAlarm,"%d", lastError);
+ sprintf(prevId, "%d", lastId);
+ reportNewAlarm(id, mid, EC_COMMON_NOERROR, Alarm_info, prevAlarm, prevId);
+ updateOperationalState();
+ updateModuleLastError(mid, moduleErrorTag);
+ } else {
+ status = false;
+ }
+ return status;
+}
+
+
+void AlarmTask::reportNewAlarm(int id, MNET_MODULE_ID mid, AlarmCode_t ecode, Alarm_severity_t severity,
+ char * arg1, char * arg2)
+{
+ extern bool alarm_sendAlarmEventToAms(ubyte4, ubyte4, ubyte4, ubyte4, char*, char*);
+
+ char strMsg[ALARM_maxMsgSize];
+ time_t ltime;
+ int posCount = 0;
+ alarm_fenter("AlarmTask::reportNewAlarm");
+
+
+ alarm_debug(("Formating alarm message to the GUI\n"));
+ memset((void *) strMsg,0,ALARM_maxMsgSize);
+ posCount += sprintf(strMsg + posCount, "%d|", id);
+
+ /* Get current local time */
+ time( &ltime );
+
+ posCount += sprintf(strMsg + posCount, "%ld|", ltime);
+ posCount += sprintf(strMsg + posCount, "%d|", severity);
+ posCount += sprintf(strMsg + posCount, "%d|", mid);
+ posCount += sprintf(strMsg + posCount, "%s|", GetMnetModuleName(mid));
+ posCount += sprintf(strMsg + posCount, "%d", ecode);
+
+ if (arg1 != NULL)
+ posCount += sprintf(strMsg + posCount, "|%s", arg1);
+ if(arg2 != NULL)
+ posCount += sprintf(strMsg + posCount, "|%s", arg2);
+
+ for (int i = posCount; i < ALARM_record_length-1; i++)
+ strMsg[i] = ' ';
+
+ strMsg[ALARM_record_length-1] = '\n';
+ strMsg[ALARM_record_length] = '\0';
+
+
+ // Broadcast message to all the Java Client Applets
+ alarm_broadcast(strMsg);
+
+ // we write to flash for all events
+ saveAlarm(strMsg);
+
+ // Send message to First AMS server
+ alarm_sendAlarmEventToAms(id, ecode, ltime, mid, arg1, arg2);
+
+ if (ecode == 0)
+ {
+ alarm_warning(("Alarm (Id = %d) in module \"%s\" has been cleared\n", id, GetMnetModuleName( mid)));
+ } else {
+ alarm_warning(("The module \"%s\" has raised an alarm (Id= %d, Code = %d)\n", GetMnetModuleName(mid), id, ecode));
+ }
+ alarm_fexit();
+
+}
+
+extern "C" void AlarmPrintStatus()
+{
+
+ AlarmTask::theAlarmTask->printStatus();
+
+}
+
+void AlarmTask::printStatus()
+{
+ int i;
+ AlarmEntry_t * tmpentry;
+
+ printf("\nNetwork Element Operational State: %d\n", getOperationState());
+ printf("Mib Access Status: %d\n", _mibAccessState);
+
+ printf("\nAlarm Statistics:\n");
+ printf("Total Alarms in this session:\n");
+ printf("\tCritical: %d\n", _statistics[0][Alarm_critical]);
+ printf("\tMajor: %d\n", _statistics[0][Alarm_major]);
+ printf("\tMinor: %d\n", _statistics[0][Alarm_minor]);
+ printf("\tInformational: %d\n", _statistics[0][Alarm_info]);
+
+ printf("Total Outstanding Alarms:\n");
+ printf("\tCritical: %d\n", _statistics[1][Alarm_critical]);
+ printf("\tMajor: %d\n", _statistics[1][Alarm_major]);
+ printf("\tMinor: %d\n", _statistics[1][Alarm_minor]);
+
+ if (_statistics[1][Alarm_critical]
+ + _statistics[1][Alarm_major]
+ + _statistics[1][Alarm_minor])
+ {
+ printf("%20s%20s\n", "MODULE NAME", "Outstanding Alarms");
+ printf("%20s%20s\n", "===========", "===================");
+ for(i=0; i< MNET_MAX_MODULE_IDS; i++)
+ {
+ if (_ms[i])
+ {
+ tmpentry = _ms[i];
+ printf("%20s ", GetMnetModuleName((MNET_MODULE_ID)i));
+ while(tmpentry)
+ {
+ printf(" %06x", tmpentry->code);
+ tmpentry = tmpentry->next;
+ }
+ printf("\n");
+ }
+ }
+ }
+}
+
+void AlarmTask::getOutstandingAlarmCount(ubyte1 &critical, ubyte1 &major, ubyte1 &minor)
+{
+ critical = _statistics[1][Alarm_critical];
+ major= _statistics[1][Alarm_major];
+ minor= _statistics[1][Alarm_minor];
+}
+
+#endif /* _ALARM_MODULE_CPP_ */
diff --git a/data/mnet/Common/Alarm/src/alarm_socket.cpp b/data/mnet/Common/Alarm/src/alarm_socket.cpp
new file mode 100644
index 0000000..12706c6
--- /dev/null
+++ b/data/mnet/Common/Alarm/src/alarm_socket.cpp
@@ -0,0 +1,445 @@
+/*********************************************************************/
+/* */
+/* (c) Copyright Cisco 2000 */
+/* All Rights Reserved */
+/* */
+/*********************************************************************/
+
+/*********************************************************************/
+/* */
+/* Version : 1.0 */
+/* Status : Under development */
+/* File : AlarmTask.h */
+/* Author(s) : Bhawani Sapkota */
+/* Create Date : 9/18/2000 */
+/* Description : This file contains alarm task socket handling */
+/* routines */
+/* */
+/*********************************************************************/
+/* REVISION HISTORY
+/*___________________________________________________________________*/
+/*----------+--------+-----------------------------------------------*/
+/* Name | Date | Reason */
+/*----------+--------+-----------------------------------------------*/
+/* Bhawani |07/14/00| Initial Draft */
+/* Bhawani |11/20/00| resturctured to share among GP, GMS and GS */
+/* Bhawani |03/10/01| Added alarm_raiseForGp10 Api */
+/*----------+--------+-----------------------------------------------*/
+/*********************************************************************/
+
+
+#ifndef _ALARM_SOCKET_CPP_
+#define _ALARM_SOCKET_CPP_
+
+#include "AlarmTask.h"
+
+#include "alarm_interface.h"
+#include <time.h>
+#include <selectLib.h>
+
+typedef int OS_SPECIFIC_SOCKET_HANDLE;
+
+/*-----------------------------------------------------------------------*/
+
+static OS_SPECIFIC_SOCKET_HANDLE SOCKET_UdpCreate()
+{
+ alarm_fenter("SOCKET_UdpCreate");
+
+ OS_SPECIFIC_SOCKET_HANDLE soc = socket(AF_INET, SOCK_DGRAM, 0);
+
+ if (ERROR == soc)
+ {
+ alarm_error(("Could not open datagram socket %s\n", strerror(errno)));
+ }
+
+ alarm_fexit();
+ return soc;
+}
+
+
+/*-----------------------------------------------------------------------*/
+
+static bool SOCKET_UdpBind(OS_SPECIFIC_SOCKET_HANDLE soc, ubyte2 port)
+{
+ struct sockaddr_in LocalAddr;
+ bool status = true;
+ alarm_fenter("SOCKET_UdpBind");
+
+
+
+ /* ask the system to allocate a port and bind to INADDR_ANY */
+ memset(&LocalAddr, 0x00, sizeof(LocalAddr));
+
+ /* get system to allocate a port number by binding a host address */
+ LocalAddr.sin_family = AF_INET;
+ LocalAddr.sin_addr.s_addr = htonl(INADDR_ANY);
+ LocalAddr.sin_port = htons(port);
+
+ /* bind socket to local address */
+ if (ERROR == bind(soc, (struct sockaddr *) &LocalAddr, sizeof(LocalAddr)))
+ {
+ alarm_error(("Could not bind datagram socket to port %d: %s\n", port, strerror(errno)));
+ status = false;
+
+ }
+
+ alarm_fexit();
+ return status;
+}
+
+/*-----------------------------------------------------------------------*/
+
+static bool SOCKET_SetRecvBuffer(OS_SPECIFIC_SOCKET_HANDLE soc, int nBytes)
+{
+ alarm_fenter("SOCKET_SetRecvBuffer");
+ bool status = true;
+
+ if (ERROR == setsockopt(soc, SOL_SOCKET, SO_RCVBUF, (char *) &nBytes, sizeof(int)))
+ {
+
+ alarm_error(("Could not set Receive buffer to %d\n", nBytes));
+ status = false;
+ }
+ alarm_fexit();
+ return status;
+}
+
+
+/*-----------------------------------------------------------------------*/
+
+void SOCKET_UdpClearRecvQ(OS_SPECIFIC_SOCKET_HANDLE sock)
+{
+ struct timeval timeout;
+ fd_set readFdSet;
+ static char buffer[512];
+ int bufferlen = 512;
+ struct sockaddr_in Addr;
+ int iAddrLen;
+
+
+ alarm_fenter("SOCKET_UdpClearInQueue");
+
+
+ timeout.tv_sec = 0;
+ timeout.tv_usec = 0;
+
+ FD_ZERO(&readFdSet);
+ FD_SET(sock, &readFdSet);
+
+
+ if(select(FD_SETSIZE, &readFdSet, NULL, NULL, &timeout) > 0)
+ {
+ /* Socket is ready for reading */
+
+ bufferlen = recvfrom(sock, buffer, bufferlen, 0, (struct sockaddr *)&Addr, &iAddrLen);
+ if (bufferlen > 0)
+ {
+ alarm_warning (("Cleared %d bytes of unexpected data from %s:%u\n",
+ bufferlen, inet_ntoa(Addr.sin_addr), Addr.sin_port));
+ }
+ }
+ alarm_fexit();
+}
+
+/*-----------------------------------------------------------------------*/
+
+extern bool
+SOCKET_UdpSendTo(OS_SPECIFIC_SOCKET_HANDLE sock,
+ struct sockaddr_in *pAddrTo,
+ char *message,
+ ubyte4 msglen)
+{
+ alarm_fenter("SOCKET_UdpSendTo");
+ bool status = true;
+ char pszIPbuf[20];
+
+
+ if (ERROR == sendto(sock, message, msglen, 0,
+ (struct sockaddr *) pAddrTo,
+ sizeof(struct sockaddr)) )
+ {
+ status = false;
+ }
+ inet_ntoa_b(pAddrTo->sin_addr, pszIPbuf);
+ alarm_debug(( "Sending %d bytes to Alarm server (ip=%s, port=%d) \n", msglen, pszIPbuf, ntohs(pAddrTo->sin_port)));
+ alarm_dump((ubyte1 *) message, msglen);
+
+ // clear any message in the incoming queue
+ SOCKET_UdpClearRecvQ(sock);
+
+ alarm_fexit();
+ return status;
+}
+
+/*-----------------------------------------------------------------------*/
+
+extern bool
+SOCKET_UdpReceive(OS_SPECIFIC_SOCKET_HANDLE sock,
+ char *msg,
+ ubyte4 *msgSize,
+ ubyte4 *peerAddr)
+{
+ struct sockaddr_in pAddr;
+ int iAddrLen;
+ int retval = recvfrom(sock, msg, *msgSize, 0, (struct sockaddr *)&pAddr, &iAddrLen );
+
+ if (retval == ERROR)
+ {
+ *msgSize = 0;
+ return false;
+ }
+
+ *msgSize = retval;
+ *peerAddr = pAddr.sin_addr.s_addr;
+ return true;
+}
+
+
+/*-----------------------------------------------------------------------*/
+
+extern bool SOCKET_Close(OS_SPECIFIC_SOCKET_HANDLE sock)
+{
+ bool retval = true;
+ alarm_fenter("SOCKET_Close");
+
+ if (ERROR == close(sock) )
+ {
+ alarm_error(("Could not close socket %s\n", strerror(errno)));
+ retval = false;
+ }
+
+ alarm_fexit();
+ return retval;
+}
+
+/*-----------------------------------------------------------------------*/
+
+ubyte4 GetHostAddress(char *pszHostName)
+{
+
+ return hostGetByName ( pszHostName );
+
+}
+
+/*-----------------------------------------------------------------------*/
+
+static ubyte4 GetLocalHostAddress()
+{
+#define MAX_PATH 80
+ char szHostName[MAX_PATH];
+ ubyte4 ulHostAddr = 0;
+
+ if (ERROR != gethostname(szHostName, MAX_PATH-1))
+ ulHostAddr = GetHostAddress ( szHostName );
+
+ return (ulHostAddr);
+}
+
+/*-----------------------------------------------------------------------*/
+
+static bool initialized = false;
+/*
+static AlarmViperCellToAmsMsg amsMsg;
+*/
+static struct sockaddr_in addrTo;
+static OS_SPECIFIC_SOCKET_HANDLE sock;
+
+bool
+initSocketAndMsgHdr()
+{
+ char pszIpBuf[20];
+ alarm_fenter("initSocketAndMsgHdr");
+
+ if (!initialized)
+ {
+ int ip;
+ /* 1. prepare udp socket */
+ sock = SOCKET_UdpCreate();
+
+ if (sock == ERROR)
+ {
+ alarm_fexit();
+ return false;
+ }
+
+ if (SOCKET_UdpBind(sock, ALARM_interfaceUdpPortClient) != true)
+ {
+ SOCKET_Close(sock);
+ alarm_fexit();
+ return false;
+
+ }
+
+ /* 2. get IP address from MIB */
+
+ if (oam_getMibIntVar(MY_MIB_APM1_IP_ADDRESS, (long *) &ip) != STATUS_OK)
+ {
+ // alarm_error(("Unable to get alarm server's IP from the MIB\n"));
+ SOCKET_Close(sock);
+ return false;
+ }
+
+ /* 3. prepare the the server's address */
+ memset (&addrTo, 0, sizeof(sockaddr_in));
+
+ addrTo.sin_family = AF_INET;
+ addrTo.sin_addr.s_addr = ip;
+ addrTo.sin_port = htons((ubyte2)ALARM_interfaceUdpPortServer);
+
+ inet_ntoa_b( addrTo.sin_addr, pszIpBuf);
+
+ /* Set small receive buffer */
+ SOCKET_SetRecvBuffer(sock, ALARM_defaultRecvBuffer);
+
+ alarm_debug (("APM1 server: ip = %s, port=%d\n", pszIpBuf, ALARM_interfaceUdpPortServer));
+ initialized = true;
+ }
+ alarm_fexit();
+ return true;
+}
+
+/*-----------------------------------------------------------------------*/
+
+bool
+alarm_sendAlarmEventToAms(ubyte4 id, ubyte4 code, ubyte4 timestamp, ubyte4 moduleId, char* opt1, char* opt2)
+{
+ AlarmViperCellToAmsMsg amsMsg;
+ ubyte4 opt;
+
+ alarm_fenter("alarm_sendAlarmMsgToAms");
+
+ if (!initSocketAndMsgHdr())
+ {
+ alarm_fexit();
+ return false;
+ }
+
+ memset(&amsMsg, 0, sizeof(AlarmViperCellToAmsMsg));
+
+ amsMsg.hdr.alarmSrcType = (ubyte1) MY_PRODUCT_ID;
+ amsMsg.hdr.alarmMsgType = ALARM_msgTypAlarmEvent;
+ amsMsg.hdr.alarmMsgLen = htons(sizeof(AlarmEventData));
+
+ strncpy(amsMsg.body.eventData.alarmSrcModuleName, GetMnetModuleName((MNET_MODULE_ID)moduleId),
+ ALARM_viperCellNameMaxSize);
+ amsMsg.body.eventData.alarmSrcIp = GetLocalHostAddress();
+
+ amsMsg.body.eventData.alarmId = htonl(id);
+ amsMsg.body.eventData.alarmCode = htonl(code);
+ amsMsg.body.eventData.alarmTimestamp = htonl(timestamp);
+ amsMsg.body.eventData.alarmSrcModuleId = htonl(moduleId);
+ if (NULL != opt1)
+ {
+ opt = atoi(opt1);
+ amsMsg.body.eventData.opt1 = htonl(opt);
+ }
+
+ if (NULL != opt1)
+ {
+ opt = atoi(opt2);
+ amsMsg.body.eventData.opt2 = htonl(opt);
+ }
+ SOCKET_UdpSendTo(sock, &addrTo, (char *) &amsMsg, ALARM_eventMsgLen);
+
+ alarm_fexit();
+ return true;
+
+}
+
+/*-----------------------------------------------------------------------*/
+#ifdef MNET_PRODUCT_SPECIFIC_GMC
+
+JC_STATUS alarm_raiseForGp10
+(
+ MNET_MODULE_ID mid, /* Gp10 source module ID */
+ AlarmCode_t alarm_code, /* Gp10 Alarm code */
+ unsigned long ip, /* GP10 IP address */
+ char *sourceName /* GP10's official name */
+ )
+{
+ AlarmViperCellToAmsMsg amsMsg;
+ const int MODULE_VBLINK = 0x11; /* ViperBase - ViperCell link client */
+ static char gp10SrcName[] = "VBLink"; /* GP10's Module name */
+
+ alarm_fenter("alarm_raiseForGp10");
+
+ if (!initSocketAndMsgHdr())
+ {
+ alarm_fexit();
+ return JC_ERROR;
+ }
+
+
+ memset(&amsMsg, 0, sizeof(AlarmViperCellToAmsMsg));
+
+ amsMsg.hdr.alarmSrcType = (ubyte1) MNET_PRODUCT_GP10;
+ amsMsg.hdr.alarmMsgType = ALARM_msgTypAlarmEvent;
+ amsMsg.hdr.alarmMsgLen = htons(sizeof(AlarmEventData));
+
+ strncpy(amsMsg.body.eventData.alarmSrcModuleName, gp10SrcName, ALARM_viperCellNameMaxSize);
+ amsMsg.body.eventData.alarmSrcIp = ip;
+
+ amsMsg.body.eventData.alarmId = htonl(ALARM_unknownAlarmId);
+ amsMsg.body.eventData.alarmCode = htonl(alarm_code);
+ amsMsg.body.eventData.alarmTimestamp = htonl(time(NULL));
+ amsMsg.body.eventData.alarmSrcModuleId = htonl(mid);
+ SOCKET_UdpSendTo(sock, &addrTo, (char *) &amsMsg, ALARM_eventMsgLen);
+
+ alarm_fexit();
+ return true;
+
+}
+
+#endif
+
+/*-----------------------------------------------------------------------*/
+
+bool AlarmTask::sendSummaryUpdateToAms()
+{
+ AlarmViperCellToAmsMsg amsMsg;
+
+ alarm_fenter("AlarmTask::sendSummaryUpdateToAms");
+ ubyte1 critical, major, minor;
+
+ if (!initSocketAndMsgHdr())
+ {
+ alarm_fexit();
+ return false;
+ }
+
+ /* 4. initialize the fixed fields */
+ memset(&amsMsg, 0, sizeof(AlarmViperCellToAmsMsg));
+
+ // populate the header
+ amsMsg.hdr.alarmSrcType = ALARM_srcTypViperCell;
+ amsMsg.hdr.alarmMsgType = ALARM_msgTypSummaryUpdate;
+ amsMsg.hdr.alarmMsgLen = htons(sizeof(AlarmSummaryUpdateData));
+
+ strncpy(amsMsg.body.summaryUpdateData.alarmSrcName, AlarmTask::srcName(),
+ ALARM_viperCellNameMaxSize);
+ amsMsg.body.summaryUpdateData.alarmSrcIp = GetLocalHostAddress();
+
+ getOutstandingAlarmCount(critical, major, minor);
+ amsMsg.body.summaryUpdateData.alarmCriticalCount = critical;
+ amsMsg.body.summaryUpdateData.alarmMajorCount = major;
+ amsMsg.body.summaryUpdateData.alarmMinorCount = minor;
+ SOCKET_UdpSendTo(sock, &addrTo, (char *) &amsMsg, ALARM_summaryUpdateMsgLen);
+
+ alarm_fexit();
+ return true;
+}
+
+
+void AlarmTask::quit ()
+{
+ _quit = true;
+}
+
+void AlarmTask::closeSocket ()
+{
+ initialized = false;
+ SOCKET_Close(sock);
+}
+
+
+#endif /* _ALARM_SOCKET_CPP_ */
diff --git a/data/mnet/Common/Alarm/src/alarm_sysCmd.cpp b/data/mnet/Common/Alarm/src/alarm_sysCmd.cpp
new file mode 100644
index 0000000..ba2ce56
--- /dev/null
+++ b/data/mnet/Common/Alarm/src/alarm_sysCmd.cpp
@@ -0,0 +1,173 @@
+/*********************************************************************/
+/* */
+/* (c) Copyright Cisco 2000 */
+/* All Rights Reserved */
+/* */
+/*********************************************************************/
+
+/*********************************************************************/
+/* */
+/* Version : 1.0 */
+/* Status : Under development */
+/* File : AlarmTask.h */
+/* Author(s) : Bhawani Sapkota */
+/* Create Date : 9/18/2000 */
+/* Description : This file contains alarm task syscommand handling */
+/* routines */
+/* */
+/*********************************************************************/
+/* REVISION HISTORY
+/*___________________________________________________________________*/
+/*----------+--------+-----------------------------------------------*/
+/* Name | Date | Reason */
+/*----------+--------+-----------------------------------------------*/
+/* Bhawani |07/14/00| Initial Draft */
+/* Bhawani |11/20/00| resturctured to share among GP, GMS and GS */
+/* Bhawani |03/09/01| Changed alarm log directory to match others */
+/*----------+--------+-----------------------------------------------*/
+/*********************************************************************/
+
+
+#ifndef __ALARM_SYSCMD_CPP__
+#define __ALARM_SYSCMD_CPP__
+
+#include "AlarmTask.h"
+
+/*
+*********************************************************************
+** Global variables
+********************************************************************
+*/
+
+/* Initialize the alarm task */
+
+AlarmTask::AlarmTask(char *name): JCTask(name)
+{
+ alarm_fenter("AlarmTask::AlarmTask");
+ if (isOneCreated == false)
+ {
+ int size, i,j;
+
+ // Initialize the message queue first
+ jcMsgQ = new JCMsgQueue(ALARM_q_maxMsgs, ALARM_q_maxMsgLength, MSG_Q_FIFO);
+
+#ifdef MNET_PRODUCT_SPECIFIC_GP10
+ // Initialize the timer
+ initTimer = new JCCTimer( (FUNCPTR ) &AlarmTask::bootupTimeoutHandler);
+ initTimer->setTimer(ALARM_mib_lock_timeout);
+#else
+ _mibAccessState = stateEnabled;
+#endif
+
+ // message receive buffer
+ _msgRecvBuff = new char[ALARM_q_maxMsgLength];
+
+ _mnetbase = getenv( "MNET_BASE" );
+
+ // compute the log file size
+ size = strlen(_mnetbase) + strlen(ALARM_logFile) + 1;
+ _logfilename = new char[size];
+ sprintf(_logfilename, "%s%s", _mnetbase, ALARM_logFile);
+
+ // initialize the module status table
+ for (i = 0; i < MNET_MAX_MODULE_IDS; i++)
+ _ms[i] = NULL;
+
+
+ // initialize the alarm pool
+ _ap = new AlarmEntry_t[ALARM_max_outstanding];
+ for (i =0; i <ALARM_max_outstanding; i++)
+ {
+ _ap[i].code = EC_COMMON_NOERROR;
+ _ap[i].next = NULL;
+ }
+
+ for (i=0; i <2; i++)
+ for (j=0; j< Alarm_max_severity; j++)
+ _statistics[i][j] = 0;
+
+ theAlarmTask = this;
+ populateSourceName();
+ isOneCreated = true;
+ }
+ alarm_fexit();
+}
+
+int AlarmTask::bootupTimeoutHandler()
+{
+ alarm_fenter("alarm_bootupTimeoutHandler");
+
+ /* The timer has expired and mib access needs to be enabled. */
+ theAlarmTask->setMibAcessControlState(stateEnabled);
+ alarm_warning(("The system did not complete reboot. Mib access has been re-enabled\n"));
+ alarm_fexit();
+ return 0;
+}
+
+
+int SysCommand_Alarm (T_SYS_CMD action)
+{
+ char *home;
+ JC_STATUS status = OK;
+
+ alarm_fenter("SysCommand_Alarm");
+ switch(action)
+ {
+ case SYS_SHUTDOWN:
+ break;
+
+ case SYS_REBOOT:
+ alarm_warning(("Reboot notification has been received\n"));
+ AlarmTask::theAlarmTask->alarmSend(InterModuleAlarmMsgTypeReboot, MY_MODULE_ID);
+ break;
+
+ case SYS_START:
+ alarm_debug(("Alarm initialization has been invoked\n"));
+
+ /* Get the value of the MNET_BASE environment variable. */
+ home = getenv( "MNET_BASE" );
+
+ if( home == NULL )
+ {
+ alarm_error(("Environment variable \"MNET_BASE\" must be defined!!\n"));
+ alarm_fexit();
+ return ERROR;
+ }
+ {
+ AlarmTask *mytask = new AlarmTask(ALARM_task_name);
+
+#ifdef MNET_PRODUCT_SPECIFIC_GP10
+ /* block the mib access */
+ mytask->setMibAcessControlState(stateDisabled);
+#endif
+
+ status = mytask->JCTaskSpawn(
+ ALARM_TASK_PRIORITY,
+ ALARM_TASK_OPTION,
+ ALARM_TASK_STACK_SIZE,
+ (FUNCPTR) AlarmTask::entryPoint,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ MY_MODULE_ID, JC_CRITICAL_TASK);
+
+ if(status == JC_ERROR)
+ {
+ alarm_error(("Alarm task spawn failure\n"));
+ status = ERROR;
+ }
+
+ }
+ break;
+
+ default:
+ alarm_warning(("Unknown SysCommand: %d\n", action));
+ status = ERROR;
+ break;
+ }
+ alarm_fexit();
+ return status;
+
+}
+
+#endif /* __ALARM_SYSCMD_CPP__ */
+
+
diff --git a/data/mnet/Common/Java/AlarmApplet/Alarm.java b/data/mnet/Common/Java/AlarmApplet/Alarm.java
new file mode 100644
index 0000000..cdf4b61
--- /dev/null
+++ b/data/mnet/Common/Java/AlarmApplet/Alarm.java
@@ -0,0 +1,102 @@
+
+
+import java.awt.*;
+import java.awt.event.*;
+import java.lang.String;
+import javax.swing.*;
+import javax.swing.event.*;
+import java.net.UnknownHostException;
+import com.jetcell.MibWM.*;
+import java.net.*;
+
+
+public class Alarm{
+ public AlarmPanel alarmPanel = null;
+ JFrame f = null;
+ AlarmTCPThread commObj = null;
+ FilterFrame filterFrame = null;
+ public final static int AM_APPLET_PORT2 = 11798;
+ JPanel jpanel = null;
+
+ // Shrinivas 23rd Apr 01
+ public Alarm(String viperbaseIp, final String vipercellIp){
+ // Shrinivas end
+ JButton setFilterButton = new JButton("Set Filter");
+ final Dimension d = new JFrame().getToolkit().getScreenSize();
+ if (f == null){
+ alarmPanel = new AlarmPanel(viperbaseIp);
+ jpanel = alarmPanel.createPanel();
+ alarmPanel.setViperCellIp(vipercellIp);//passing on viperCellIp to panel
+ JPanel southPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
+ southPanel.add(setFilterButton);
+
+ f = new JFrame("Alarm List for source: "+vipercellIp);
+ // Shrinivas 23rd Apr 01
+ f.addWindowListener(new WindowAdapter(){
+ public void windowClosing(WindowEvent evt){
+ AlarmStatusTable.removeAlarmSrcIp(vipercellIp);
+ destroy();
+ }
+ });
+ // Shrinivas end
+ if(Util.applet == null){
+ f.setIconImage(Toolkit.getDefaultToolkit().getImage("../Images/app_icon.gif"));
+ }
+ else{
+ String iconPath = Util.applet.getCodeBase().toString();
+ iconPath += "Images/app_icon.gif";
+ URL iconPathURL = null;
+ try{
+ iconPathURL = new URL(iconPath);
+ }
+ catch(MalformedURLException exc){
+ System.out.println("Bad URL.");
+ }
+ System.out.println(iconPathURL);
+ f.setIconImage(Toolkit.getDefaultToolkit().getImage(iconPathURL));
+ }
+
+ f.getContentPane().setLayout(new BorderLayout());
+ f.getContentPane().add(southPanel,BorderLayout.SOUTH);
+ f.getContentPane().add(jpanel,BorderLayout.CENTER);
+ f.setBounds(0,0, 720,400);
+ f.setLocation(d.width/5,d.height/5);
+ f.setVisible(true);
+ }
+ else
+ f.setVisible(true);
+
+ if (commObj == null)
+ commObj = new AlarmTCPThread(viperbaseIp, AM_APPLET_PORT2);
+ commObj.startReadThread(alarmPanel, vipercellIp, true);
+
+ setFilterButton.addActionListener(new ActionListener(){
+ public void actionPerformed(ActionEvent evt){
+ AlarmStatusApplet.logDM("Launch filter screen");
+ filterFrame = new FilterFrame(alarmPanel);
+ filterFrame.setLocation(d.width/4,d.width/5);
+ if(Util.applet == null){
+ filterFrame.setTitle("Filter for user : " + AlarmTCPThread.user.toUpperCase());
+ }
+ else{
+ filterFrame.setTitle("Filter Screen");
+ }
+ filterFrame.setResizable(false);
+ filterFrame.setVisible(true);
+ }
+ });
+
+ }
+
+ public void start(String vipercellIp){
+ f.setTitle("Alarm List for source: "+vipercellIp);
+ f.setVisible(true);
+ alarmPanel.setViperCellIp(vipercellIp);//passing on viperCellIp to panel
+ commObj.startReadThread(alarmPanel, vipercellIp, false);
+ }
+
+ public void destroy(){
+ System.out.println("Destroy method has been called");
+ commObj.finishReadThread();
+ }
+}
diff --git a/data/mnet/Common/Java/AlarmApplet/AlarmStatusApplet.java b/data/mnet/Common/Java/AlarmApplet/AlarmStatusApplet.java
new file mode 100644
index 0000000..cd3af38
--- /dev/null
+++ b/data/mnet/Common/Java/AlarmApplet/AlarmStatusApplet.java
@@ -0,0 +1,139 @@
+/*
+ * AlarmStatusApplet.java
+ * Kevin Lim
+ * 03/20/00
+ */
+
+import com.jetcell.MibWM.*;
+import java.applet.Applet;
+import java.awt.*;
+import java.awt.event.*;
+import java.util.Calendar;
+import java.lang.String;
+import javax.swing.*;
+import javax.swing.text.Document;
+import javax.swing.event.*;import java.net.*;
+import java.net.UnknownHostException;
+
+public class AlarmStatusApplet extends JApplet{
+
+ public static String ip = null;
+ public static int port = 11798; /*11800;*/
+ AlarmStatusPanel alarmPanel = null;
+ JFrame f = null;
+ static AlarmTCPThread commObj = null;
+
+ public static boolean isDebug = false;
+
+ public void init(){
+ Util.applet = this;
+ String newin = getParameter("NEWWINDOW");
+ ip = getParameter("HOST");
+ port = Integer.parseInt(getParameter("PORT"));
+
+ createUIPanel(newin);
+ }
+ // changes by Shrinivas : the code under this method were under the above init() method
+ // earlier. Function split was done so that the code could run both as an applet and an application
+ protected void createUIPanel(String newin){
+ alarmPanel = new AlarmStatusPanel();
+ if (f != null){
+ f.setVisible(true);
+ }
+ else {
+ if (newin != null){
+ System.out.println("NEWWINDOW VALUE = " +newin);
+ if(newin.equals("FALSE") || newin.equals("false")){
+ getContentPane().setLayout(new BorderLayout());
+ getContentPane().add(alarmPanel.createPanel(this),BorderLayout.CENTER);
+ }
+ else {
+ f = new JFrame("Alarm Status List for " + ip);
+ f.setIconImage(Toolkit.getDefaultToolkit().getImage("../Images/app_icon.gif"));
+ f.getContentPane().setLayout(new BorderLayout());
+ f.getContentPane().add(alarmPanel.createPanel(this));
+ f.setBounds(0,0, 720,400);
+ f.setVisible(true);
+ }
+ }
+ else {
+ System.out.println("Please set NEWWINDOW parameter to TRUE or FALSE");
+ System.out.println("Assuming - no new window");
+ getContentPane().setLayout(new BorderLayout());
+ getContentPane().add(alarmPanel.createPanel(this),BorderLayout.CENTER);
+ }
+ }
+
+ commObj = new AlarmTCPThread(ip, port);
+ commObj.startReadThread(alarmPanel);
+ }
+
+ public void start(){
+ System.out.println("Applet started");
+ }
+
+ public void stop(){
+ System.out.println("Applet stopped");
+ if (commObj != null){
+ commObj.finishReadThread();
+ commObj = null;
+ }
+ }
+
+ public void destroy(){
+ System.out.println("Destroy method has been called");
+ }
+
+ public void sendRemoveReq(AlarmStatusData data){
+ commObj.sendRemoveReq(data);
+ }
+
+ public void sendUpdateReq(){
+ commObj.sendUpdateReq();
+ }
+
+ public static void logDM(String message){
+ if(isDebug){
+ System.out.println(message);
+ }
+ }
+
+ public static void stopAPM1(){
+ if(commObj != null)
+ commObj.finishReadThread();
+ }
+
+ public static void startAPM1(String ipStr,boolean debug,String user){
+
+ isDebug = debug;
+ final JFrame frame = new JFrame();
+
+ try {
+ InetAddress.getByName(ipStr);
+ }
+ catch (UnknownHostException ex) {
+ JOptionPane.showMessageDialog(frame,"Invalid Host ID:","Error",JOptionPane.ERROR_MESSAGE);
+ return;
+ }
+ ip = ipStr;
+ final JApplet applet = new AlarmStatusApplet();
+ ((AlarmStatusApplet)applet).createUIPanel("false");
+ AlarmTCPThread.user = user;
+ frame.setContentPane(applet.getContentPane());
+ frame.setBounds(0,0, 720,400);
+ frame.setTitle("Alarm Status List for " + ip);
+ frame.setIconImage(Toolkit.getDefaultToolkit().getImage("../Images/app_icon.gif"));
+ Dimension d = new JFrame().getToolkit().getScreenSize();
+ frame.setLocation(d.width/10,d.height/10);
+ frame.setVisible(true);
+ frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
+
+ frame.addWindowListener(new WindowAdapter() {
+ public void windowClosed(WindowEvent e){
+ applet.stop();
+ }
+ });
+
+ }
+}
+
diff --git a/data/mnet/Common/Java/AlarmApplet/AlarmStatusData.java b/data/mnet/Common/Java/AlarmApplet/AlarmStatusData.java
new file mode 100644
index 0000000..f989f88
--- /dev/null
+++ b/data/mnet/Common/Java/AlarmApplet/AlarmStatusData.java
@@ -0,0 +1,139 @@
+/*
+ * AlarmStatusData.java
+ * Kevin Lim
+ * 03/20/00
+ */
+
+import java.util.StringTokenizer;
+
+public class AlarmStatusData
+{
+ final static byte ALARM_SRC_TYPE_VC = (byte)128;
+ final static byte ALARM_SRC_TYPE_VB = (byte)129;
+
+ String source_type;
+ String source_ip;
+ String source_name;
+ String critical;
+ String major;
+ String minor;
+
+ public AlarmStatusData( String source_type, String source_ip, String source_name,
+ String critical, String major, String minor)
+ {
+ this.source_type = source_type;
+ this.source_ip = source_ip;
+ this.source_name = source_name;
+ this.critical = critical;
+ this.major = major;
+ this.minor = minor;
+ }
+
+ public AlarmStatusData(byte[] msg){
+ int i = AlarmTCPThread.ALARM_HEAD_SRC_TYPE_POS;
+ extractSrcType (msg, i);
+ i = AlarmTCPThread.ALARM_MSG_HEADER_LEN;
+ extractSrcIP (msg, i);
+ i += AlarmTCPThread.ALARM_MSG_SRC_IP_SIZE;
+ extractSrcName (msg, i);
+ i += AlarmTCPThread.ALARM_MSG_SRC_NAME_SIZE;
+ extractCriCount(msg, i);
+ i += AlarmTCPThread.ALARM_MSG_CRITICAL_SIZE;
+ extractMajCount(msg, i);
+ i += AlarmTCPThread.ALARM_MSG_MAJOR_SIZE;
+ extractMinCount(msg, i);
+
+ }
+
+ public byte[] getSrcIPByte(){
+ byte[] ip = new byte[AlarmTCPThread.ALARM_MSG_SRC_IP_SIZE];
+
+ StringTokenizer st = new StringTokenizer(source_ip, ".");
+ if(st.countTokens() != 4){
+ System.out.println("Error on getSrcIPByte: ip token count");
+ return null;
+ }
+ else{
+ int i = 0;
+ while (st.hasMoreTokens()) {
+ ip[i++] = (byte) Integer.parseInt(st.nextToken());
+ }
+ }
+ return ip;
+ }
+
+ public byte getSrcTypeByte(){
+ byte type = (byte)0xFF;
+ if(source_type.equals("ViperCell"))
+ type = AlarmStatusData.ALARM_SRC_TYPE_VC;
+ else if(source_type.equals("ViperBase"))
+ type = AlarmStatusData.ALARM_SRC_TYPE_VB;
+ return type;
+ }
+
+ public int extractSrcType(byte[] msg, int i){
+ switch(msg[i]){
+ case AlarmStatusData.ALARM_SRC_TYPE_VC:
+ this.source_type = new String("ViperCell");
+ break;
+ case AlarmStatusData.ALARM_SRC_TYPE_VB:
+ this.source_type = new String("ViperBase");
+ break;
+ default:
+ this.source_type = new String("Unknown");
+ }
+ return (int)msg[i];
+ }
+
+ public void extractSrcIP(byte[] msg, int i) {
+ int h1 = (int)msg[i] & 0x00FF;
+ int h2 = (int)msg[i+1] & 0x00FF;
+ int h3 = (int)msg[i+2] & 0x00FF;
+ int h4 = (int)msg[i+3] & 0x00FF;
+ this.source_ip = "" + (new Integer(h1)).toString() +
+ "." + (new Integer(h2)).toString() +
+ "." + (new Integer(h3)).toString() +
+ "." + (new Integer(h4)).toString();
+ }
+
+ public void extractSrcName(byte[] msg, int i){
+ byte[] name = new byte[AlarmTCPThread.ALARM_MSG_SRC_NAME_SIZE];
+ for(int j=0; j<AlarmTCPThread.ALARM_MSG_SRC_NAME_SIZE; j++)
+ name[j] = msg[i+j];
+ this.source_name = (new String(name)).trim();
+ }
+
+ public void extractCriCount(byte[] msg, int i){
+ this.critical = (new Integer((int)msg[i] & 0x00FF)).toString();
+ }
+
+ public void extractMajCount(byte[] msg, int i){
+ this.major = (new Integer((int)msg[i] & 0x00FF)).toString();
+ }
+
+ public void extractMinCount(byte[] msg, int i){
+ this.minor = (new Integer((int)msg[i] & 0x00FF)).toString();
+ }
+
+ public void dump(){
+ System.out.println("*****************************");
+ System.out.println("Source Type : " + source_type);
+ System.out.println("Source IP : " + source_ip);
+ System.out.println("Source Name : " + source_name);
+ System.out.println("Critical Count: " + critical);
+ System.out.println("Major Count : " + major);
+ System.out.println("Minor Count : " + minor);
+ System.out.println("*****************************");
+ }
+
+ public static void main(String[] argv){
+ byte[] msg = { (byte)128, 1, 0, 48, 10, 1, 2, (byte)250,
+ (byte)'V', (byte)'i', (byte)'p', (byte)'e', (byte)'r', (byte)'1', 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3 };
+ AlarmStatusData data = new AlarmStatusData(msg);
+ data.dump();
+ }
+
+}
+
diff --git a/data/mnet/Common/Java/AlarmApplet/AlarmStatusPanel.java b/data/mnet/Common/Java/AlarmApplet/AlarmStatusPanel.java
new file mode 100644
index 0000000..c4c0efd
--- /dev/null
+++ b/data/mnet/Common/Java/AlarmApplet/AlarmStatusPanel.java
@@ -0,0 +1,53 @@
+/*
+ * AlarmStatusPanel.java
+ * Kevin Lim
+ * 03/20/00
+ */
+
+
+import javax.swing.*;
+import javax.swing.border.*;
+import javax.swing.table.*;
+import java.awt.event.*;
+import javax.swing.text.Document;
+import javax.swing.event.*;
+import java.net.UnknownHostException;
+import java.awt.*;
+import java.util.*;
+
+public class AlarmStatusPanel{
+ static String host = null;
+ AlarmStatusTable alarmStatusTable = null;
+ JLabel statLabel = null;
+
+ public AlarmStatusPanel(){
+ }
+
+ public JPanel createPanel(JApplet applet){
+ JPanel panel = new JPanel();
+ panel.setBorder(new EmptyBorder(5, 5, 5, 5));
+ panel.setLayout(new BorderLayout());
+ AlarmStatusTableModel model = new AlarmStatusTableModel();
+ alarmStatusTable = new AlarmStatusTable(model, applet);
+ JScrollPane scroller= new JScrollPane( alarmStatusTable,
+ JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED ,
+ JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
+ panel.add(scroller, BorderLayout.CENTER);
+ statLabel = new JLabel("Server Status");
+ panel.add(statLabel, BorderLayout.SOUTH);
+ return panel;
+ }
+
+ public void addEvent(AlarmStatusData alarm){
+ alarmStatusTable.setAlarmStatusData(alarm);
+ }
+
+ public void dispStatus(String status){
+ statLabel.setText(status);
+ }
+
+ public void clearEvents() {
+ alarmStatusTable.RemoveAll();
+ }
+}
+
diff --git a/data/mnet/Common/Java/AlarmApplet/AlarmStatusTable.java b/data/mnet/Common/Java/AlarmApplet/AlarmStatusTable.java
new file mode 100644
index 0000000..ec23f91
--- /dev/null
+++ b/data/mnet/Common/Java/AlarmApplet/AlarmStatusTable.java
@@ -0,0 +1,221 @@
+/*
+ * AlarmStatusTable
+ * Kevin Lim
+ * 03/20/00
+ */
+
+
+
+import java.awt.event.*;
+import javax.swing.*;
+import javax.swing.JTable;
+import javax.swing.table.*;
+import javax.swing.event.*;
+import java.util.Hashtable;
+import java.awt.*;
+import java.io.*;
+import java.net.*;
+import java.applet.*;
+import com.jetcell.MibWM.Util;
+// Shrinivas 23rd Apr 01
+import java.util.*;
+// Shrinivas end
+public class AlarmStatusTable extends JTable {
+
+ DefaultTableModel model;
+ JPopupMenu popupMenu = null;
+ JApplet applet = null;
+ // Shrinivas 23rd Apr 01
+ //Alarm alarm = null;
+ static Vector alarmSrcIpList = null;
+ // Shrinivas end
+ final int [] columnMinWidth = { 30, 60, 30, 30, 30, 0};
+ final int [] columnMaxWidth = {200, 150, 150, 150, 150, 0};
+ Hashtable alarmHashTable = null;
+
+ public AlarmStatusTable(DefaultTableModel model, JApplet applet){
+ super(model);
+ // Shrinivas 23rd Apr 01
+ alarmSrcIpList = new Vector(8,3);
+ // Shrinivas end
+ popupMenu = AlarmStatusTablePopupMenu.getPopupMenu();
+ this.applet = applet;
+
+ addMouseListener(new MouseHandler(this));
+ alarmHashTable = new Hashtable();
+ for (int i=0; i < model.getColumnCount(); i++ )
+ setColumnWidth(i, columnMinWidth[i], columnMaxWidth[i]);
+ TableColumnModel colModel = getColumnModel();
+ colModel.getColumn(AlarmStatusTableModel.CRITICAL).setCellRenderer(new CountCellRenderer());
+ colModel.getColumn(AlarmStatusTableModel.MAJOR).setCellRenderer(new CountCellRenderer());
+ colModel.getColumn(AlarmStatusTableModel.MINOR).setCellRenderer(new CountCellRenderer());
+
+ setRowSelectionAllowed(true);
+ setColumnSelectionAllowed(false);
+ setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
+ setShowGrid(true);
+ setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
+ getTableHeader().setReorderingAllowed(false);
+ }
+
+ public void setColumnWidth(int columnIndex, int minWidth, int maxWidth){
+ TableColumn column = (TableColumn)getColumn(getColumnName(columnIndex));
+ column.setMinWidth(minWidth);
+ column.setMaxWidth(maxWidth);
+ }
+
+ public boolean isCellEditable(int i, int j){
+ return false;
+ }
+
+ public AlarmStatusData getAlarmStatusData(String source_ip){
+ if (alarmHashTable != null)
+ return (AlarmStatusData) alarmHashTable.get(source_ip);
+ return null;
+ }
+
+ public int rowAlarmStatusData(String source_ip){
+ int row_count = ((DefaultTableModel)getModel()).getRowCount();
+ for(int i=0; i<row_count; i++){
+ String ip = (String)getValueAt(i, AlarmStatusTableModel.SRC_IP);
+ if(ip.equals(source_ip))
+ return i;
+ }
+ return -1;
+ }
+
+ public void setAlarmStatusData(AlarmStatusData alarm){
+ int row_index;
+ if (getAlarmStatusData(alarm.source_ip) != null){
+ alarmHashTable.remove(alarm.source_ip);
+ alarmHashTable.put(alarm.source_ip, alarm);
+ row_index = rowAlarmStatusData(alarm.source_ip);
+ setValueAt(alarm.source_ip, row_index, AlarmStatusTableModel.SRC_IP);
+ setValueAt(alarm.source_name, row_index, AlarmStatusTableModel.SRC_NAME);
+ setValueAt(alarm.critical, row_index, AlarmStatusTableModel.CRITICAL);
+ setValueAt(alarm.major, row_index, AlarmStatusTableModel.MAJOR);
+ setValueAt(alarm.minor, row_index, AlarmStatusTableModel.MINOR);
+ }
+ else{
+ alarmHashTable.put(alarm.source_ip, alarm);
+ row_index = ((DefaultTableModel)getModel()).getRowCount();
+ Object [] row = new Object[AlarmStatusTableModel.NUM_COL];
+ row[AlarmStatusTableModel.SRC_IP] = alarm.source_ip;
+ row[AlarmStatusTableModel.SRC_NAME] = alarm.source_name;
+ row[AlarmStatusTableModel.CRITICAL] = alarm.critical;
+ row[AlarmStatusTableModel.MAJOR] = alarm.major;
+ row[AlarmStatusTableModel.MINOR] = alarm.minor;
+ ((DefaultTableModel)getModel()).insertRow(row_index, row);
+ }
+ }
+
+ // Shrinivas 23rd Apr 01
+ public static void removeAlarmSrcIp(String ip){
+ alarmSrcIpList.remove(ip);
+ }
+ // Shrinivas end
+ public void OpenEvent(){
+ int selectedRow = getSelectedRow();
+ if(selectedRow == -1){
+ System.out.println("Open Event: no selection made");
+ return;
+ }
+ String ip = (String)getValueAt(selectedRow, AlarmStatusTableModel.SRC_IP);
+ //System.out.println("Open Event: " +ip);
+ // Shrinivas 23rd Apr 01
+ if(alarmSrcIpList.contains(ip)){
+ return;
+ }
+ else{
+ alarmSrcIpList.add(ip);
+ }
+ Alarm alarmList = new Alarm(AlarmStatusApplet.ip, ip);
+ /*if (alarm == null){
+ alarm = new Alarm(AlarmStatusApplet.ip, ip);
+ }
+ else
+ alarm.start(ip); */
+ // Shrinivas end
+ } // end OpenEvent()
+
+ public void Remove(){
+ int selectedRow = getSelectedRow();
+ if(selectedRow == -1){
+ System.out.println("Remove Event: no selection made");
+ return;
+ }
+ String ip = (String)getValueAt(selectedRow, AlarmStatusTableModel.SRC_IP);
+ System.out.println("Remove Event: " +ip);
+ AlarmStatusData data = getAlarmStatusData(ip);
+ if(data == null){
+ System.out.println("Remove Event: data not found");
+ }
+ else{
+ alarmHashTable.remove(ip);
+ int row_index = rowAlarmStatusData(ip);
+ ((DefaultTableModel)getModel()).removeRow(row_index);
+ }
+ ((AlarmStatusApplet)applet).sendRemoveReq(data);
+ }
+
+ public void RemoveAll(){
+ int row_count = ((DefaultTableModel)getModel()).getRowCount();
+ while(row_count != 0){
+ String ip = (String)getValueAt(0, AlarmStatusTableModel.SRC_IP);
+ alarmHashTable.remove(ip);
+ ((DefaultTableModel)getModel()).removeRow(0);
+ row_count = ((DefaultTableModel)getModel()).getRowCount();
+ }
+ }
+
+ public void Refresh(){
+ ((AlarmStatusApplet)applet).sendUpdateReq();
+ }
+
+
+ class MouseHandler extends MouseAdapter{
+ public AlarmStatusTable table;
+
+ public MouseHandler(AlarmStatusTable table){
+ this.table = table;
+ }
+
+ public void mouseReleased(MouseEvent e){
+ if (e.getClickCount() == 2 ){
+ OpenEvent();
+ }
+
+ if ( e.isPopupTrigger()){
+ // changes by Shrinivas on 17th Oct 2k
+ System.out.println("Event : Popup menu");
+ int selectedRow = rowAtPoint(new Point(e.getX(),e.getY()));
+ setRowSelectionInterval(selectedRow,selectedRow);
+ // end of changes
+ popupMenu.show(table, e.getX(), e.getY());
+ }
+ }
+ }
+
+ class CountCellRenderer extends JLabel implements TableCellRenderer{
+ Font defaultFont = new Font("Helvetica", Font.BOLD,12);
+ Font empFont = new Font("TimesRoman", Font.BOLD,18);
+
+ public CountCellRenderer(){
+ super("Unknown");
+ setHorizontalAlignment(JLabel.CENTER);
+ }
+
+ public Component getTableCellRendererComponent( JTable table,
+ Object value,
+ boolean isSelected,
+ boolean hasFocus,
+ int row,
+ int column ){
+ setText((String)value);
+
+ return this;
+ }
+ }
+
+}
+
diff --git a/data/mnet/Common/Java/AlarmApplet/AlarmStatusTableModel.java b/data/mnet/Common/Java/AlarmApplet/AlarmStatusTableModel.java
new file mode 100644
index 0000000..85aa726
--- /dev/null
+++ b/data/mnet/Common/Java/AlarmApplet/AlarmStatusTableModel.java
@@ -0,0 +1,34 @@
+/*
+ * AlarmStatusTableModel.java
+ * Kevin Lim
+ * 03/20/00
+ */
+
+
+
+import javax.swing.*;
+import javax.swing.table.*;
+import java.awt.event.*;
+import java.awt.*;
+import java.util.*;
+
+public class AlarmStatusTableModel extends DefaultTableModel
+
+
+{
+ final static int SRC_IP = 0;
+ final static int SRC_NAME = 1;
+ final static int CRITICAL = 2;
+ final static int MAJOR = 3;
+ final static int MINOR = 4;
+
+ static String ColumnTitle[] = {"Source IP", "Source Name", "Critical Alarm", "Major Alarm", "Minor Alarm"};
+ final static int NUM_COL = ColumnTitle.length;
+
+ public AlarmStatusTableModel()
+ {
+ super(ColumnTitle, 0);
+ }
+}
+
+
diff --git a/data/mnet/Common/Java/AlarmApplet/AlarmStatusTablePopupMenu.java b/data/mnet/Common/Java/AlarmApplet/AlarmStatusTablePopupMenu.java
new file mode 100644
index 0000000..e91f3f4
--- /dev/null
+++ b/data/mnet/Common/Java/AlarmApplet/AlarmStatusTablePopupMenu.java
@@ -0,0 +1,126 @@
+/*
+ * AlarmStatusTablePopupMenu.java
+ * Kevin Lim
+ * 03/20/00
+ */
+
+
+
+import java.util.*;
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+import javax.swing.text.*;
+
+public class AlarmStatusTablePopupMenu extends JPopupMenu implements ActionListener{
+ static JMenuItem openMenuItem;
+ static JMenuItem removeMenuItem;
+ static JMenuItem refreshMenuItem;
+ static boolean iconsLoaded = false;
+ protected static AlarmStatusTablePopupMenu popupMenu = new AlarmStatusTablePopupMenu();
+ static AlarmStatusTable invoker ;
+ static int x;
+ static int y;
+
+
+ /**
+ * You cannot instantiate this class. Use getPopupMenu() to get
+ * a shared instance!
+ */
+ protected AlarmStatusTablePopupMenu(){
+
+ openMenuItem = new JMenuItem(new String("Open Alarm"));
+ openMenuItem.setMnemonic('O');
+ openMenuItem.registerKeyboardAction(null, KeyStroke.getKeyStroke('O', Event.ALT_MASK, false),
+ JComponent.WHEN_IN_FOCUSED_WINDOW);
+ openMenuItem.setHorizontalTextPosition(SwingConstants.RIGHT);
+ openMenuItem.setHorizontalAlignment(SwingConstants.LEFT);
+ openMenuItem.addActionListener(this);
+ add(openMenuItem);
+
+ removeMenuItem = new JMenuItem(new String("Remove"));
+ removeMenuItem.setMnemonic('m');
+ removeMenuItem.registerKeyboardAction(null, KeyStroke.getKeyStroke('m', Event.ALT_MASK, false),
+ JComponent.WHEN_IN_FOCUSED_WINDOW);
+ removeMenuItem.setHorizontalTextPosition(SwingConstants.RIGHT);
+ removeMenuItem.setHorizontalAlignment(SwingConstants.LEFT);
+ removeMenuItem.addActionListener(this);
+ add(removeMenuItem);
+
+ // Shrinivas 20th Apr 01
+ /*refreshMenuItem = new JMenuItem(new String("Refresh"));
+ refreshMenuItem.setMnemonic('R');
+ refreshMenuItem.registerKeyboardAction(null, KeyStroke.getKeyStroke('R', Event.ALT_MASK, false),
+ JComponent.WHEN_IN_FOCUSED_WINDOW);
+ refreshMenuItem.setHorizontalTextPosition(SwingConstants.RIGHT);
+ refreshMenuItem.setHorizontalAlignment(SwingConstants.LEFT);
+ refreshMenuItem.addActionListener(this);
+ add(refreshMenuItem);*/
+ // Shrinivas end
+ }
+
+
+ /**
+ * returns shared instance of popupMenu
+ */
+ public static AlarmStatusTablePopupMenu getPopupMenu(){
+ return popupMenu;
+ }
+
+
+ /**
+ * update to use difference icons later!
+ */
+ void loadIcons(){
+ }
+
+
+ /**
+ * update to use shared clipboard access later
+ */
+ public void actionPerformed(ActionEvent e){
+ Object obj = e.getSource();
+ String selection = null;
+
+ if (obj == openMenuItem) {
+ invoker.OpenEvent();
+ }
+ else if (obj == removeMenuItem) {
+ invoker.Remove();
+ }
+ else if (obj == refreshMenuItem) {
+ invoker.Refresh();
+ }
+ }
+
+
+ /**
+ * force JTable only later
+ */
+ public void show(Component c, int x, int y){
+ invoker = (AlarmStatusTable)c;
+
+ Point p = new Point(x,y);
+ int row = invoker.rowAtPoint(p);
+ int col = invoker.columnAtPoint(p);
+
+ this.x = x;
+ this.y = y;
+ super.show(c,x,y);
+ }
+
+
+ void disableMenu() {
+ openMenuItem.setEnabled(false);
+ removeMenuItem.setEnabled(false);
+ refreshMenuItem.setEnabled(false);
+ }
+
+
+ void enableMenu(){
+ openMenuItem.setEnabled(true);
+ removeMenuItem.setEnabled(true);
+ refreshMenuItem.setEnabled(true);
+ }
+}
+
diff --git a/data/mnet/Common/Java/AlarmApplet/AlarmTCPThread.java b/data/mnet/Common/Java/AlarmApplet/AlarmTCPThread.java
new file mode 100644
index 0000000..3a4ed0d
--- /dev/null
+++ b/data/mnet/Common/Java/AlarmApplet/AlarmTCPThread.java
@@ -0,0 +1,469 @@
+
+/*
+ * AlarmTCPThread.java
+ * Kevin Lim
+ * 03/21/00
+ */
+
+
+
+import java.net.*;
+import java.io.*;
+import javax.swing.*;
+import javax.swing.*;
+import javax.swing.text.Document;
+import javax.swing.event.*;
+import com.jetcell.MibWM.*;
+
+public class AlarmTCPThread extends Thread{
+
+ static private boolean FILTER = false;
+ private String filterVipercellIp = null;
+
+ static final int MAX_IN_BUF_SIZE = 4096;
+ static final int MAX_MSG_BUF_SIZE = 1024;
+ static final int ALARM_HEAD_SRC_TYPE_POS = 0;
+ static final int ALARM_HEAD_MSG_TYPE_POS = 1;
+ static final int ALARM_HEAD_MSG_SIZE_POS = 2;
+ static final int ALARM_MSG_HEADER_LEN = 4;
+ static final int ALARM_MSG_SRC_IP_SIZE = 4;
+ static final int ALARM_MSG_SRC_NAME_SIZE = 41;
+ static final int ALARM_MSG_CRITICAL_SIZE = 1;
+ static final int ALARM_MSG_MAJOR_SIZE = 1;
+ static final int ALARM_MSG_MINOR_SIZE = 1;
+
+ static final byte ALARM_MSG_TYPE_UPDATE_REQ = 1;
+ static final byte ALARM_MSG_TYPE_UPDATE_RSP = 2;
+ static final byte ALARM_MSG_TYPE_REMOVE_REQ = 3;
+ static final byte ALARM_MSG_TYPE_EVENT_REQ = 4;
+ static final byte ALARM_MSG_TYPE_EVENT_RSP = 5;
+ static final byte ALARM_MSG_TYPE_ACK = 6;
+
+ static final byte ALARM_MSG_SRC_TYPE_APPLET = (byte)0xFF;
+
+static final int MAX_MODULE_SPECIC_ALARM = 0xFFFF;
+ static final int ALARM_CRITICAL_START_POINT = 0x0001;
+ static final int ALARM_MAJOR_START_POINT = 0x0100;
+ static final int ALARM_MINOR_START_POINT = 0x0800;
+ static final int ALARM_INFO_START_POINT = 0x1000;
+ static final int ALARM_CRITICAL = 0;
+ static final int ALARM_MAJOR = 1;
+ static final int ALARM_MINOR = 2;
+ static final int ALARM_INFO = 3;
+ public static String user = null;
+
+ Socket socket;
+ String host;
+ int port;
+ int appletVipercellIp = 0;
+ int msgVipercellIp = 0;
+ AlarmStatusPanel panel = null;
+ AlarmPanel alarmPanel = null;
+ AlarmData alarmData = null;
+ BufferedInputStream in = null;
+ InputStreamReader isr = null;
+ public static BufferedOutputStream out = null;
+ boolean running;
+
+ public AlarmTCPThread(String host, int port) {
+ this.host = host;
+ this.port = port;
+ System.out.println("Connecting to the Server " + host + " at port " + port);
+ try {
+ socket = new Socket(host, port);
+ } catch(IOException e) {
+ System.out.println("Could not connect to the Server");
+ socket = null;
+ }
+ if(socket != null){
+ try {
+ in = new BufferedInputStream(socket.getInputStream()); // reading is done to byte arrays
+ out = new BufferedOutputStream(socket.getOutputStream()); // writing is done from byte arrays
+ out.flush();
+ } catch(IOException e) {
+ System.out.println("IO exception in AlarmTCPThread: ");
+ close_socket();
+ }
+ }
+ }
+
+ public void sendRemoveReq(AlarmStatusData data)
+ {
+ if(out == null) return;
+ try {
+ byte[] msg = {ALARM_MSG_SRC_TYPE_APPLET,
+ ALARM_MSG_TYPE_REMOVE_REQ,
+ 0, 5, 0, 0, 0, 0, 0};
+ int i = AlarmTCPThread.ALARM_MSG_HEADER_LEN;
+ byte[] ip_addr = data.getSrcIPByte();
+ if(ip_addr == null){
+ System.out.println("Error on sendRemoveReq: getSrcIPByte failed");
+ return;
+ }
+ for(int j=0; j<AlarmTCPThread.ALARM_MSG_SRC_IP_SIZE; j++){
+ msg[i++] = ip_addr[j];
+ System.out.println("ip_addr "+ip_addr[j]);
+ }
+ byte type = data.getSrcTypeByte();
+ if(type == (byte)0xFF){
+ System.out.println("Error on sendRemoveReq: getSrcTypeByte returned unknown");
+ return;
+ }
+ msg[i++] = type;
+ out.write(msg, 0, i);
+ out.flush();
+ } catch(IOException ioe) {
+ System.out.println("IO exception in AlarmTCPThread:send "+ioe);
+ }
+ }
+
+ public void sendUpdateReq(){
+ if(out == null) return;
+ try {
+ byte[] msg = {ALARM_MSG_SRC_TYPE_APPLET,
+ ALARM_MSG_TYPE_UPDATE_REQ,
+ 0, 0};
+ out.write(msg, 0, ALARM_MSG_HEADER_LEN);
+ out.flush();
+ } catch(IOException ioe) {
+ System.out.println("IO exception in AlarmTCPThread:send "+ioe);
+ }
+ }
+
+ // send alarm event msg update request to AlarmServer
+ static public void sendEventReq(String vipercellIp){
+ int index = 0;
+ String tmpStr = vipercellIp;
+ String valueStr;
+ Short [] ip = new Short[4];
+ if (out == null)
+ return;
+
+ // converting IP string into 4 octets
+ for (int i = 0; i < 4; i++){
+ index = tmpStr.indexOf(".");
+ valueStr = i == 3 ? tmpStr : tmpStr.substring(0, index);
+ ip[i] = new Short(valueStr);
+ tmpStr = tmpStr.substring(index + 1);
+ }
+
+ try {
+ byte[] msg = {ALARM_MSG_SRC_TYPE_APPLET,
+ ALARM_MSG_TYPE_EVENT_REQ,
+ 0x00, 0x04, // length of data
+ ip[0].byteValue(), ip[1].byteValue(), ip[2].byteValue(),
+ ip[3].byteValue()};
+ out.write(msg, 0, ALARM_MSG_HEADER_LEN + 4);
+ out.flush();
+ }
+ catch(IOException ioe) {
+ System.out.println("IO exception in AlarmTCPThread:send "+ioe);
+ }
+ FILTER = false;
+ }
+
+ public static void sendAck(String srcIp,String alarmId,String recordNum){
+ int index = 0;
+ String tmpStr = srcIp;
+ String valueStr;
+ Short [] ip = new Short[4];
+
+ byte aid[] = new byte[4];
+ byte rec[] = new byte[4];
+
+
+ // converting IP string into 4 octets
+ for (int i = 0; i < 4; i++){
+ index = tmpStr.indexOf(".");
+ valueStr = i == 3 ? tmpStr : tmpStr.substring(0, index);
+ ip[i] = new Short(valueStr);
+ tmpStr = tmpStr.substring(index + 1);
+ }
+
+ // converting alarmID to bytes
+ aid = AlarmTCPThread.extractBytes(alarmId);
+ rec = AlarmTCPThread.extractBytes(recordNum);
+
+ try {
+ byte[] msg = {ALARM_MSG_SRC_TYPE_APPLET,
+ ALARM_MSG_TYPE_ACK,
+ 0x00, 0x0c, // length of data
+ ip[0].byteValue(), ip[1].byteValue(), ip[2].byteValue(),
+ ip[3].byteValue(),
+ aid[3],aid[2],aid[1],aid[0],
+ rec[3],rec[2],rec[1],rec[0]};
+ out.write(msg, 0, msg.length);
+ out.flush();
+ }
+ catch(IOException ioe) {
+ AlarmStatusApplet.logDM("IO exception in AlarmTCPThread: ack "+ioe);
+ }
+ }
+
+ public static byte[] extractBytes(String s){
+
+ byte store[] = new byte[4];
+ int intValue = Integer.parseInt(s);
+
+ store[0] = (byte)(intValue & 0x000000ff);
+ store[1] = (byte)((intValue >> 8) & 0x000000ff);
+ store[2] = (byte)((intValue >> 16) & 0x000000ff);
+ store[3] = (byte)((intValue >> 24) & 0x000000ff);
+
+ return store;
+ }
+
+ public void alarmMsgHandler(byte[] msg) {
+ int index = AlarmTCPThread.ALARM_HEAD_MSG_TYPE_POS;
+ switch(msg[index]){
+ case ALARM_MSG_TYPE_UPDATE_RSP:
+ if (panel != null)
+ {
+ AlarmStatusData alarm = new AlarmStatusData(msg);
+ panel.addEvent(alarm);
+ }
+ break;
+ case ALARM_MSG_TYPE_EVENT_RSP:
+ if (alarmPanel != null)
+ {
+ try {
+ alarmData = new AlarmData(parseEventData(msg));
+ }
+ catch(Exception e) {}
+ if (appletVipercellIp == msgVipercellIp){
+ alarmPanel.addEvent(alarmData);
+ }
+ }
+ break;
+ default:
+ System.out.println("Unknown message received "+(int)msg[index]);
+ int size = 0x00FF & (int)msg[AlarmTCPThread.ALARM_HEAD_MSG_SIZE_POS];
+ size = (size << 8) | (0x00FF & (int)msg[AlarmTCPThread.ALARM_HEAD_MSG_SIZE_POS+1]);
+ size += AlarmTCPThread.ALARM_MSG_HEADER_LEN;
+ if(size > AlarmTCPThread.MAX_MSG_BUF_SIZE) size = AlarmTCPThread.MAX_MSG_BUF_SIZE;
+ for(int i=0; i<size; i++) System.out.print(" " + (int)(msg[i] & 0x00FF));
+ System.out.println(" ");
+ }
+ }
+
+ public void close_socket() {
+ if(socket != null){
+ try {
+ socket.close();
+ System.out.println("closing socket at third window level...");
+ }
+ catch(IOException e) {
+ System.out.println("Couldn't close socket " + e);
+ }
+ }
+ }
+
+ public void reconnect() {
+ boolean done = false;
+ while(!done){
+ try {
+ if (panel != null)
+ panel.dispStatus("Attempting to reconnect to the Server...");
+ socket = new Socket(host, port);
+ done = true;
+ if (panel != null)
+ panel.dispStatus("Server on-line");
+ }
+ catch(IOException e) {
+ if (panel != null)
+ panel.dispStatus("Server off-line");
+ }
+ try {
+ sleep(1000);
+ }
+ catch (InterruptedException ie) {
+ System.out.println(" Interrupted Excution = " + ie);
+ }
+ }
+ if(socket != null){
+ try {
+ in = new BufferedInputStream(socket.getInputStream()); // reading is done to byte arrays
+ out = new BufferedOutputStream(socket.getOutputStream()); // writing is done from byte arrays
+ out.flush();
+ if (panel != null) {
+ panel.clearEvents();
+ sendUpdateReq();
+ }
+ }
+ catch(IOException e) {
+ System.out.println("IO exception in AlarmTCPThread: ");
+ close_socket();
+ }
+ }
+ }
+
+ public void run() {
+ // Shrinivas 01 June 01
+ if(socket == null && running ) reconnect();
+ byte[] buf = new byte[AlarmTCPThread.MAX_IN_BUF_SIZE];
+ byte[] msg = new byte[AlarmTCPThread.MAX_MSG_BUF_SIZE];
+ running = true;
+ int readBytes;
+ int index;
+ int msg_size;
+ int header_size = AlarmTCPThread.ALARM_MSG_HEADER_LEN;
+ while(running){
+ try {
+ readBytes = in.read(buf, 0, AlarmTCPThread.MAX_IN_BUF_SIZE);
+ if(readBytes == -1){
+ System.out.println("End of stream reached!");
+ close_socket();
+ // Shrinivas 01 June 01'
+ if(running){
+ reconnect();
+ }
+ // Shrinivas end
+ }
+ index = 0;
+ while ((index + header_size) <= readBytes){ // while there are msg at least size of header
+ msg_size = 0x00FF & (int)buf[index+AlarmTCPThread.ALARM_HEAD_MSG_SIZE_POS];
+ msg_size = (msg_size << 8)
+ | (0x00FF & (int)buf[index+AlarmTCPThread.ALARM_HEAD_MSG_SIZE_POS+1]);
+ if((header_size + msg_size) <= (readBytes - index)){ // about to copy msg within valid range
+ for(int i=0; i<(header_size + msg_size); i++){
+ msg[i] = buf[index++];
+ }
+ AlarmStatusApplet.logDM("Received msg with length: " + msg_size);
+ alarmMsgHandler(msg);
+ }
+ else{
+ System.out.println("Length Err. Msg Length specified : "+msg_size);
+ System.out.println("Length Err. Bytes left in read buf: "+(readBytes - index));
+ index = readBytes; // finish while
+ }
+ }
+ }
+ catch(IOException e) {
+ close_socket();
+ if(running != false){
+ reconnect();
+ }
+ System.out.println("Stopping thread.");
+ }
+ }
+ }
+
+ public void startReadThread(AlarmStatusPanel panel){
+ this.panel = panel;
+ start();
+ panel.dispStatus("Server on-line");
+ sendUpdateReq();
+ }
+
+ public void startReadThread(AlarmPanel panel, String vipercellIp, boolean startThread){
+ alarmPanel = panel;
+ alarmPanel.removeAllEvents();
+ setAppletVipercellIp(vipercellIp);
+ if (startThread)
+ start();
+ this.filterVipercellIp = vipercellIp;
+ sendEventReq(vipercellIp);
+ }
+
+ public void finishReadThread(){
+ System.out.println("TCP thread is being shutdown");
+ running = false;
+ close_socket();
+ stop();
+ }
+
+ private void setAppletVipercellIp(String vipercellIp){
+ String valueStr;
+ Short octetVal;
+ String tmpStr = vipercellIp;
+ int index = 0;
+ appletVipercellIp = 0;
+ for (int i = 0; i < 4; i++)
+ {
+ index = tmpStr.indexOf(".");
+ valueStr = i == 3 ? tmpStr : tmpStr.substring(0, index);
+ if (i > 1) // we use only last two octets
+ {
+ octetVal = new Short(valueStr);
+ if (i == 2)
+ appletVipercellIp = octetVal.shortValue() << 8;
+ else
+ appletVipercellIp += octetVal.shortValue();
+ }
+ tmpStr = tmpStr.substring(index + 1);
+ }
+ }
+
+ private int extractNumber(byte[] msg, int pos){
+ return ((msg[pos] << 24 & 0xff000000) +
+ (msg[pos+1] << 16 & 0xff0000) +
+ (msg[pos+2] << 8 & 0xff00) +
+ (msg[pos+3] & 0xff));
+ }
+
+ private int extractIp(byte[] msg, int pos){
+ // for now, we are only extracting last 2 octets of an IP address
+ return((msg[pos+2] << 8 & 0xff00) + (msg[pos+3] & 0xff));
+ }
+
+ public String extractSrcIP(byte[] msg, int i){
+ int h1 = (int)msg[i] & 0x00FF;
+ int h2 = (int)msg[i+1] & 0x00FF;
+ int h3 = (int)msg[i+2] & 0x00FF;
+ int h4 = (int)msg[i+3] & 0x00FF;
+ String source_ip = "" + (new Integer(h1)).toString() +
+ "." + (new Integer(h2)).toString() +
+ "." + (new Integer(h3)).toString() +
+ "." + (new Integer(h4)).toString();
+
+ return source_ip;
+ }
+
+ private int getSeverity(int errorCode){
+ int severity;
+
+ if (errorCode == 0)
+ return ALARM_INFO;
+
+ int tmp = (errorCode & MAX_MODULE_SPECIC_ALARM);
+ if (tmp < ALARM_MAJOR_START_POINT)
+ {
+ severity = ALARM_CRITICAL;
+ } else if (tmp < ALARM_MINOR_START_POINT) {
+ severity = ALARM_MAJOR;
+ } else if (tmp < ALARM_INFO_START_POINT) {
+ severity = ALARM_MINOR;
+ } else {
+ severity = ALARM_INFO;
+ }
+ return severity;
+ }
+
+ private String parseEventData(byte[] msg) {
+ int id = extractNumber(msg, 4);
+ int code = extractNumber(msg, 8);
+ int severity = getSeverity(code);
+ int timestamp = extractNumber(msg, 12);
+ int srcIp = extractIp(msg, 16);
+
+ String srcIpString = extractSrcIP(msg, 16);
+
+ if (0 == appletVipercellIp){
+ appletVipercellIp = srcIp;
+ msgVipercellIp = srcIp;
+ }
+ else
+ msgVipercellIp = srcIp;
+ int srcModule = extractNumber(msg, 64);
+ int opt1 = extractNumber(msg, 68);
+ int opt2 = extractNumber(msg, 72);
+ int ack = extractNumber(msg,76);
+ int recNumber = extractNumber(msg,80);
+ String srcName = new String(msg, 20, 41);
+ srcName = srcName.trim();
+ String eventData = new String(id+"|"+timestamp+"|"+severity+"|"+srcModule+"|"+
+ srcName+"|"+code+"|"+opt1+"|"+opt2+"|"+srcIpString+"|"+ack+"|"+recNumber+"|");
+ return eventData;
+ }
+}
+
diff --git a/data/mnet/Common/Java/AlarmApplet/FilterFrame.java b/data/mnet/Common/Java/AlarmApplet/FilterFrame.java
new file mode 100644
index 0000000..c130ca4
--- /dev/null
+++ b/data/mnet/Common/Java/AlarmApplet/FilterFrame.java
@@ -0,0 +1,337 @@
+import java.awt.*;
+import javax.swing.*;
+import java.awt.event.*;
+import javax.swing.UIManager.*;
+import java.net.*;
+
+import com.jetcell.MibWM.*;
+
+ public class FilterFrame extends JFrame{
+
+ final FilterFrame ff = this;
+
+ Container contentPane = null;
+ JPanel centerPanel = null;
+ JPanel southPanel = null;
+
+ // Labels
+ JLabel alarms = null;
+ JLabel time = null;
+ JLabel severity = null;
+ JLabel acknowledge = null;
+
+ // Combo Boxes
+ JComboBox alarmCombo = new JComboBox();
+ JComboBox timeCombo = new JComboBox();
+ JComboBox severityCombo = new JComboBox();
+ JComboBox acknowledgeCombo = new JComboBox();
+
+ // Reference to "AlarmPanel"
+ AlarmPanel alarmPanel = null;
+
+ public static FilterObject filterObject = null;
+ public static FilterObject tempFilterObject = null;
+
+ public FilterFrame(){
+ if(Util.applet == null){
+ setIconImage(Toolkit.getDefaultToolkit().getImage("../Images/app_icon.gif"));
+ }
+ else{
+ String iconPath = Util.applet.getCodeBase().toString();
+ iconPath += "Images/app_icon.gif";
+ URL iconPathURL = null;
+ try{
+ iconPathURL = new URL(iconPath);
+ }
+ catch(MalformedURLException exc){
+ System.out.println("Bad URL.");
+ }
+ System.out.println(iconPathURL);
+ setIconImage(Toolkit.getDefaultToolkit().getImage(iconPathURL));
+ }
+ }
+
+ public FilterFrame(AlarmPanel panel){
+ this.alarmPanel = panel;
+ if(tempFilterObject == null)
+ tempFilterObject = filterObject;
+ try{
+ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
+ }
+ catch(Exception ex){
+ System.out.println("Error setting Look and Feel for Filter frame");
+ }
+ if(Util.applet == null){
+ setIconImage(Toolkit.getDefaultToolkit().getImage("../Images/app_icon.gif"));
+ }
+ else{
+ String iconPath = Util.applet.getCodeBase().toString();
+ iconPath += "Images/app_icon.gif";
+ URL iconPathURL = null;
+ try{
+ iconPathURL = new URL(iconPath);
+ }
+ catch(MalformedURLException exc){
+ System.out.println("Bad URL.");
+ }
+ System.out.println(iconPathURL);
+ setIconImage(Toolkit.getDefaultToolkit().getImage(iconPathURL));
+ }
+ JButton ok = new JButton(" OK ");
+ JButton cancel = new JButton("CANCEL");
+ JButton saveDefault = new JButton("Save As Default");
+ contentPane = getContentPane();
+ getCenterPanel(tempFilterObject);
+ if(tempFilterObject != null){
+ mapFilterOnFrame(tempFilterObject);
+ }
+ southPanel = new JPanel();
+ southPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
+ southPanel.add(ok);
+ southPanel.add(cancel);
+ if(Util.applet == null){
+ southPanel.add(saveDefault);
+ }
+
+ contentPane.add(centerPanel,BorderLayout.CENTER);
+ contentPane.add(southPanel,BorderLayout.SOUTH);
+ setSize(400,200);
+ addWindowListener(new windowListener());
+
+ ok.addActionListener(new ActionListener(){
+ public void actionPerformed(ActionEvent evt){
+ AlarmStatusApplet.logDM("Handle filter selection");
+ handleFilterSave();
+ }
+ });
+
+ cancel.addActionListener(new ActionListener(){
+ public void actionPerformed(ActionEvent evt){
+ dispose();
+ AlarmStatusApplet.logDM("No filter selection");
+ }
+ });
+
+ saveDefault.addActionListener(new ActionListener(){
+ public void actionPerformed(ActionEvent evt){
+ handleFilterSave();
+ filterObject = tempFilterObject;
+
+ }
+ });
+
+ }
+
+ public void handleFilterSave(){
+
+ // alarms selected
+ tempFilterObject = new FilterObject();
+ String alarms = (String)alarmCombo.getSelectedItem();
+ if(alarms.equals("All")){
+ tempFilterObject.NUM_ALARMS = FilterObject.NONE;
+ }
+ else{
+ try{
+ tempFilterObject.NUM_ALARMS = Integer.parseInt(alarms);
+ }
+ catch(NumberFormatException nfex){
+ JOptionPane.showMessageDialog(ff,"Bad Alarm number criteria.Default value assumed. ","Invalid number",JOptionPane.ERROR_MESSAGE);
+ tempFilterObject.NUM_ALARMS = FilterObject.NONE;
+ }
+ }
+
+ // time selected
+ int timeIndex = timeCombo.getSelectedIndex();
+
+ if(timeIndex == 1){
+ tempFilterObject.TIME = FilterObject.MIN_15;
+ }
+ else if(timeIndex == 2){
+ tempFilterObject.TIME = FilterObject.HR_1;
+ }
+ else if(timeIndex == 3){
+ tempFilterObject.TIME = FilterObject.HR_12;
+ }
+ else if(timeIndex == 4){
+ tempFilterObject.TIME = FilterObject.HR_24;
+ }
+ else
+ tempFilterObject.TIME = FilterObject.NONE;
+
+ // severity selected
+ int severityIndex = severityCombo.getSelectedIndex();
+
+ if(severityIndex == 1){
+ tempFilterObject.SEVERITY = FilterObject.CRITICAL;
+ }
+ else if(severityIndex == 2){
+ tempFilterObject.SEVERITY = FilterObject.MAJOR;
+ }
+ else if(severityIndex == 3){
+ tempFilterObject.SEVERITY = FilterObject.MINOR;
+ }
+ else
+ tempFilterObject.SEVERITY = FilterObject.NULL;
+
+ // acknowledge selected
+ int ackIndex = acknowledgeCombo.getSelectedIndex();
+ if(ackIndex == 1){
+ tempFilterObject.ACKNOWLEDGE = FilterObject.ALL_ACK;
+ }
+ else if(ackIndex == 2){
+ tempFilterObject.ACKNOWLEDGE = FilterObject.NO_ACK;
+ }
+ else
+ tempFilterObject.ACKNOWLEDGE = FilterObject.NONE;
+ this.dispose();
+ // Ananth
+ /*if (tempFilterObject.NUM_ALARMS == FilterObject.NONE &&
+ tempFilterObject.SEVERITY == FilterObject.NULL &&
+ tempFilterObject.TIME == FilterObject.NONE &&
+ tempFilterObject.ACKNOWLEDGE == FilterObject.NONE){
+ Util.setBorderTitle("Alarm List");
+ }
+ else{
+ Util.setBorderTitle("Alarm List (Filtered)");
+ }*/
+
+ if(alarmPanel!=null){
+ alarmPanel.handleFilterEvent(tempFilterObject);
+ alarmPanel.getAlarmTable().Refresh();
+ }
+ else{
+ filterObject = tempFilterObject;
+ }
+
+ }
+
+ private void mapFilterOnFrame(FilterObject tempFilterObject){
+
+ if(tempFilterObject.NUM_ALARMS != FilterObject.NONE){
+ String alarms = Integer.toString(tempFilterObject.NUM_ALARMS);
+ alarmCombo.getEditor().setItem(alarms);
+ }
+ else{
+ alarmCombo.setSelectedIndex(0);
+ }
+
+ if(tempFilterObject.TIME != FilterObject.NONE){
+
+ if(tempFilterObject.TIME == FilterObject.MIN_15)
+ timeCombo.setSelectedIndex(1);
+ else if(tempFilterObject.TIME == FilterObject.HR_1)
+ timeCombo.setSelectedIndex(2);
+ else if(tempFilterObject.TIME == FilterObject.HR_12)
+ timeCombo.setSelectedIndex(3);
+ else if(tempFilterObject.TIME == FilterObject.HR_24)
+ timeCombo.setSelectedIndex(4);
+ }
+ else{
+ timeCombo.setSelectedIndex(0);
+ }
+
+ if(!tempFilterObject.SEVERITY.equals(FilterObject.NULL)){
+
+ if(tempFilterObject.SEVERITY.equals(FilterObject.CRITICAL))
+ severityCombo.setSelectedIndex(1);
+ else if(tempFilterObject.SEVERITY.equals(FilterObject.MAJOR))
+ severityCombo.setSelectedIndex(2);
+ else if(tempFilterObject.SEVERITY.equals(FilterObject.MINOR))
+ severityCombo.setSelectedIndex(3);
+ }
+ else{
+ severityCombo.setSelectedIndex(0);
+ }
+
+ if(tempFilterObject.ACKNOWLEDGE != FilterObject.NONE){
+
+ if(tempFilterObject.ACKNOWLEDGE == FilterObject.ALL_ACK)
+ acknowledgeCombo.setSelectedIndex(1);
+ else if(tempFilterObject.ACKNOWLEDGE == FilterObject.NO_ACK)
+ acknowledgeCombo.setSelectedIndex(2);
+ }
+ else{
+ acknowledgeCombo.setSelectedIndex(0);
+ }
+ }
+
+ public JPanel getCenterPanel(FilterObject filterObj){
+
+ centerPanel = Util.makeBorderPanel("Filter Screen");
+ centerPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
+ alarms = new JLabel(" Alarms ");
+ alarms.setToolTipText("Check to set Alarm filter / Uncheck to set Default (All)");
+ time = new JLabel(" Time ");
+ time.setToolTipText("Check to set Time filter / Uncheck to set Default(All)");
+ severity = new JLabel(" Severity ");
+ severity.setToolTipText("Check to set Severity filter / Uncheck to set Default (All)");
+ acknowledge = new JLabel(" Acknowledge ");
+ acknowledge.setToolTipText("Check to set Acknowledge filter / Uncheck to set Default (All)");
+
+ // Alarms
+ alarmCombo.setPreferredSize(new Dimension(50,20));
+ alarmCombo.setEditable(true);
+ alarmCombo.addItem("All");
+ for(int i=1;i<=20;i++){
+ alarmCombo.addItem(Integer.toString(i));
+ }
+
+ // Time
+ timeCombo.addItem("All");
+ timeCombo.addItem("15 mins");
+ timeCombo.addItem("1 hour");
+ timeCombo.addItem("12 hours");
+ timeCombo.addItem("24 hours");
+
+ // Severity
+ severityCombo.addItem("All");
+ severityCombo.addItem("Critical");
+ severityCombo.addItem("Critical-Major");
+ severityCombo.addItem("Critical-Minor");
+
+ // Acknowledge
+ acknowledgeCombo.addItem("All");
+ acknowledgeCombo.addItem("Acknowledged");
+ acknowledgeCombo.addItem("Unacknowledged");
+
+ // Alarms
+ final JPanel p1 = new JPanel();
+ p1.setLayout(new FlowLayout(FlowLayout.LEFT));
+ p1.add(alarms);
+ p1.add(alarmCombo);
+ p1.add(acknowledge);
+ p1.add(acknowledgeCombo);
+
+
+ // Time
+ final JPanel p2 = new JPanel();
+ p2.setLayout(new FlowLayout(FlowLayout.LEFT));
+ p2.add(severity);
+ p2.add(severityCombo);
+ p2.add(time);
+ p2.add(timeCombo);
+
+ // Severity
+
+ // Acknowledge
+
+
+ centerPanel.add(p1);
+
+ centerPanel.add(p2);
+
+ if(filterObj != null){
+ mapFilterOnFrame(filterObj);
+ }
+ return centerPanel;
+ }
+
+
+ class windowListener extends WindowAdapter{
+ public void windowClosing(WindowEvent evt){
+ dispose();
+ AlarmStatusApplet.logDM("Closing Filter Screen");
+ }
+ }
+
+ }
diff --git a/data/mnet/Common/Java/AlarmApplet/FilterObject.java b/data/mnet/Common/Java/AlarmApplet/FilterObject.java
new file mode 100644
index 0000000..dc7f403
--- /dev/null
+++ b/data/mnet/Common/Java/AlarmApplet/FilterObject.java
@@ -0,0 +1,35 @@
+import java.io.Serializable;
+
+public class FilterObject implements Serializable{
+
+ // filter criteria
+ public int NUM_ALARMS;
+ public int TIME;
+ public String SEVERITY;
+ public int ACKNOWLEDGE;
+
+ public static int NONE = 0;
+
+ // Alarm number constants
+ public static int N1 = 2;
+ public static int N2 = 4;
+ public static int N3 = 6;
+ public static int N4 = 8;
+
+ // Severtiy constants
+ public static String CRITICAL = "CRITICAL";
+ public static String MAJOR = "MAJOR";
+ public static String MINOR = "MINOR";
+ public static String WARNING = "WARNING";
+ public static String NULL = "NULL";
+
+ // Ack constants
+ public static int NO_ACK = 1;
+ public static int ALL_ACK = 2;
+
+ // Time stamp constants
+ public static int MIN_15 = 1;
+ public static int HR_1 = 2;
+ public static int HR_12 = 3;
+ public static int HR_24 = 4;
+}
diff --git a/data/mnet/Common/Java/AlarmApplet/Makefile b/data/mnet/Common/Java/AlarmApplet/Makefile
new file mode 100644
index 0000000..24ded19
--- /dev/null
+++ b/data/mnet/Common/Java/AlarmApplet/Makefile
@@ -0,0 +1,41 @@
+####################################################################
+#
+# FILE NAME: Makefile
+#
+# DESCRIPTION: This makefile creates the vipercell related class
+# files
+# COMPONENTS:
+#
+#
+# NOTES:
+#
+# (C) Copyright 1999 JetCell Inc., CA, USA http://www.jetcell.com/
+#
+# REVISION HISTORY
+#__________________________________________________________________
+#----------+--------+----------------------------------------------
+# Name | Date | Reason
+#----------+--------+----------------------------------------------
+# Kevin Lim|03/28/00| Initial Draft
+#----------+--------+----------------------------------------------
+####################################################################
+#/
+
+CODEBASE = ..
+ALARMARCH = $(CODEBASE)\Java\AlarmStatus.jar
+
+include $(CODEBASE)\java.mk
+
+
+all: $(CLASS_LIST) $(ALARMARCH)
+
+$(ALARMARCH):
+ $(JAR) cvf $@ *.class com\jetcell\MibWM\*.class
+
+clean:
+ -$(RM) *.class
+
+cleanall:
+ -$(RM) *.class
+ -$(RM) $(ALARMARCH)
+
diff --git a/data/mnet/Common/Java/AlarmApplet/com/jetcell/MibWM/Makefile b/data/mnet/Common/Java/AlarmApplet/com/jetcell/MibWM/Makefile
new file mode 100644
index 0000000..e8c30ce
--- /dev/null
+++ b/data/mnet/Common/Java/AlarmApplet/com/jetcell/MibWM/Makefile
@@ -0,0 +1,40 @@
+####################################################################
+#
+# FILE NAME: Makefile
+#
+# DESCRIPTION: This makefile creates the vipercell related class
+# files
+# COMPONENTS:
+#
+#
+# NOTES:
+#
+# (C) Copyright 1999 JetCell Inc., CA, USA http://www.jetcell.com/
+#
+# REVISION HISTORY
+#__________________________________________________________________
+#----------+--------+----------------------------------------------
+# Name | Date | Reason
+#----------+--------+----------------------------------------------
+# Bhawani |11/28/99| Initial Draft
+#----------+--------+----------------------------------------------
+####################################################################
+#/
+
+CODEBASE = ../../../../
+
+
+include $(CODEBASE)/java.mk
+
+
+all: $(CLASS_LIST)
+
+
+clean:
+ -$(RM) *.java
+ -$(RM) *.class
+
+cleanall:
+ -$(RM) *.java
+ -$(RM) *.class
+
diff --git a/data/mnet/Common/Java/Images/Jetcelllogo.jpg b/data/mnet/Common/Java/Images/Jetcelllogo.jpg
new file mode 100644
index 0000000..dc936c9
--- /dev/null
+++ b/data/mnet/Common/Java/Images/Jetcelllogo.jpg
Binary files differ
diff --git a/data/mnet/Common/Java/Images/app_icon.GIF b/data/mnet/Common/Java/Images/app_icon.GIF
new file mode 100644
index 0000000..cee2081
--- /dev/null
+++ b/data/mnet/Common/Java/Images/app_icon.GIF
Binary files differ
diff --git a/data/mnet/Common/Java/Images/app_icon2.GIF b/data/mnet/Common/Java/Images/app_icon2.GIF
new file mode 100644
index 0000000..7f57c5b
--- /dev/null
+++ b/data/mnet/Common/Java/Images/app_icon2.GIF
Binary files differ
diff --git a/data/mnet/Common/Java/Images/cisco.JPG b/data/mnet/Common/Java/Images/cisco.JPG
new file mode 100644
index 0000000..a844554
--- /dev/null
+++ b/data/mnet/Common/Java/Images/cisco.JPG
Binary files differ
diff --git a/data/mnet/Common/Java/Images/cisco2.JPG b/data/mnet/Common/Java/Images/cisco2.JPG
new file mode 100644
index 0000000..510359d
--- /dev/null
+++ b/data/mnet/Common/Java/Images/cisco2.JPG
Binary files differ
diff --git a/data/mnet/Common/Java/Images/ciscologo.jpg b/data/mnet/Common/Java/Images/ciscologo.jpg
new file mode 100644
index 0000000..dc936c9
--- /dev/null
+++ b/data/mnet/Common/Java/Images/ciscologo.jpg
Binary files differ
diff --git a/data/mnet/Common/Java/Images/clear.gif b/data/mnet/Common/Java/Images/clear.gif
new file mode 100644
index 0000000..2664824
--- /dev/null
+++ b/data/mnet/Common/Java/Images/clear.gif
Binary files differ
diff --git a/data/mnet/Common/Java/Images/cowbell.wav b/data/mnet/Common/Java/Images/cowbell.wav
new file mode 100644
index 0000000..425bfdb
--- /dev/null
+++ b/data/mnet/Common/Java/Images/cowbell.wav
Binary files differ
diff --git a/data/mnet/Common/Java/Images/critical.gif b/data/mnet/Common/Java/Images/critical.gif
new file mode 100644
index 0000000..5a5e633
--- /dev/null
+++ b/data/mnet/Common/Java/Images/critical.gif
Binary files differ
diff --git a/data/mnet/Common/Java/Images/filler.gif b/data/mnet/Common/Java/Images/filler.gif
new file mode 100644
index 0000000..b169fb1
--- /dev/null
+++ b/data/mnet/Common/Java/Images/filler.gif
Binary files differ
diff --git a/data/mnet/Common/Java/Images/gmc.jpg b/data/mnet/Common/Java/Images/gmc.jpg
new file mode 100644
index 0000000..4ce4188
--- /dev/null
+++ b/data/mnet/Common/Java/Images/gmc.jpg
Binary files differ
diff --git a/data/mnet/Common/Java/Images/grey.gif b/data/mnet/Common/Java/Images/grey.gif
new file mode 100644
index 0000000..62f0955
--- /dev/null
+++ b/data/mnet/Common/Java/Images/grey.gif
Binary files differ
diff --git a/data/mnet/Common/Java/Images/indeterminate.gif b/data/mnet/Common/Java/Images/indeterminate.gif
new file mode 100644
index 0000000..fa6781d
--- /dev/null
+++ b/data/mnet/Common/Java/Images/indeterminate.gif
Binary files differ
diff --git a/data/mnet/Common/Java/Images/indeterminate2.gif b/data/mnet/Common/Java/Images/indeterminate2.gif
new file mode 100644
index 0000000..62f0955
--- /dev/null
+++ b/data/mnet/Common/Java/Images/indeterminate2.gif
Binary files differ
diff --git a/data/mnet/Common/Java/Images/information.gif b/data/mnet/Common/Java/Images/information.gif
new file mode 100644
index 0000000..8b4657e
--- /dev/null
+++ b/data/mnet/Common/Java/Images/information.gif
Binary files differ
diff --git a/data/mnet/Common/Java/Images/line-01.gif b/data/mnet/Common/Java/Images/line-01.gif
new file mode 100644
index 0000000..691a18d
--- /dev/null
+++ b/data/mnet/Common/Java/Images/line-01.gif
Binary files differ
diff --git a/data/mnet/Common/Java/Images/line-02.gif b/data/mnet/Common/Java/Images/line-02.gif
new file mode 100644
index 0000000..a40c5a7
--- /dev/null
+++ b/data/mnet/Common/Java/Images/line-02.gif
Binary files differ
diff --git a/data/mnet/Common/Java/Images/logo.gif b/data/mnet/Common/Java/Images/logo.gif
new file mode 100644
index 0000000..2356666
--- /dev/null
+++ b/data/mnet/Common/Java/Images/logo.gif
Binary files differ
diff --git a/data/mnet/Common/Java/Images/logo.jpg b/data/mnet/Common/Java/Images/logo.jpg
new file mode 100644
index 0000000..dc936c9
--- /dev/null
+++ b/data/mnet/Common/Java/Images/logo.jpg
Binary files differ
diff --git a/data/mnet/Common/Java/Images/logo1.gif b/data/mnet/Common/Java/Images/logo1.gif
new file mode 100644
index 0000000..2356666
--- /dev/null
+++ b/data/mnet/Common/Java/Images/logo1.gif
Binary files differ
diff --git a/data/mnet/Common/Java/Images/major.gif b/data/mnet/Common/Java/Images/major.gif
new file mode 100644
index 0000000..97257cd
--- /dev/null
+++ b/data/mnet/Common/Java/Images/major.gif
Binary files differ
diff --git a/data/mnet/Common/Java/Images/minor.gif b/data/mnet/Common/Java/Images/minor.gif
new file mode 100644
index 0000000..8855fde
--- /dev/null
+++ b/data/mnet/Common/Java/Images/minor.gif
Binary files differ
diff --git a/data/mnet/Common/Java/Images/minus.gif b/data/mnet/Common/Java/Images/minus.gif
new file mode 100644
index 0000000..5442059
--- /dev/null
+++ b/data/mnet/Common/Java/Images/minus.gif
Binary files differ
diff --git a/data/mnet/Common/Java/Images/normal.gif b/data/mnet/Common/Java/Images/normal.gif
new file mode 100644
index 0000000..2664824
--- /dev/null
+++ b/data/mnet/Common/Java/Images/normal.gif
Binary files differ
diff --git a/data/mnet/Common/Java/Images/notify.wav b/data/mnet/Common/Java/Images/notify.wav
new file mode 100644
index 0000000..726bc0d
--- /dev/null
+++ b/data/mnet/Common/Java/Images/notify.wav
Binary files differ
diff --git a/data/mnet/Common/Java/Images/plus.gif b/data/mnet/Common/Java/Images/plus.gif
new file mode 100644
index 0000000..91c5db9
--- /dev/null
+++ b/data/mnet/Common/Java/Images/plus.gif
Binary files differ
diff --git a/data/mnet/Common/Java/Images/scritical.gif b/data/mnet/Common/Java/Images/scritical.gif
new file mode 100644
index 0000000..5a5e633
--- /dev/null
+++ b/data/mnet/Common/Java/Images/scritical.gif
Binary files differ
diff --git a/data/mnet/Common/Java/Images/sinformation.gif b/data/mnet/Common/Java/Images/sinformation.gif
new file mode 100644
index 0000000..8b4657e
--- /dev/null
+++ b/data/mnet/Common/Java/Images/sinformation.gif
Binary files differ
diff --git a/data/mnet/Common/Java/Images/smajor.gif b/data/mnet/Common/Java/Images/smajor.gif
new file mode 100644
index 0000000..97257cd
--- /dev/null
+++ b/data/mnet/Common/Java/Images/smajor.gif
Binary files differ
diff --git a/data/mnet/Common/Java/Images/sminor.gif b/data/mnet/Common/Java/Images/sminor.gif
new file mode 100644
index 0000000..8855fde
--- /dev/null
+++ b/data/mnet/Common/Java/Images/sminor.gif
Binary files differ
diff --git a/data/mnet/Common/Java/Images/undrkunstrukson.gif b/data/mnet/Common/Java/Images/undrkunstrukson.gif
new file mode 100644
index 0000000..99e41a3
--- /dev/null
+++ b/data/mnet/Common/Java/Images/undrkunstrukson.gif
Binary files differ
diff --git a/data/mnet/Common/Java/Images/vipercell.gif b/data/mnet/Common/Java/Images/vipercell.gif
new file mode 100644
index 0000000..129d52a
--- /dev/null
+++ b/data/mnet/Common/Java/Images/vipercell.gif
Binary files differ
diff --git a/data/mnet/Common/Java/Images/wireless.jpg b/data/mnet/Common/Java/Images/wireless.jpg
new file mode 100644
index 0000000..cea2d88
--- /dev/null
+++ b/data/mnet/Common/Java/Images/wireless.jpg
Binary files differ
diff --git a/data/mnet/Common/Java/Images/wireless1.JPG b/data/mnet/Common/Java/Images/wireless1.JPG
new file mode 100644
index 0000000..5f28e19
--- /dev/null
+++ b/data/mnet/Common/Java/Images/wireless1.JPG
Binary files differ
diff --git a/data/mnet/Common/Java/Java/AlarmApplet.java b/data/mnet/Common/Java/Java/AlarmApplet.java
new file mode 100644
index 0000000..9d4e171
--- /dev/null
+++ b/data/mnet/Common/Java/Java/AlarmApplet.java
@@ -0,0 +1,177 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// Class : AlarmApplet
+// Desc :
+// Author : George Zhao
+// Hist : 06/17/1999 Initial Creation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+package Java;
+
+import java.applet.Applet;
+import java.awt.*;
+import java.util.Calendar;
+import java.lang.String;
+import javax.swing.*;
+import javax.swing.text.Document;
+import javax.swing.event.*;
+import java.net.UnknownHostException;
+import com.jetcell.MibWM.*;
+
+public class AlarmApplet extends JApplet implements DocumentListener
+{
+ public static String ip = null;
+ JTextField eventField = null;
+ AlarmPanel alarmPanel = null;
+ JFrame f = null;
+ AlarmCommThread commObj;
+ public final static short TCP_SERVER_PORT = 10977;
+
+
+
+ public void init()
+ {
+ Util.applet = this;
+ Util.debug = true;
+ eventField = new JTextField();
+ Document doc = eventField.getDocument();
+ doc.addDocumentListener(this);
+
+ /*
+ setBrokerOptions();
+ Broker.addMagicMarkup("QSEvent", "java.lang.String", false);
+ RlBeanProperty beanProp = Broker.wrapBeanProperty(eventField, "text", java.lang.String.class);
+ Broker.bindMarkupToBeanProperty("QSEvent", "", null, beanProp, true, false, true, null);
+ */
+
+ if(getParameter("TEST") != null)
+ {
+ String event1="1111|123456789|0|123|RRM|0|op1|op2";
+ String event2="1111|4321999|1|123|RRM|1|op1";
+ String event3="1111|3432213|3|123|RRM|2";
+ eventField.setText(event1);
+ eventField.setText(event2);
+ eventField.setText(event3);
+ } else {
+ commObj = new AlarmCommThread(getCodeBase().getHost(), TCP_SERVER_PORT);
+ commObj.startReadThread(eventField);
+ }
+
+ alarmPanel = new AlarmPanel();
+ String newin = getParameter("NEWINDOW");
+ if (f != null)
+ {
+ f.setVisible(true);
+ }
+ else {
+ if (newin != null)
+ {
+ System.out.println("NEWINDOW VALUE = " +newin);
+ if(newin.equals("FALSE") || newin.equals("false"))
+ {
+ getContentPane().setLayout(new BorderLayout());
+ getContentPane().setBackground(Color.white);
+ setBackground(Color.white);
+ getContentPane().add(alarmPanel.createPanel(),BorderLayout.CENTER);
+ }
+ else {
+ f = new JFrame("Alarm List for ViperCell: "+ip);
+ f.getContentPane().setLayout(new BorderLayout());
+ f.getContentPane().add(alarmPanel.createPanel());
+ f.setBounds(0,0, 720,400);
+ f.setVisible(true);
+ }
+ }
+ else {
+ System.out.println("Please set NEWINDOW parameter to TRUE or FALSE");
+ }
+ }
+
+ try
+ {
+ getRootPane().putClientProperty("defeatSystemEventQueueCheck", Boolean.TRUE);
+ UIManager.setLookAndFeel( "com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
+ SwingUtilities.updateComponentTreeUI(this);
+ }
+ catch(Exception ex)
+ {
+ //Util.showDialog(f, ex.toString(), "Error", JOptionPane.ERROR_MESSAGE);
+ }
+ }
+
+ public void start()
+ {
+ }
+
+ public void stop()
+ {
+ }
+
+ public void destroy()
+ {
+ commObj.finishReadThread();
+ System.out.println("Destroy method has been called");
+ }
+
+ public void changedUpdate(DocumentEvent e)
+ {
+ }
+
+ public void insertUpdate(DocumentEvent e)
+ {
+ /*
+ System.out.println("insertUpdate");
+ java.util.Random r = new java.util.Random();
+ Calendar d = Calendar.getInstance();
+ */
+ String alarmId = eventField.getText();
+ System.out.println("Receiving Alarm: "+alarmId);
+
+ // for test only. -gz
+ /*
+ int eventId = Integer.parseInt(alarmId.substring(alarmId.indexOf('r')+2, alarmId.length()));
+
+ String severity = null;
+
+ try {
+ d.add(Calendar.SECOND, java.lang.Math.abs(r.nextInt()));
+ if (eventId-eventId/3*3 == 0)
+ severity = new String("Critical");
+ else if (eventId-eventId/3*3 == 1)
+ severity = new String("Minor");
+ else if (eventId - eventId/3*3 == 2)
+ severity = new String("Info");
+ String date = d.getTime().toString();
+ String object = "Object_"+String.valueOf(java.lang.Math.abs(r.nextInt()));
+ String message = eventField.getText();
+
+ //AlarmData alarm = new AlarmData(String.valueOf(eventId), date, severity, null, object, message, null);
+
+ AlarmData alarm = new AlarmData(alarmId);
+ alarmPanel.addEvent(alarm);
+ Thread.sleep(1000);
+ System.out.println("Event: " +alarmId);
+ }
+ catch(Exception ex)
+ {
+ System.out.println(ex);
+ ex.printStackTrace();
+ }
+ */
+
+ if(!alarmId.startsWith("Event Number"))
+ {
+ try {
+ AlarmData alarm = new AlarmData(alarmId);
+ alarmPanel.addEvent(alarm);
+ }
+ catch(Exception ex) {}
+ }
+ }
+
+ public void removeUpdate(DocumentEvent e)
+ {
+ }
+}
+//$History:$ \ No newline at end of file
diff --git a/data/mnet/Common/Java/Java/AlarmCommThread.java b/data/mnet/Common/Java/Java/AlarmCommThread.java
new file mode 100644
index 0000000..cd9721b
--- /dev/null
+++ b/data/mnet/Common/Java/Java/AlarmCommThread.java
@@ -0,0 +1,121 @@
+////////////////////////////////////////////////////////////////////////////
+//
+// FILE NAME: AlarmCommThread.java
+//
+// DESCRIPTION: This file contains a class that allow the applet to
+// communicate with the Tcp Server at the ViperCell
+// COMPONENTS:
+//
+//
+// NOTES:
+//
+// (C) Copyright 1999 JetCell Inc., CA, USA http://www.jetcell.com/
+//
+// REVISION HISTORY
+//__________________________________________________________________
+//----------+--------+----------------------------------------------
+// Name | Date | Reason
+//----------+--------+----------------------------------------------
+// Bhawani |2/08/00 | Initial Draft
+//----------+--------+----------------------------------------------
+//////////////////////////////////////////////////////////////////////////
+//
+
+package Java;
+
+import java.net.*;
+import java.io.*;
+import javax.swing.*;
+import javax.swing.*;
+import javax.swing.text.Document;
+import javax.swing.event.*;
+
+
+
+public class AlarmCommThread extends Thread {
+ private Socket socket;
+ private BufferedReader in;
+ private PrintWriter out;
+ private JTextField p_eventField;
+ private boolean running;
+
+ public AlarmCommThread(String addr, short port) {
+ System.out.println("Initializing TCP/Ip socket environment");
+ try {
+ socket = new Socket(addr, port);
+ } catch(IOException e) {
+ // If the creation of the socket fails,
+ // nothing needs to be cleaned up.
+ System.out.println("Could not connect to the Server" + addr + "at port " + port + ": " + socket);
+ }
+ try {
+ in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
+ // Enable auto-flush:
+ out = new PrintWriter(new OutputStreamWriter(socket.getOutputStream()));
+ // register client's message group
+ out.print("AlarmAsyncUpdate");
+ out.flush();
+
+ // digest the hello message
+ String str = in.readLine();
+ System.out.println("Server's Greeting: " + str);
+ } catch(IOException e) {
+ // The socket should be closed on any
+ // failures other than the socket
+ // constructor:
+ System.out.println("IO error in AlarmCommThread: ");
+ try {
+ socket.close();
+ } catch(IOException e2) {}
+ }
+ // Otherwise the socket will be closed by
+ // the run() method of the thread.
+ }
+
+ public void send(String str)
+ {
+ out.print(str);
+ out.flush();
+ }
+
+ public void startReadThread(JTextField eventField)
+ {
+
+ p_eventField = eventField;
+ start();
+ }
+ public void run() {
+ try {
+ running = true;
+ while (running) {
+ if(in.ready())
+ {
+ String str = in.readLine();
+ this.p_eventField.setText(str);
+ } else {
+ try {
+ this.sleep(100);
+ } catch (InterruptedException ie) {
+ System.out.println(" Interrupted Excution = " + ie);
+ }
+ }
+ }
+ } catch(IOException e3) {
+ System.out.println(" IO expection at read thread" + e3 );
+ } finally {
+ // Always close it:
+ try {
+ System.out.println("Socket is closing");
+ socket.close();
+ } catch(IOException e) {}
+ // Ending this thread
+ }
+ }
+
+ public void finishReadThread()
+ {
+ System.out.println("The read thread is being shutdown");
+ running = false;
+ }
+}
+
diff --git a/data/mnet/Common/Java/Java/ConfigApplet.java b/data/mnet/Common/Java/Java/ConfigApplet.java
new file mode 100644
index 0000000..2b82c7e
--- /dev/null
+++ b/data/mnet/Common/Java/Java/ConfigApplet.java
@@ -0,0 +1,53 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// Class : ConfigApplet
+// Desc :
+// Author : George Zhao
+// Hist : 08/25/1999 Initial Creation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+package Java;
+
+import java.awt.event.*;
+import javax.swing.*;
+import javax.swing.table.*;
+import javax.swing.event.*;
+import java.util.Hashtable;
+import java.awt.*;
+import com.jetcell.MibWM.*;
+import com.jetcell.MibWM.ViperBase.*;
+
+public class ConfigApplet extends JApplet
+{
+
+ public void init()
+ {
+ try {
+ String host = getParameter("HOST");
+ int port = Integer.parseInt(getParameter("PORT"));
+ Configuration base = new Configuration(host, port);
+ getContentPane().setLayout(new BorderLayout());
+ getContentPane().setBackground(Color.white);
+ setBackground(Color.white);
+ getContentPane().add(base.mainPanel,BorderLayout.CENTER);
+ }
+ catch(Exception e)
+ {
+ System.out.println("Exception : "+ e.toString());
+ }
+ }
+
+ public void start()
+ {
+ }
+
+ public void stop()
+ {
+ }
+
+ public void destroy()
+ {
+ }
+}
+//$History:$ \ No newline at end of file
diff --git a/data/mnet/Common/Java/Java/ConfigAppletBeanInfo.java b/data/mnet/Common/Java/Java/ConfigAppletBeanInfo.java
new file mode 100644
index 0000000..dc23ed8
--- /dev/null
+++ b/data/mnet/Common/Java/Java/ConfigAppletBeanInfo.java
@@ -0,0 +1,70 @@
+/////////////////////////////////////////////////////////////////////////////
+//
+// Class : ConfigAppletBeanInfo
+// Desc :
+// Author : George Zhao
+// Hist : 08/27/1999 Initial Creation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+package Java;
+
+import java.beans.*;
+import java.beans.SimpleBeanInfo;
+
+public class ConfigAppletBeanInfo extends java.beans.SimpleBeanInfo
+{
+ public ConfigAppletBeanInfo()
+ {
+ }
+
+ /**
+ * Gets a BeanInfo for the superclass of this bean.
+ * @return BeanInfo[] containing this bean's superclass BeanInfo
+ */
+ public BeanInfo[] getAdditionalBeanInfo()
+ {
+ try
+ {
+ BeanInfo[] bi = new BeanInfo[1];
+ bi[0] = Introspector.getBeanInfo(beanClass.getSuperclass());
+ return bi;
+ }
+ catch (IntrospectionException e)
+ {
+ throw new Error(e.toString());
+ }
+ }
+
+ /**
+ * Gets the BeanDescriptor for this bean.
+ * @return an object of type BeanDescriptor
+ * @see java.beans.BeanDescriptor
+ */
+ public BeanDescriptor getBeanDescriptor()
+ {
+ BeanDescriptor bd = new BeanDescriptor(beanClass);
+ return bd;
+ }
+
+ /**
+ * Gets an image that may be used to visually represent this bean
+ * (in the toolbar, on a form, etc).
+ * @param iconKind the type of icon desired, one of: BeanInfo.ICON_MONO_16x16,
+ * BeanInfo.ICON_COLOR_16x16, BeanInfo.ICON_MONO_32x32, or BeanInfo.ICON_COLOR_32x32.
+ * @return an image for this bean
+ * @see BeanInfo#ICON_MONO_16x16
+ * @see BeanInfo#ICON_COLOR_16x16
+ * @see BeanInfo#ICON_MONO_32x32
+ * @see BeanInfo#ICON_COLOR_32x32
+ */
+ public java.awt.Image getIcon(int nIconKind)
+ {
+ java.awt.Image img = null;
+ return img;
+ }
+
+ private final Class beanClass = ConfigApplet.class;
+}
+
+//$History:$ \ No newline at end of file
diff --git a/data/mnet/Common/Java/Java/Makefile b/data/mnet/Common/Java/Java/Makefile
new file mode 100644
index 0000000..b1ea6c2
--- /dev/null
+++ b/data/mnet/Common/Java/Java/Makefile
@@ -0,0 +1,69 @@
+####################################################################
+#
+# FILE NAME: Makefile
+#
+# DESCRIPTION: This makefile creates the common class files and the
+# common jar file.
+#
+# COMPONENTS:
+#
+#
+# NOTES:
+#
+# (C) Copyright 1999 JetCell Inc., CA, USA http://www.jetcell.com/
+#
+# REVISION HISTORY
+#__________________________________________________________________
+#----------+--------+----------------------------------------------
+# Name | Date | Reason
+#----------+--------+----------------------------------------------
+# Bhawani |11/28/99| Initial Draft
+# Kevin Lim|03/28/00| add AlarmStatus.jar
+#----------+--------+----------------------------------------------
+####################################################################
+#/
+
+CODEBASE = ..
+include $(CODEBASE)/java.mk
+
+MIBWMPATH = $(CODEBASE)/com/jetcell/MibWM
+VIPERCELL = $(MIBWMPATH)
+VIPERBASE = $(MIBWMPATH)/ViperBase
+ALARMPATH = $(CODEBASE)/AlarmApplet
+
+MIBWM = ./MibWM.jar
+ALARMARCH = ./AlarmStatus.jar
+
+
+VIPERCELL_JAVA = $(wildcard $(VIPERCELL)/*.java)
+VIPERCELL_CLASS = $(subst /,/, $(VIPERCELL_JAVA:.java=.class))
+
+VIPERBASE_JAVA = GudbData.java EncodeMessage.java \
+ Configuration.java RoamingNumberTable.java
+
+VIPERBASE_TMP = $(VIPERBASE_JAVA:.java=.class)
+VIPERBASE_CLASS = $(foreach file, $(VIPERBASE_TMP), $(VIPERBASE)/$(file))
+
+all: $(MIBWM) $(CLASS_LIST) $(ALARMARCH)
+
+
+$(MIBWM): $(VIPERCELL_CLASS) $(VIPERBASE_CLASS)
+ @$(RM) $@
+ $(MAKE) -C $(CODEBASE) mibwm
+
+$(ALARMARCH): $(ALARMPATH)/*.class
+ @$(RM) $@
+ $(MAKE) -C $(CODEBASE) alarm
+
+viperCell:
+ $(MAKE) -C $(VIPERCELL) all
+
+viperBase:
+ $(MAKE) -C $(VIPERBASE) all
+
+cleanall:
+ -$(RM) $(subst /,\, $(VIPERBASE)/*.class)
+ -$(RM) $(subst /,\, $(MIBWM) $(CLASS_LIST))
+
+
+
diff --git a/data/mnet/Common/Java/Java/SubscriberApplet.java b/data/mnet/Common/Java/Java/SubscriberApplet.java
new file mode 100644
index 0000000..8f7aedc
--- /dev/null
+++ b/data/mnet/Common/Java/Java/SubscriberApplet.java
@@ -0,0 +1,58 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// Class : SubscriberApplet
+// Desc :
+// Author : George Zhao
+// Hist : 08/25/1999 Initial Creation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+package Java;
+
+import java.awt.event.*;
+import javax.swing.*;
+import javax.swing.table.*;
+import javax.swing.event.*;
+import java.util.Hashtable;
+import java.awt.*;
+import com.jetcell.MibWM.*;
+import com.jetcell.MibWM.ViperBase.*;
+
+
+public class SubscriberApplet extends JApplet
+{
+
+
+ public void init()
+ {
+ try {
+ String host = getParameter("HOST");
+ int port = Integer.parseInt(getParameter("PORT"));
+ //test. -begin
+ Subscriber sub = new Subscriber(host, port);
+ //Subscriber sub = new Subscriber();
+ // test. -end.
+ getContentPane().setLayout(new BorderLayout());
+ getContentPane().setBackground(Color.white);
+ setBackground(Color.white);
+ getContentPane().add(((Subscriber)sub).mainPanel ,BorderLayout.CENTER);
+ }
+ catch(Exception e)
+ {
+ System.out.println("Exception : " +e.toString());
+ }
+ }
+
+ public void start()
+ {
+ }
+
+ public void stop()
+ {
+ }
+
+ public void destroy()
+ {
+ }
+}
+//$History:$ \ No newline at end of file
diff --git a/data/mnet/Common/Java/Java/SubscriberAppletBeanInfo.java b/data/mnet/Common/Java/Java/SubscriberAppletBeanInfo.java
new file mode 100644
index 0000000..0386ffb
--- /dev/null
+++ b/data/mnet/Common/Java/Java/SubscriberAppletBeanInfo.java
@@ -0,0 +1,69 @@
+/////////////////////////////////////////////////////////////////////////////
+//
+// Class : SubscriberAppletBeanInfo
+// Desc :
+// Author : George Zhao
+// Hist : 08/27/1999 Initial Creation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+package Java;
+
+import java.beans.*;
+import java.beans.SimpleBeanInfo;
+
+public class SubscriberAppletBeanInfo extends java.beans.SimpleBeanInfo
+{
+ public SubscriberAppletBeanInfo()
+ {
+ }
+
+ /**
+ * Gets a BeanInfo for the superclass of this bean.
+ * @return BeanInfo[] containing this bean's superclass BeanInfo
+ */
+ public BeanInfo[] getAdditionalBeanInfo()
+ {
+ try
+ {
+ BeanInfo[] bi = new BeanInfo[1];
+ bi[0] = Introspector.getBeanInfo(beanClass.getSuperclass());
+ return bi;
+ }
+ catch (IntrospectionException e)
+ {
+ throw new Error(e.toString());
+ }
+ }
+
+ /**
+ * Gets the BeanDescriptor for this bean.
+ * @return an object of type BeanDescriptor
+ * @see java.beans.BeanDescriptor
+ */
+ public BeanDescriptor getBeanDescriptor()
+ {
+ BeanDescriptor bd = new BeanDescriptor(beanClass);
+ return bd;
+ }
+
+ /**
+ * Gets an image that may be used to visually represent this bean
+ * (in the toolbar, on a form, etc).
+ * @param iconKind the type of icon desired, one of: BeanInfo.ICON_MONO_16x16,
+ * BeanInfo.ICON_COLOR_16x16, BeanInfo.ICON_MONO_32x32, or BeanInfo.ICON_COLOR_32x32.
+ * @return an image for this bean
+ * @see BeanInfo#ICON_MONO_16x16
+ * @see BeanInfo#ICON_COLOR_16x16
+ * @see BeanInfo#ICON_MONO_32x32
+ * @see BeanInfo#ICON_COLOR_32x32
+ */
+ public java.awt.Image getIcon(int nIconKind)
+ {
+ java.awt.Image img = null;
+ return img;
+ }
+
+ private final Class beanClass = SubscriberApplet.class;
+}
+//$History:$ \ No newline at end of file
diff --git a/data/mnet/Common/Java/Makefile b/data/mnet/Common/Java/Makefile
new file mode 100644
index 0000000..2e8b2bb
--- /dev/null
+++ b/data/mnet/Common/Java/Makefile
@@ -0,0 +1,58 @@
+####################################################################
+#
+# FILE NAME: Makefile
+#
+# DESCRIPTION: This is root make file that genetates java classes
+# and jar file.
+#
+# COMPONENTS:
+#
+#
+# NOTES:
+#
+# (C) Copyright 1999 JetCell Inc., CA, USA http://www.jetcell.com/
+#
+# REVISION HISTORY
+#__________________________________________________________________
+#----------+--------+----------------------------------------------
+# Name | Date | Reason
+#----------+--------+----------------------------------------------
+# Bhawani |11/28/99| Iniitial Draft
+# Kevin Lim|03/28/00| added AlarmStatusApplet
+#----------+--------+----------------------------------------------
+####################################################################
+
+CODEBASE = .
+include $(CODEBASE)/java.mk
+VIPERCELL = $(MIBWMPATH)
+VIPERBASE = $(MIBWMPATH)/ViperBase
+PACKPATH = $(ALARMAPPLETDIR)\com\jetcell\MibWM
+
+MIBWM = ./Java/MibWM.jar
+ALARMARCH = ./Java/AlarmStatus.jar
+
+all:
+ $(CP) $(MIBWMPATH)\*.java $(PACKPATH)
+
+ $(MAKE) -C $(ALARMAPPLETDIR) all
+
+alarm: $(ALARMARCH)
+
+$(ALARMARCH):
+ $(CP) AlarmApplet\AlarmStatus.jar Java\AlarmStatus.jar
+
+# mibwm: $(MIBWM)
+
+$(MIBWM): ./Java/AlarmCommThread.class
+# $(JAR) cvf $@ $(VIPERCELL)/*.class $(VIPERBASE)/*.class ./Java/AlarmCommThread.class
+ $(JAR) cvf $@ $(VIPERCELL)/*.class ./Java/AlarmCommThread.class
+
+
+cleanall:
+ $(MAKE) -C $(ALARMAPPLETDIR) cleanall
+ $(MAKE) -C $(PACKPATH) cleanall
+ $(MAKE) -C $(COMMON) cleanall
+
+
+
+
diff --git a/data/mnet/Common/Java/Text/AlarmCode.English b/data/mnet/Common/Java/Text/AlarmCode.English
new file mode 100644
index 0000000..8f79150
--- /dev/null
+++ b/data/mnet/Common/Java/Text/AlarmCode.English
@@ -0,0 +1,154 @@
+// AlarmCode.English
+// Copyright (C) 2000 Cisco Systems, Inc.
+// All rights reserved
+// WARNING: This file is automatically generated by an AlarmCode tool
+// Any changes made to this file will be overwritten by
+// subsequent uses of the tool.
+//
+// ALARM_ERROR_CODE | "ALARM_SYNOPSIS" | "ALARM_DETAIL_MESSAGE"
+ 0 | Module alarm with ID %2 has cleared | The alarm ID %2 (error code %1) was cleared by module %module. The operational state of GSM Port depends on alarm status from all modules.
+ 131074 | First DSP/FPGA Hardware Failure | Bit clock at the first DSP/Fpga is not functioning. GSM Port must be rebooted to recover from this situation.
+ 131075 | Second DSP/FPGA Hardware Failure | Bit clock at the second DSP/Fpga is not functioning. GSM Port must be rebooted to recover from this situation.
+ 131076 | First DSP not responding | Link between RM and first DSP is broken. GSM Port must be rebooted to recover from this situation.
+ 131077 | Second DSP not responding | Link between RM and second DSP is broken. GSM Port can function in a reduced-Capacity mode if the first DSP can function properly. GSM Port must be rebooted to recover from this situation.
+ 131078 | Cell Broadcast Channel unusable | Cell broadcast channel initialization failed. Cell broadcast will not be supported until the next reboot. This channel, however, does not affect the operational state of the GSM Port.
+ 131079 | No usable traffic channel | Initialization of all the traffic channels failed. Please unlock them if they are locked. If the their admin state is already unlocked, please reboot the system.
+ 131080 | No TRX enabled | Initialization of both TRX failed. Please unlock them if they are locked. If the their admin state is already unlocked, please reboot the system.
+ 131081 | Illegal Configuration - No BCCH Channel | No BCCH channel combination is specified in the MIB. Please check the first TRX configuration through GP Manager.
+ 131082 | Illegal Configuration - Unsupported Channel | Unsupported channel combination is detected in the MIB. Please check both first and second TRX configuration through GP Manager
+ 131083 | Illegal Configuration - Two BCCH Channel | Only one BCCH channel is supported at this time but two BCCH channel configuration found. Please correct this problem through GP Manager.
+ 131084 | Illegal Configuration - Too many Channel Combination I | Too many channel combination I configuration found. Please correct this problem through GP Manager.
+ 131085 | Illegal Configuration - Multiple BCCH Channels | Only one BCCH channel is supported at this time but more than two BCCH channels have been configured. Please correct this problem through GP Manager.
+ 131086 | System Call Failure - Watchdog timer create | RM module detects failure in creating WatchDog Timer which is essential for proper software operation. GSM Port must be rebooted to recover from this situation.
+ 131087 | System Call Failure - Message queue receive | RM module encountered failure in receiving message. GSM Port must be rebooted to recover from this situation.
+ 131088 | OAM Api Failure | Could not set a field of a MIB table entry.
+ 131089 | Oam Api Failure | Could not set a MIB integer variable.
+ 131090 | RF board not detected | Failed to detect RF board. Please check if it is there.
+ 135169 | GSM Port Locked | The GSM Port was locked successfully. Existing calls (if any) were aborted. No new calls can be made through GSM Port.
+ 135170 | GSM Port Unlocked | The GSM Port was unlocked successfully. GSM Port can accept new calls if its operational state is enabled.
+ 135171 | GSM Port Shutting Down | The GSM Port is being shutdown. No new calls can be made through GSM Port. Existing calls are maintained until terminates normally.
+ 135172 | First TRX Locked | The first TRX was locked successfully. Locking of first TRX is equivalent of locking of GSM Port. Existing calls (if any) were aborted. No new calls can be made through GSM Port.
+ 135173 | Second TRX Locked | The second TRX was locked successfully. Existing calls (if any) were aborted. No new calls will be made through this TRX.
+ 135174 | First TRX Unlocked | The first TRX was unlocked successfully. New calls can be made through this TRX.
+ 135175 | Second TRX Unlocked | The second TRX was unlocked successfully. New calls can be made through this TRX.
+ 135176 | First TRX shutting down | The first TRX is being shutting down. Shutting down first TRX is equivalent of shutting down GSM Port. No new calls can be made through GSM Port. Existing calls are maintained until terminates normally.
+ 135177 | Second TRX shutting down | The second TRX is being shutting down. No new calls can be made through this TRX. Existing calls are maintained until terminates normally.
+ 135178 | First TRX Time Slot 0 locked | Locking of Time Slot 0 of first TRX is equivalent of locking GSM Port. Existing calls (if any) were aborted. No new calls can be made through GSM Port.
+ 135179 | First TRX Time Slot 1 locked | Time slot 1 of the first TRX was locked successfully. Existing call (if any) was aborted. No new call can be made through this time slot.
+ 135180 | First TRX Time Slot 2 locked | Time slot 2 of the first TRX was locked successfully. Existing call (if any) was aborted. No new call can be made through this time slot.
+ 135181 | First TRX Time Slot 3 locked | Time slot 3 of the first TRX was locked successfully. Existing call (if any) was aborted. No new call can be made through this time slot.
+ 135182 | First TRX Time Slot 4 locked | Time slot 4 of the first TRX was locked successfully. Existing call (if any) was aborted. No new call can be made through this time slot.
+ 135183 | First TRX Time Slot 5 locked | Time slot 5 of the first TRX was locked successfully. Existing call (if any) was aborted. No new call can be made through this time slot.
+ 135184 | First TRX Time Slot 6 locked | Time slot 6 of the first TRX was locked successfully. Existing call (if any) was aborted. No new call can be made through this time slot.
+ 135185 | First TRX Time Slot 7 locked | Time slot 7 of the first TRX was locked successfully. Existing call (if any) was aborted. No new call can be made through this time slot.
+ 135186 | Second TRX Time Slot 0 locked | Time slot 0 of the second TRX was locked successfully. Existing call (if any) was aborted. No new call can be made through this time slot.
+ 135187 | Second TRX Time Slot 1 locked | Time slot 1 of the second TRX was locked successfully. Existing call (if any) was aborted. No new call can be made through this time slot.
+ 135188 | Second TRX Time Slot 2 locked | Time slot 2 of the second TRX was locked successfully. Existing call (if any) was aborted. No new call can be made through this time slot.
+ 135189 | Second TRX Time Slot 3 locked | Time slot 3 of the second TRX was locked successfully. Existing call (if any) was aborted. No new call can be made through this time slot.
+ 135190 | Second TRX Time Slot 4 locked | Time slot 4 of the second TRX was locked successfully. Existing call (if any) was aborted. No new call can be made through this time slot.
+ 135191 | Second TRX Time Slot 5 locked | Time slot 5 of the second TRX was locked successfully. Existing call (if any) was aborted. No new call can be made through this time slot.
+ 135192 | Second TRX Time Slot 6 locked | Time slot 6 of the second TRX was locked successfully. Existing call (if any) was aborted. No new call can be made through this time slot.
+ 135193 | Second TRX Time Slot 7 locked | Time slot 7 of the second TRX was locked successfully. Existing call (if any) was aborted. No new call can be made through this time slot.
+ 135194 | First TRX Time Slot 0 Unlocked | Time slot 0 of the first TRX was unlocked successfully. New calls can be made through this time slot.
+ 135195 | First TRX Time Slot 1 Unlocked | Time slot 1 of the first TRX was unlocked successfully. New calls can be made through this time slot.
+ 135196 | First TRX Time Slot 2 Unlocked | Time slot 2 of the first TRX was unlocked successfully. New calls can be made through this time slot.
+ 135197 | First TRX Time Slot 3 Unlocked | Time slot 3 of the first TRX was unlocked successfully. New calls can be made through this time slot.
+ 135198 | First TRX Time Slot 4 Unlocked | Time slot 4 of the first TRX was unlocked successfully. New calls can be made through this time slot.
+ 135199 | First TRX Time Slot 5 Unlocked | Time slot 5 of the first TRX was unlocked successfully. New calls can be made through this time slot.
+ 135200 | First TRX Time Slot 6 Unlocked | Time slot 6 of the first TRX was unlocked successfully. New calls can be made through this time slot.
+ 135201 | First TRX Time Slot 7 Unlocked | Time slot 7 of the first TRX was unlocked successfully. New calls can be made through this time slot.
+ 135202 | Second TRX Time Slot 0 Unlocked | Time slot 0 of the second TRX was unlocked successfully. New calls can be made through this time slot.
+ 135203 | Second TRX Time Slot 1 Unlocked | Time slot 1 of the second TRX was unlocked successfully. New calls can be made through this time slot.
+ 135204 | Second TRX Time Slot 2 Unlocked | Time slot 2 of the second TRX was unlocked successfully. New calls can be made through this time slot.
+ 135205 | Second TRX Time Slot 3 Unlocked | Time slot 3 of the second TRX was unlocked successfully. New calls can be made through this time slot.
+ 135206 | Second TRX Time Slot 4 Unlocked | Time slot 4 of the second TRX was unlocked successfully. New calls can be made through this time slot.
+ 135207 | Second TRX Time Slot 5 Unlocked | Time slot 5 of the second TRX was unlocked successfully. New calls can be made through this time slot.
+ 135208 | Second TRX Time Slot 6 Unlocked | Time slot 6 of the second TRX was unlocked successfully. New calls can be made through this time slot.
+ 135209 | Second TRX Time Slot 7 Unlocked | Time slot 7 of the second TRX was unlocked successfully. New calls can be made through this time slot.
+ 135210 | First TRX Time Slot 0 shutting down | Time slot 0 of the first TRX is being shutdown. Shutting down Time Slot 0 of First TRX is equivalent of shutting down GSM Port. Existing calls will be maintained until terminate normally. No new calls can be made through GSM Port.
+ 135211 | First TRX Time Slot 1 shutting down | Time slot 1 of the first TRX is being shutdown. Existing call (if any) will be maintained until terminate normally. No new call can be made through this time slot.
+ 135212 | First TRX Time Slot 2 shutting down | Time slot 2 of the first TRX is being shutdown. Existing call (if any) will be maintained until terminate normally. No new call can be made through this time slot.
+ 135213 | First TRX Time Slot 3 shutting down | Time slot 3 of the first TRX is being shutdown. Existing call (if any) will be maintained until terminate normally. No new call can be made through this time slot.
+ 135214 | First TRX Time Slot 4 shutting down | Time slot 4 of the first TRX is being shutdown. Existing call (if any) will be maintained until terminate normally. No new call can be made through this time slot.
+ 135215 | First TRX Time Slot 5 shutting down | Time slot 5 of the first TRX is being shutdown. Existing call (if any) will be maintained until terminate normally. No new call can be made through this time slot.
+ 135216 | First TRX Time Slot 6 shutting down | Time slot 6 of the first TRX is being shutdown. Existing call (if any) will be maintained until terminate normally. No new call can be made through this time slot.
+ 135217 | First TRX Time Slot 7 shutting down | Time slot 7 of the first TRX is being shutdown. Existing call (if any) will be maintained until terminate normally. No new call can be made through this time slot.
+ 135218 | Second TRX Time Slot 0 shutting down | Time slot 0 of the second TRX is being shutdown. Existing call (if any) will be maintained until terminate normally. No new call can be made through this time slot.
+ 135219 | Second TRX Time Slot 1 shutting down | Time slot 1 of the second TRX is being shutdown. Existing call (if any) will be maintained until terminate normally. No new call can be made through this time slot.
+ 135220 | Second TRX Time Slot 2 shutting down | Time slot 2 of the second TRX is being shutdown. Existing call (if any) will be maintained until terminate normally. No new call can be made through this time slot.
+ 135221 | Second TRX Time Slot 3 shutting down | Time slot 3 of the second TRX is being shutdown. Existing call (if any) will be maintained until terminate normally. No new call can be made through this time slot.
+ 135222 | Second TRX Time Slot 4 shutting down | Time slot 4 of the second TRX is being shutdown. Existing call (if any) will be maintained until terminate normally. No new call can be made through this time slot.
+ 135223 | Second TRX Time Slot 5 shutting down | Time slot 5 of the second TRX is being shutdown. Existing call (if any) will be maintained until terminate normally. No new call can be made through this time slot.
+ 135224 | Second TRX Time Slot 6 shutting down | Time slot 6 of the second TRX is being shutdown. Existing call (if any) will be maintained until terminate normally. No new call can be made through this time slot.
+ 135225 | Second TRX Time Slot 7 shutting down | Time slot 7 of the second TRX is being shutdown. Existing call (if any) will be maintained until terminate normally. No new call can be made through this time slot.
+ 135226 | Radio for the first TRX is off | Radio for the first TRX is off
+ 135227 | Radio for the second TRX is off | Radio for the second TRX is off
+ 135228 | RM detects corrupted Layer 1 message | RM module detected a corrupted message from Layer 1.
+ 327681 | LAPDm Internal Failure | Data corruption in the LAPDm Layer software. The system needs a reboot
+ 327936 | LAPDm Resource Exhausted | LAPDm Layer ran out of available frame buffer. This is most likely caused by radio link problem with MS.
+ 462848 | (Re)Load MIB | New MIB have been loaded on %1. You most likely need to reboot the GSM Port
+ 462850 | MIB save option Change - Timer enabled | MIB save timer has been disabled on %1.
+ 462849 | MIB save option Change - Timer disabled | MIB save timer has been disabled on %1.
+ 462851 | MIB Option Change - Duplicate save allowed | MIB save option change on %1.
+ 462852 | MIB option change - Duplicate save not allowed | Duplicate saving of the MIB is now disabled. This will improve the response time of the set operation at GP Manager
+ 458753 | GSM Port Operator-Initiated Reboot | The operator has initiated a reboot on %1. GSM Port will reboot within a few seconds.
+ 524289 | GMC Link Down | Detected link lost to GMC. Please check the operational status of GMC and the physical network connectivity between GMC and GSM Port.
+ 917505 | MPC SRAM test failure | MCH Module's Test results indicates that there was a failure in MPC SRAM Test.
+ 917506 | DSP0 internal data RAM test failure | MCH Module's Post Test results indicates that there was a failure in DSP0's internal data RAM Test.
+ 917507 | DSP1 internal data RAM test failure | MCH Module's Post Test results indicates that there was a failure in DSP1's internal data RAM Test.
+ 917508 | DSP0 internal program RAM test failure | MCH Module's Post Test results indicates that there was a failure in DSP0's internal program RAM Test.
+ 917509 | DSP1 internal program RAM test failure | MCH Module's Post Test results indicates that there was a failure in DSP1's internal program RAM Test.
+ 917510 | DSP0 external RAM test failure | MCH Module's Post Test results indicates that there was a failure in DSP0's external RAM Test.
+ 917511 | DSP1 external RAM test failure | MCH Module's Post Test results indicates that there was a failure in DSP1's external RAM Test.
+ 917512 | FPGA0 test failure | MCH Module's Post Test results indicates that there was a failure in FPGA0 Test.
+ 917513 | FPGA1 test failure | MCH Module's Post Test results indicates that there was a failure in FPGA1 Test.
+ 917514 | I2C test failure | MCH Module's Post Test results indicates that there was a failure in I2C Test.
+ 917515 | ViperTask startup delay detected | One or more ViperTask has a delay on startup, reporting readiness late.
+ 917516 | SysCommand_xxx symbol not found | One or more module's SysCommand_xxx() function symbol is not found. Check module loading logs.
+ 917517 | Critical Task suspension detected | Critical Task suspension from ModuleId %1 detected.
+ 917518 | Critical exit abnormally detected | Critical Task abnormally exited from ModuleID %1 detected.
+ 917519 | LoadModule failure | Loading module object codes had problems. Check startup logs.
+ 917761 | Non-Critical Task suspension detected | Non-Critical Task suspension from ModuleId %1 detected.
+ 917762 | Non-Critical exit abnormally detected | Non-Critical Task abnormally exited from ModuleID %1 detected.
+ 16711681 | Module booting up | Module %module is booting up now
+ 16711682 | Module shutting down | Module %module is shutting down now
+ 16711683 | Out of Internal Memory Error | The GSM Port ran out of memory. Module %module did not complete its intended operation. GSM Port must be rebooted to recover from this situation.
+ 16711684 | System Internal Error | GSM Port software system encountered an unexpected error, which resulted in data corruption. GSM Port must be rebooted to recover from this situation.
+ 16711685 | Reboot Started | The GSM Port is rebooting now.
+ 17039362 | GMC Link Down | Could not get a list of active GP10s from GMC. The link is down. Please verify if the GMC is up and running at the localhost
+ 17039617 | CBC Index File Read Failure | Either CBC index file is missing or it is not readable.
+ 17039618 | CBC Message File Read Failure | CBC message file could not be completely read and decoded. Some of the previously scheduled messages may have been lost.
+ 17236226 | ITP link is down | Verify: 1) network connection to ITP; 2) whether ITP is running
+ 17236227 | Roaming number not available | Add more roaming numbers
+ 17236229 | Can't save config file | Check available space on hard drive
+ 17236230 | Can't open config file | jcvbase.dat is missing or damaged. Note: created after first configuration changes
+ 17236228 | Duplicated GP CellID | Two GPs with the same CellID. Change CellID on GP. Check the error logs for details.
+ 17235970 | Internal failure to initialize | GMC can't initialize. Try power off reboot first. See error log for more details
+ 17236231 | GP Disconnected | Check GP status and network connection
+ 17236232 | Can't open translations data file for reading | Check if vnxlndb.dat is missing or has wrong permissions. vnxlndb.dat file is not needed if no previous translations data exists. It will be created after the first changes.
+ 17236233 | Error during translations data file read | vnxlndb.dat may be corrupted. Try to import a known good ASCII translations data file, if available, through the Translations Manager.
+ 17236234 | Can't open translations data file for writing | Check if vnxlndb.dat has wrong permissions. If not, try rebooting the GMC.
+ 17236235 | Can't save translations data file changes | Check available space on the hard drive. Try to export current data to an ASCII translations data file from the Translations Manager for backup. Try rebooting GMC if this failure is repeated. Try importing the backed up ASCII file after GMC reboot.
+ 17235971 | Can't get OS resources for Translations | Try rebooting the GMC.
+ 17236236 | IN link down | Check that the IN server and connectivity are Ok
+ 17236237 | No Heartbeat on IN link | Check that the IN server is OK
+ 17367042 | Tones&Announcements Application failed to initialize | Validate the configuration information for the Tones & Announcements.
+ 17367298 | Announcements configuration problem for Tones&Announcements. | (Either) no announcements are configured (or) Configuration data is incorrect. Ensure the name & presence of announcement files in the right directory(/sd0/gmc/IVR)
+ 17432578 | CDR Server failed to start off. | Ensure that SNMP daemon is running and initialized
+ 17432834 | CCS did not recognize CDR Server name. | Add this CDR/MNET name to CCS config file(cdr2.conf) and restart CCS.
+ 17432835 | The communication between CDR Server and CCS is lost. | Ensure that CCS is running.
+ 17436674 | File Tranmission problem between CDR Server and CCS.Retramsmitting file. | No correction mechanism required.
+ 17301506 | APM Server failed to start off. | Ensure that SNMP daemon is running and initialized
+ 17301762 | APM Server name not recognized by CAPS. | Add this APM/MNET name to CAPS through the CAM.
+ 17498113 | ViperTask startup delay detected | One or more ViperTask has a delay on startup, reporting readiness late.
+ 17498114 | SysCommand_xxx symbol not found | One or more module's SysCommand_xxx() function symbol is not found. Check module loading logs.
+ 17498115 | Critical Task suspension detected | Critical Task suspension from ModuleId %1 detected.
+ 17498116 | Critical exit abnormally detected | Critical Task abnormally exited from ModuleID %1 detected.
+ 17498117 | LoadModule failure | Loading module object codes had problems. Check startup logs.
+ 17498369 | Non-Critical Task suspension detected | Non-Critical Task suspension from ModuleId %1 detected.
+ 17498370 | Non-Critical exit abnormally detected | Non-Critical Task abnormally exited from ModuleID %1 detected.
+ 33488897 | Module booting up | Module %module is booting up now
+ 33488898 | Module shutting down | Module %module is shutting down now
+ 33488899 | Out of Internal Memory Error | The GSM Port ran out of memory. Module %module did not complete its intended operation. GSM Port must be rebooted to recover from this situation.
+ 33488900 | System Internal Error | GSM Port software system encountered an unexpected error, which resulted in data corruption. GSM Port must be rebooted to recover from this situation.
+ 33488901 | Reboot Started | The GSM Port is rebooting now. \ No newline at end of file
diff --git a/data/mnet/Common/Java/com/jetcell/MibWM/AlarmData.java b/data/mnet/Common/Java/com/jetcell/MibWM/AlarmData.java
new file mode 100644
index 0000000..403a8bb
--- /dev/null
+++ b/data/mnet/Common/Java/com/jetcell/MibWM/AlarmData.java
@@ -0,0 +1,216 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// Class : AlarmData
+// Desc :
+// Author : George Zhao
+// Hist : 06/17/1999 Initial Creation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+package com.jetcell.MibWM;
+
+import javax.swing.*;
+import javax.swing.table.*;
+import java.awt.event.*;
+import java.text.*;
+import java.awt.*;
+import java.util.*;
+public class AlarmData
+{
+ static int AlarmIndex = 0;
+
+ String alarmId;
+ String timestamp;
+ String severity;
+ String objectId;
+ String object;
+ String errorNo;
+ String subject;
+ String message;
+ Integer alarmIndex;
+ String optional1;
+ String optional2;
+ String acknowledge;
+ String recordNumber;
+ String srcIp;
+ static int NUM_REQUIRED_FIELDS = 8;
+ static int NUM_OPTIONAL_FIELDS = 3;
+ static int OP1 = 6;
+ static int OP2 = 7;
+ static int SRCIP = 8;
+ static int ACK = 9;
+ static int REC_NUM = 10;
+ static final String OP1Field = "%1";
+ static final String OP2Field = "%2";
+ static final String OPModule = "%module";
+ static String[] AlarmSeverity = { "Critical",
+ "Major",
+ "Minor",
+ "Information"
+ };
+
+ public static SimpleDateFormat formatter = new SimpleDateFormat( "yyyy/MM/dd HH:mm:ss z" );
+
+ public static SimpleDateFormat myFormatter = new SimpleDateFormat("dd.MM.yyyy/HH:mm:ss");
+
+ static final char dilim = '|';
+
+ public AlarmData( String alarmId, String timestamp, String severity,
+ String objectId, String object, String subject, String message)
+ {
+ this.alarmId = alarmId;
+ this.timestamp = timestamp;
+ this.severity = severity;
+ this.objectId = objectId;
+ this.object = object;
+ this.subject = subject;
+ this.message = message;
+ }
+
+ public AlarmData(String event) throws Exception
+ {
+ // event are in the format of:
+ // eventId|timestamp|severity|objectid|object name|event no |optional 1 |optional 2 | optional 3
+ String[] values = new String[NUM_REQUIRED_FIELDS+NUM_OPTIONAL_FIELDS];
+
+
+ int index = 0;
+ int pos = 0;
+ int i = 0;
+ boolean end = false;
+ while(!end)
+ {
+ index = event.indexOf(dilim, pos);
+ if (index == -1)
+ {
+ index = event.length();
+ end = true;
+ continue;
+ }
+ values[i++] = event.substring(pos,index);
+ pos = index+1;
+ }
+
+ try {
+ alarmId = values[0].trim();
+
+ timestamp = formatter.format(new Date(1000*Long.parseLong(Util.trimSpaces(values[1]))));
+ //timestamp = Util.trimSpaces(values[1]);
+ if(Util.debug)
+ {
+ System.out.println("values[1] " + values[1]);
+ System.out.println("Util.trimSpaces(values[1])) " + Util.trimSpaces(values[1]));
+ System.out.println("Long.parseLong(Util.trimSpaces(values[1])) " + Long.parseLong(Util.trimSpaces(values[1])));
+ Date d = new Date(1000*Long.parseLong(Util.trimSpaces(values[1])));
+ System.out.println("date " + d.toString());
+ System.out.println("date.gettime() "+d.getTime());
+ }
+
+ severity = AlarmSeverity[Integer.parseInt(Util.trimSpaces(values[2]))];
+ objectId = values[3].trim();
+ object = values[4];
+ errorNo = values[5].trim();
+ int error = Integer.parseInt(errorNo);
+ Vector alarmMsg = AlarmMessageMap.Get(error);
+ subject = (String) alarmMsg.elementAt(AlarmMessageMap.SUBJECT);
+ message = (String) alarmMsg.elementAt(AlarmMessageMap.MESSAGE);
+ alarmIndex = new Integer(AlarmIndex++);
+ subject = Replace(subject, object, OPModule);
+ message = Replace(message, object, OPModule);
+
+ optional1 = values[OP1].trim();
+ optional2 = values[OP2].trim();
+ srcIp = values[SRCIP].trim();
+ acknowledge = values[ACK].trim();
+ recordNumber = values[REC_NUM].trim();
+
+ if(values[OP1] != null)
+ {
+ optional1 = values[OP1];
+ subject = Replace(subject, optional1, OP1Field);
+ message = Replace(message, optional1, OP1Field);
+ }
+
+ if(values[OP2] != null)
+ {
+ optional2 = values[OP2];
+ subject = Replace(subject, optional2, OP2Field);
+ message = Replace(message, optional2, OP2Field);
+ }
+ }
+ catch(Exception e)
+ {
+ System.out.println("Invalid error No. " +errorNo);
+ e.printStackTrace();
+ throw e;
+ }
+ }
+
+
+ public Object getValueAt(int column)
+ {
+ switch (column)
+ {
+ case AlarmTableModel.ALARMID:
+ return alarmId;
+ case AlarmTableModel.TIMESTAMP:
+ return timestamp;
+ case AlarmTableModel.SEVERITY:
+ return severity;
+ case AlarmTableModel.OBJECT:
+ return object;
+ case AlarmTableModel.SUBJECT:
+ return subject;
+ default:
+ return "Unknown";
+ }
+ }
+
+ public void dump()
+ {
+ if(Util.debug)
+ {
+ System.out.println("Alarm ID : " +alarmId);
+ System.out.println("Timestamp : " +timestamp);
+ System.out.println("Severity : " +severity);
+ System.out.println("Object ID : " +objectId);
+ System.out.println("Object : " +object);
+ System.out.println("Error No : " +errorNo);
+ System.out.println("Subject : " +subject);
+ System.out.println("Message : " +message);
+ System.out.println("Optional1 : " +optional1);
+ System.out.println("Optional2 : " +optional2);
+ System.out.println("Index: " +alarmIndex);
+ }
+ }
+
+ String Replace(String field, String opfield, String op)
+ {
+ String message = null;
+ int pos = field.indexOf(op);
+ if(pos != -1) message = field.substring(0, pos) + opfield + field.substring(pos+op.length(), field.length());
+ else message = field;
+ return message;
+ }
+
+ public static void main(String[] argv)
+ {
+ // alarmId|timestamp|severity|objectId|objectName|error code|op 1| op 2
+ String event1="12323|10:23:34 1999|Critical|123|RRM|0|op1|op2";
+ String event2="12323|10:23:34 1999|Critical|123|RRM|1|op1";
+ String event3="12323|10:23:34 1999|Critical|123|RRM|2";
+
+ try {
+ AlarmData data = new AlarmData(event1);
+ data.dump();
+ data = new AlarmData(event2);
+ data.dump();
+ data = new AlarmData(event3);
+ data.dump();
+ }
+ catch(Exception e) {}
+ }
+
+}
+
+//$History:$
diff --git a/data/mnet/Common/Java/com/jetcell/MibWM/AlarmMessageMap.java b/data/mnet/Common/Java/com/jetcell/MibWM/AlarmMessageMap.java
new file mode 100644
index 0000000..939f006
--- /dev/null
+++ b/data/mnet/Common/Java/com/jetcell/MibWM/AlarmMessageMap.java
@@ -0,0 +1,131 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// Class : AlarmMessageMap
+// Desc :
+// Author : George Zhao
+// Hist : 06/17/1999 Initial Creation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+package com.jetcell.MibWM;
+
+import java.awt.event.*;
+import java.awt.*;
+import java.util.*;
+import java.io.*;
+import java.net.URL;
+import Java.AlarmApplet;
+
+abstract class AlarmMessageMap
+{
+ static String file = "Text/AlarmCode.English";
+ static String Comments = "//";
+ static String delim = "|";
+ static Hashtable alarmTable = null;
+ static final int SUBJECT = 0;
+ static final int MESSAGE = 1;
+ static final int VECTOR_SIZE= 2;
+ static final int LENGTH = 3;
+ static boolean readfile = false;
+
+ static String[] ErrorCode = {
+ "0|subect for alarm code 0| detail message for alarm code 0 wdsdsa fdsafdsafs adfdsa fdsafsad fsaf sadfdsaf sadfdsfsa fds dfsa asfa sfasf asdf sadfasfadf sa fasf asfa dsaf asasfdsafa a afasdfdsaf dsafds afitsdfsfdsafsdfsafjksa;lkfjsalkfjsaf;lksajfsaklfsa;lkfasjfa;lksjfsadlkfjas;lkfjsfalksfjsa;lkfjsafkljdsfkldsafjdskfjflksajflksfj;safjas;lfjsafjsaklfsajflkdsafjsalkfah optional field %1",
+ "1|subect for alarm code 1| detail message for alarm code 1 ddsfsdfsafsfaskf;lsjflsfskdl fjsalkfsaflksafwith optional field %1",
+ "2|subect for alarm code 2| detail message for alarm code 2 with optional field %1"
+ };
+
+
+ static Vector Get(long errorNo)
+ {
+ if (alarmTable == null)
+ {
+ Init();
+ }
+
+ Vector object = (Vector) alarmTable.get(new Long(errorNo));
+ if (object == null)
+ {
+ object = new Vector();
+ object.addElement(new String("No entry for data file for error code " +errorNo));
+ object.addElement(new String("No entry for data file for error code " +errorNo));
+ }
+ return object;
+ }
+
+ static void Init()
+ {
+ alarmTable = new Hashtable();
+ URL cfg_url;
+
+ try {
+ if(Util.applet != null) {
+ System.out.println("Running applet");
+ System.out.println("codebase : " + Util.applet.getCodeBase());
+ System.out.println("documentbase : " + Util.applet.getDocumentBase());
+ System.out.println("file : " + Util.applet.getCodeBase().getFile());
+ //BufferedReader in = new BufferedReader(new FileReader(new File(Util.applet.getDocumentBase().getFile(), file)));
+ cfg_url = new URL(Util.applet.getCodeBase()+file);
+ //cfg_url = new URL("http://"+ ((AlarmApplet)Util.applet).ip+"/"+file);
+ }
+ else {
+ System.out.println("Running application");
+ String sep = System.getProperty("file.separator");
+ String pwd = "file:"+".."+sep+"Text"+sep+"AlarmCode.English";
+ cfg_url = new URL(pwd);
+ }
+ System.out.println("Open File: " +cfg_url);
+ BufferedReader in = new BufferedReader(new InputStreamReader(cfg_url.openStream()));
+ String line = null;
+ while( (line = in.readLine()) != null)
+ {
+ ProcessErrorCode(line);
+ readfile = true;
+ }
+ }
+ catch(FileNotFoundException e)
+ {
+ System.out.println(e.toString());
+ System.out.println("Cannot open alarm code file " + file);
+ }
+ catch(IOException ex)
+ {
+ System.out.println("IO Exception: " + ex.toString());
+ }
+
+ if(!readfile)
+ {
+ for(int i=0; i< ErrorCode.length; i++)
+ {
+ ProcessErrorCode(ErrorCode[i]);
+ }
+ }
+ }
+
+ static void ProcessErrorCode(String line)
+ {
+ if(line.startsWith(Comments)) return;
+
+ StringTokenizer token = new StringTokenizer(line, delim);
+ if(token.countTokens() != LENGTH)
+ {
+ return;
+ }
+
+ Long errorNo = new Long(Util.trimSpaces(token.nextToken(delim)));
+ Vector alarmMsg = new Vector(VECTOR_SIZE);
+ alarmMsg.insertElementAt(token.nextToken(delim), SUBJECT);
+ alarmMsg.insertElementAt(token.nextToken(delim), MESSAGE);
+
+ alarmTable.put(errorNo, alarmMsg);
+ }
+
+ static void dump()
+ {
+ if(Util.debug)
+ for (Enumeration e = alarmTable.elements() ; e.hasMoreElements() ;) {
+ System.out.println(e.nextElement());
+ }
+ }
+
+}
+//$History:$
diff --git a/data/mnet/Common/Java/com/jetcell/MibWM/AlarmPanel.java b/data/mnet/Common/Java/com/jetcell/MibWM/AlarmPanel.java
new file mode 100644
index 0000000..192f3f0
--- /dev/null
+++ b/data/mnet/Common/Java/com/jetcell/MibWM/AlarmPanel.java
@@ -0,0 +1,467 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// Class : AlarmPanel
+// Desc :
+// Author : George Zhao
+// Hist : 04/27/1999 Initial Creation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+package com.jetcell.MibWM;
+
+import javax.swing.*;
+import javax.swing.table.*;
+import java.awt.event.*;
+import javax.swing.text.Document;
+import javax.swing.event.*;
+import java.net.UnknownHostException;
+import java.awt.*;
+import java.util.*;
+import rl.clbroker.Broker;
+import rl.clbroker.RlBeanProperty;
+import rl.clbroker.RlError;
+
+import FilterObject;
+import FilterFrame;
+import java.text.*;
+import AlarmStatusApplet;
+
+public class AlarmPanel implements DocumentListener,Cloneable{
+ static String host = null;
+ JPanel mainPanel = null;
+ AlarmTable alarmTable = null;
+
+ FilterObject filterObject = null;
+ int alarmFilterCount = 0;
+ Date filterDate = null;
+ Date alarmDate = null;
+ SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss z");
+ String viperCellIp = null; // gp10 ip for this panel.
+
+ private static JTextField eventField = null;
+
+ public AlarmPanel(){
+ filterObject = FilterFrame.filterObject;
+ AlarmMessageMap.Init();
+ /*
+ Thread t = new LoadFileThread();
+ t.start();
+ */
+ if(Util.applet == null)
+ {
+ System.out.println("Running as application");
+ Document doc = eventField.getDocument();
+ doc.addDocumentListener(this);
+ }
+ }
+
+ // Instantiated from another applet
+ public AlarmPanel(String viperbaseIp){
+ filterObject = FilterFrame.filterObject;
+ host = viperbaseIp;
+ AlarmMessageMap.Init();
+ }
+ public void setViperCellIp(String viperCell){
+ this.viperCellIp = viperCell;
+ alarmTable.setViperCellIp(viperCell);
+ }
+
+ public AlarmTable getAlarmTable(){
+ return alarmTable;
+ }
+ public JPanel createPanel(){
+ JPanel panel;
+ panel = Util.makeBorderPanel("Alarm List");
+ //Ananth
+ /*if (filterObject.NUM_ALARMS == FilterObject.NONE &&
+ filterObject.SEVERITY == FilterObject.NULL &&
+ filterObject.TIME == FilterObject.NONE &&
+ filterObject.ACKNOWLEDGE == FilterObject.NONE){
+ panel = Util.makeBorderPanel("Alarm List");
+ }
+ else{
+ panel = Util.makeBorderPanel("Alarm List (Filtered)");
+ }*/
+ panel.setLayout(new BorderLayout());
+ AlarmTableModel model = new AlarmTableModel();
+ alarmTable = new AlarmTable(model);
+ alarmTable.setViperCellIp(viperCellIp);
+ JScrollPane scroller= new JScrollPane( alarmTable,
+ JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED ,
+ JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
+ panel.add(scroller, BorderLayout.CENTER);
+
+ if (host == null) // applet is run against GP10 instead of GMC
+ alarmTable.Refresh();
+ return panel;
+ }
+
+ public void removeRows(int start,int end){
+ DefaultTableModel model = (DefaultTableModel)alarmTable.getSorter().getModel();
+ AlarmTableSorter sorter = alarmTable.getSorter();
+ int row = 0;
+ int indexAtRow = 0;
+ AlarmStatusApplet.logDM("Row : " + row + " Index : " + indexAtRow);
+
+ for(int i = 0;i < (end-start); i++){
+ row = model.getRowCount();
+ indexAtRow = alarmTable.getSorter().getIndexAtRow(row-1);
+ AlarmStatusApplet.logDM("Row : " + row + " Index : " + indexAtRow);
+ sorter.filteredRemoveRow(row-1);
+ }
+ }
+
+
+ public void handleFilterEvent(FilterObject filter){
+
+ DefaultTableModel model = (DefaultTableModel)alarmTable.getModel();
+ AlarmTableSorter sorter = alarmTable.getSorter();
+ this.filterObject = filter;
+ int rowCount = model.getRowCount();
+ String severity = null;
+ String date = null;
+ Boolean acknowledge = null;
+
+ // filtering num of Alarms
+ if(filterObject.NUM_ALARMS != FilterObject.NONE){
+ AlarmStatusApplet.logDM("Filtering num: of Alarms");
+ if(rowCount > filterObject.NUM_ALARMS){
+ AlarmStatusApplet.logDM("Filtering no: of Alarms");
+ removeRows(filterObject.NUM_ALARMS,rowCount);
+ }
+ }
+
+ int newRowCount = model.getRowCount();
+ MyCalendar myCalendar = new MyCalendar();
+ filterDate = myCalendar.calculateDate();
+
+
+ for(int i=0;i<newRowCount;i++){
+ // filtering Severity
+ if(!filterObject.SEVERITY.equals(FilterObject.NULL)){
+ AlarmStatusApplet.logDM("Filtering severity");
+ severity = (String)model.getValueAt(i,AlarmTableModel.SEVERITY);
+ if(filterObject.SEVERITY.equals(FilterObject.CRITICAL)){
+ if(!severity.toUpperCase().equals(filterObject.CRITICAL)){
+ sorter.filteredRemoveRow(i);
+ i--;
+ newRowCount--;
+ continue;
+ }
+ }
+ else if(filterObject.SEVERITY.equals(FilterObject.MAJOR)){
+ if(!(severity.toUpperCase().equals(filterObject.CRITICAL)
+ || severity.toUpperCase().equals(filterObject.MAJOR))){
+ sorter.filteredRemoveRow(i);
+ i--;
+ newRowCount--;
+ continue;
+ }
+ }
+ else if(filterObject.SEVERITY.equals(FilterObject.MINOR)){
+ if(!(severity.toUpperCase().equals(filterObject.CRITICAL)
+ || severity.toUpperCase().equals(filterObject.MAJOR)
+ || severity.toUpperCase().equals(filterObject.MINOR))){
+ sorter.filteredRemoveRow(i);
+ i--;
+ newRowCount--;
+ continue;
+ }
+ }
+
+ }
+
+ // filtering Date/Time
+ if(!(filterObject.TIME == FilterObject.NONE)){
+ AlarmStatusApplet.logDM("Checking timestamp");
+ date = (String)model.getValueAt(i,AlarmTableModel.TIMESTAMP);
+ try{
+ alarmDate = formatter.parse(date);
+ }
+ catch(ParseException ex){
+ System.out.println("Cudn't parse date ...");
+ }
+ if(!alarmDate.after(filterDate)){
+ sorter.filteredRemoveRow(i);
+ i--;
+ newRowCount--;
+ continue;
+ }
+ }
+
+ // filtering Ack
+ if(!(filterObject.ACKNOWLEDGE == FilterObject.NONE)){
+ AlarmStatusApplet.logDM("Filtering ack");
+ acknowledge = (Boolean)model.getValueAt(i,AlarmTableModel.ACK);
+ if(filterObject.ACKNOWLEDGE == FilterObject.NO_ACK){
+ if(acknowledge.booleanValue()){
+ sorter.filteredRemoveRow(i);
+ i--;
+ newRowCount--;
+ }
+ continue;
+ }
+ else if(filterObject.ACKNOWLEDGE == FilterObject.ALL_ACK){
+ if(!acknowledge.booleanValue()){
+ sorter.filteredRemoveRow(i);
+ i--;
+ newRowCount--;
+ }
+ continue;
+ }
+ }
+ } // end "for loop"
+
+ // addEvent(alarm);
+ }
+
+ public void addEvent(AlarmData alarm){
+ String severity;
+ Boolean acknowledge;
+ int ack;
+ String date;
+ DefaultTableModel model = (DefaultTableModel)alarmTable.getModel();
+
+ if(filterObject != null){
+
+ // filtering Severity
+ if(!filterObject.SEVERITY.equals(FilterObject.NULL)){
+ AlarmStatusApplet.logDM("Filtering severity");
+ severity = alarm.severity;
+ if(filterObject.SEVERITY.equals(FilterObject.CRITICAL)){
+ if(!severity.toUpperCase().equals(filterObject.CRITICAL)){
+ return;
+ }
+ }
+ else if(filterObject.SEVERITY.equals(FilterObject.MAJOR)){
+ if(!(severity.toUpperCase().equals(filterObject.CRITICAL)
+ || severity.toUpperCase().equals(filterObject.MAJOR))){
+ return;
+ }
+ }
+ else if(filterObject.SEVERITY.equals(FilterObject.MINOR)){
+ if(!(severity.toUpperCase().equals(filterObject.CRITICAL)
+ || severity.toUpperCase().equals(filterObject.MAJOR)
+ || severity.toUpperCase().equals(filterObject.MINOR))){
+ return;
+ }
+ }
+ }
+
+ // filtering Ack
+ ack = Integer.parseInt(alarm.acknowledge);
+ if(ack == 0){
+ acknowledge = new Boolean(false);
+ }
+ else{
+ acknowledge = new Boolean(true);
+ }
+ if(!(filterObject.ACKNOWLEDGE == FilterObject.NONE)){
+ AlarmStatusApplet.logDM("Filtering ack");
+ if(filterObject.ACKNOWLEDGE == FilterObject.NO_ACK){
+ if(acknowledge.booleanValue()){
+ return;
+ }
+ }
+ else if(filterObject.ACKNOWLEDGE == FilterObject.ALL_ACK){
+ if(!acknowledge.booleanValue()){
+ return;
+ }
+ }
+ }
+
+ // filtering Date/Time
+ MyCalendar myCalendar = new MyCalendar();
+ filterDate = myCalendar.calculateDate();
+
+ if(!(filterObject.TIME == FilterObject.NONE)){
+
+ AlarmStatusApplet.logDM("Checking timestamp");
+ date = alarm.timestamp;
+ try{
+ alarmDate = formatter.parse(date);
+ }
+ catch(ParseException ex){
+ System.out.println("Cudn't parse date ...");
+ }
+ if(!alarmDate.after(filterDate)){
+ return;
+ }
+ }
+
+ // Shrinivas 05 jun 01'
+ // filtering NUM_ALARMS
+ if(filterObject.NUM_ALARMS != FilterObject.NONE){
+ int rowCount = model.getRowCount();
+ AlarmStatusApplet.logDM("Filtering num: of Alarms");
+ if(rowCount > filterObject.NUM_ALARMS-1){
+ AlarmStatusApplet.logDM("Filtering no: of Alarms");
+ removeRows(filterObject.NUM_ALARMS-1,rowCount);
+ }
+ }
+ // Shrinivas end
+ }
+
+
+ Object [] row = new Object[AlarmTableModel.NUM_COL];
+ row[AlarmTableModel.INDEX] = alarm.alarmIndex;
+ row[AlarmTableModel.READ] = new Boolean(false);
+ row[AlarmTableModel.ALARMID] = alarm.alarmId;
+ row[AlarmTableModel.TIMESTAMP] = alarm.timestamp;
+ row[AlarmTableModel.SEVERITY] = alarm.severity;
+ row[AlarmTableModel.OBJECT] = alarm.object;
+ row[AlarmTableModel.SUBJECT] = alarm.subject;
+
+ if(Integer.parseInt(alarm.acknowledge) == 0)
+ row[AlarmTableModel.ACK] = new Boolean(false);
+ else
+ row[AlarmTableModel.ACK] = new Boolean(true);
+
+ ((DefaultTableModel)alarmTable.getModel()).insertRow(0, row);
+ alarmTable.setAlarmData(alarm);
+
+ }
+
+ public void removeAllEvents()
+ {
+ while (((DefaultTableModel)alarmTable.getModel()).getRowCount() > 0)
+ ((DefaultTableModel)alarmTable.getModel()).removeRow(0);
+ }
+
+ static public void main(String[] argv)
+ {
+ eventField = new JTextField();
+ host = argv[0];
+ try
+ {
+ boolean useTCP = true;
+ int portNum = 80;
+ int maxLen = 4096;
+
+ System.out.println("Connect to " + host + " prot " +portNum);
+ Broker.setOptions(host, portNum, maxLen, useTCP);
+
+ }
+ catch(UnknownHostException e) { e.printStackTrace(); }
+ Broker.addMagicMarkup("QSEvent", "java.lang.String", false);
+ RlBeanProperty beanProp = Broker.wrapBeanProperty(eventField, "text", java.lang.String.class);
+ Broker.bindMarkupToBeanProperty("QSEvent", "", null, beanProp, true, false, true, null);
+ Broker.start();
+ JFrame f = new JFrame("ViperCell Event List");
+ f.addWindowListener(new WindowAdapter() {
+ public void windowClosing(WindowEvent e)
+ {
+ System.exit(1);
+ }
+ });
+ f.getContentPane().setLayout(new BorderLayout());
+ AlarmPanel base = new AlarmPanel();
+ f.getContentPane().add(base.createPanel());
+ f.setBounds(0,0, 720,400);
+ try
+ {
+ UIManager.setLookAndFeel( "com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
+ SwingUtilities.updateComponentTreeUI(f);
+ }
+ catch(Exception ex)
+ {
+ Util.showDialog(f, ex.toString(), "Error", JOptionPane.ERROR_MESSAGE);
+ }
+ f.setVisible(true);
+
+ /*
+ Random r = new Random();
+ Calendar d = Calendar.getInstance();
+
+ String severity = null;
+
+ for(int i=0; i<20; i++)
+ {
+ try {
+ d.add(Calendar.SECOND, java.lang.Math.abs(r.nextInt()));
+ if (i-i/3*3 == 0)
+ severity = new String("Critical");
+ else if (i-i/3 == 1)
+ severity = new String("Minor");
+ else if (i - i/3*3 == 2)
+ severity = new String("Info");
+ String date = d.getTime().toString();
+ String object = "Object_"+String.valueOf(java.lang.Math.abs(r.nextInt()));
+ String message = " Event messages ....";
+
+ AlarmData alarm = new AlarmData(String.valueOf(i), date, severity, null, object, message, null);
+ base.addEvent(alarm);
+ Thread.sleep(10000);
+ System.out.println("Event: " +i);
+ }
+ catch(Exception e)
+ {}
+ }
+ */
+
+
+ }
+
+ public void changedUpdate(DocumentEvent e)
+ {
+ }
+
+ public void insertUpdate(DocumentEvent e)
+ {
+ String alarmId = eventField.getText();
+ alarmId.trim();
+ System.out.println("Receiving Alarm: " + alarmId);
+
+ if(!alarmId.startsWith("Event Number"))
+ {
+ try {
+ AlarmData alarm = new AlarmData(alarmId);
+ addEvent(alarm);
+ }
+ catch(Exception ex) {}
+ }
+ }
+
+ public void removeUpdate(DocumentEvent e)
+ {
+ }
+
+ class LoadFileThread extends Thread
+ {
+ public void run()
+ {
+ AlarmMessageMap.Init();
+ }
+ }
+
+ class MyCalendar extends GregorianCalendar{
+
+ public Date calculateDate(){
+
+ MyCalendar myCalen = new MyCalendar();
+ long currentMillis = myCalen.getTimeInMillis();
+ long temp;
+ Date pDate = null;
+
+ if(filterObject.TIME == FilterObject.MIN_15){
+ temp = 15 * 60 * 1000;
+ pDate = new Date(currentMillis - temp);
+ }
+ else if(filterObject.TIME == FilterObject.HR_1){
+ temp = 60 * 60 * 1000;
+ pDate = new Date(currentMillis - temp);
+ }
+ else if(filterObject.TIME == FilterObject.HR_12){
+ temp = (12 * 60 ) * 60 * 1000;
+ pDate = new Date(currentMillis - temp);
+ }
+ else if(filterObject.TIME == FilterObject.HR_24){
+ temp = (24 * 60 ) * 60 * 1000;
+ pDate = new Date(currentMillis - temp);
+ }
+ return pDate;
+ }
+ }
+}
+
+//$History:$
diff --git a/data/mnet/Common/Java/com/jetcell/MibWM/AlarmTable.java b/data/mnet/Common/Java/com/jetcell/MibWM/AlarmTable.java
new file mode 100644
index 0000000..1e5490d
--- /dev/null
+++ b/data/mnet/Common/Java/com/jetcell/MibWM/AlarmTable.java
@@ -0,0 +1,588 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// Class : AlarmTable
+// Desc :
+// Author : George Zhao
+// Hist : 06/17/1999 Initial Creation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+package com.jetcell.MibWM;
+
+import java.awt.event.*;
+import javax.swing.*;
+import javax.swing.table.*;
+import javax.swing.event.*;
+import java.util.Hashtable;
+import java.awt.*;
+import java.io.*;
+import java.awt.image.*;
+import java.net.*;
+import AlarmTCPThread;
+
+public class AlarmTable extends JTable {
+
+ DefaultTableModel model;
+ JPopupMenu popupMenu = null;
+
+ final int [] columnMinWidth = {25, 30, 150, 50, 80, 250, 0,25};
+ final int [] columnMaxWidth = {40, 60, 200, 100, 150, 800, 0,40};
+
+ AlarmTableSorter sorter = null;
+ Hashtable alarmHashTable = null;
+ DetailFrame detailFrame = new DetailFrame();
+ String viperCellIp = null;
+
+ public AlarmTable(DefaultTableModel model)
+ {
+ super(model);
+ popupMenu = AlarmTablePopupMenu.getPopupMenu();
+
+ sorter = new AlarmTableSorter(model);
+ super.setModel( sorter );
+ addMouseListener(new MouseHandler(this));
+ alarmHashTable = new Hashtable();
+ for (int i=0; i < model.getColumnCount(); i++ )
+ setColumnWidth(i, columnMinWidth[i], columnMaxWidth[i]);
+ TableColumnModel colModel = getColumnModel();
+ colModel.getColumn(AlarmTableModel.READ).setCellRenderer(new ReadCellRenderer());
+ colModel.getColumn(AlarmTableModel.SEVERITY).setCellRenderer(new SeverityRenderer());
+ colModel.getColumn(AlarmTableModel.ACK).setCellRenderer(new ReadCellRenderer());
+
+ setRowSelectionAllowed(true);
+ setColumnSelectionAllowed(false);
+ setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
+ setShowGrid(true);
+ setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
+ setShowVerticalLines(false);
+ setGridColor(new Color(153,153,255));
+ }
+
+
+ public AlarmTableSorter getSorter(){
+ return this.sorter;
+ }
+ public void setViperCellIp(String viperCell){
+ this.viperCellIp = viperCell;
+ }
+
+ public void setColumnWidth(int columnIndex, int minWidth, int maxWidth)
+ {
+ TableColumn column = (TableColumn)getColumn(getColumnName(columnIndex));
+
+ column.setMinWidth(minWidth);
+ column.setMaxWidth(maxWidth);
+ }
+
+ public boolean isCellEditable(int i, int j)
+ {
+ return false;
+ }
+
+
+ public AlarmData getAlarmData(Integer index)
+ {
+ if (alarmHashTable != null)
+ return (AlarmData) alarmHashTable.get(index);
+ return null;
+ }
+
+ public void setAlarmData(AlarmData alarmdata){
+ if(AlarmMessageMap.readfile){
+ alarmHashTable.put(alarmdata.alarmIndex, alarmdata);
+ }
+ }
+
+ public void OpenEvent()
+ {
+ Integer index = (Integer)getValueAt(getSelectedRow(), AlarmTableModel.INDEX);
+ System.out.println("Open Event: " +index);
+ AlarmData data = (AlarmData) alarmHashTable.get(index);
+ data.dump();
+ detailFrame.setData(data);
+ Dimension d = new JFrame().getToolkit().getScreenSize();
+ detailFrame.setLocation(d.width/4,d.height/3);
+ detailFrame.setResizable(false);
+ if(Util.applet == null){
+ detailFrame.setIconImage(Toolkit.getDefaultToolkit().getImage("../Images/app_icon.gif"));
+ }
+ else{
+ String iconPath = Util.applet.getCodeBase().toString();
+ iconPath += "Images/app_icon.gif";
+ URL iconPathURL = null;
+ try{
+ iconPathURL = new URL(iconPath);
+ }
+ catch(MalformedURLException exc){
+ System.out.println("Bad URL.");
+ }
+ System.out.println(iconPathURL);
+ detailFrame.setIconImage(Toolkit.getDefaultToolkit().getImage(iconPathURL));
+ }
+ //detailFrame.setIconImage(Toolkit.getDefaultToolkit().getImage("../Images/app_icon.gif"));
+ detailFrame.setVisible(true);
+ setValueAt(new Boolean(true), getSelectedRow(), AlarmTableModel.READ);
+ }
+
+ public void RemoveAllEvents()
+ {
+ System.out.println("Remove All");
+ while( getRowCount()> 0)
+ {
+ ((DefaultTableModel) getModel()).removeRow(0);
+ }
+ }
+
+ public void RemoveInfoEvents()
+ {
+ System.out.println("Remvoe Info");
+ sorter.reallocateIndexes();
+ sorter.sortByColumn(AlarmTableModel.ALARMID, false);
+ for (int i=0; i< getRowCount(); i++)
+ {
+ if (((String) getValueAt(i, AlarmTableModel.SEVERITY)).equals("Info"))
+ {
+ System.out.println("removing row " + i);
+ ((DefaultTableModel) getModel()).removeRow(i);
+ }
+ }
+ }
+
+ public void RemoveReadEvents()
+ {
+ System.out.println("RemoveRead");
+ sorter.reallocateIndexes();
+ sorter.sortByColumn(AlarmTableModel.READ, false);
+ for (int i=0; i< getRowCount(); i++)
+ {
+ if (((Boolean) getValueAt(i, AlarmTableModel.READ)).booleanValue())
+ {
+ System.out.println("removing row " + i);
+ ((DefaultTableModel) getModel()).removeRow(i);
+ i--;
+ }
+ }
+ }
+
+ public void RemoveEvent()
+ {
+ String alarmId = (String)getValueAt(getSelectedRow(), AlarmTableModel.INDEX);
+ System.out.println("Remove Event: " +alarmId);
+ sorter.reallocateIndexes();
+ sorter.sortByColumn(AlarmTableModel.ALARMID, false);
+ for (int i=0; i< getRowCount(); i++)
+ {
+ if (((String) getValueAt(i, AlarmTableModel.INDEX)).equals(alarmId))
+ {
+ System.out.println("removing row " + i);
+ ((DefaultTableModel) getModel()).removeRow(i);
+ break;
+ }
+ }
+ }
+
+
+ public void Refresh(){
+ RemoveAllEvents();
+ java.net.URL cfg_url = null;
+
+ // Shrinivas Feb 28th
+ AlarmTCPThread.sendEventReq(viperCellIp);
+
+ /*if(Util.applet == null){
+ AlarmTCPThread.sendEventReq(viperCellIp);
+ }
+ // original applet code : Refresh logic as it was before
+ else{
+ try {
+ if(Util.applet != null)
+ cfg_url = new java.net.URL(Util.applet.getDocumentBase()+"Text/alarm.log");
+ else
+ cfg_url = new java.net.URL("http://"+AlarmPanel.host+"/Text/alarm.log");
+ System.out.println("Open File: " +cfg_url);
+ java.io.BufferedReader in = new java.io.BufferedReader(new InputStreamReader(cfg_url.openStream()));
+ String line = null;
+ while( (line = in.readLine()) != null){
+ try {
+ System.out.println("Line : " +line);
+ AlarmData alarm = new AlarmData(line);
+ setAlarmData(alarm);
+ Object [] row = new Object[AlarmTableModel.NUM_COL];
+ row[AlarmTableModel.INDEX] = alarm.alarmIndex;
+ row[AlarmTableModel.READ] = new Boolean(false);
+ row[AlarmTableModel.ALARMID] = alarm.alarmId;
+ row[AlarmTableModel.TIMESTAMP] = alarm.timestamp;
+ row[AlarmTableModel.SEVERITY] = alarm.severity;
+ row[AlarmTableModel.OBJECT] = alarm.object;
+ row[AlarmTableModel.SUBJECT] = alarm.subject;
+
+ ((DefaultTableModel)getModel()).insertRow(0, row);
+ }
+ catch(Exception ex) {}
+ }
+ }
+ catch(FileNotFoundException e){
+ System.out.println(e.toString());
+ System.out.println("Cannot open alarm code file Text/alarm.log");
+ }
+ catch(IOException ex){
+ System.out.println("IO Exception: " + ex.toString());
+ }
+ }*/
+
+ // Shrinivas end
+ }
+
+ public void Acknowledge(){
+ Integer index = (Integer)getValueAt(getSelectedRow(), AlarmTableModel.INDEX);
+ AlarmData data = (AlarmData) alarmHashTable.get(index);
+ if(data == null)
+ System.out.println("unable to get Alarm data");
+ AlarmTCPThread.sendAck(data.srcIp,data.alarmId,data.recordNumber);
+ setValueAt(new Boolean(true), getSelectedRow(), AlarmTableModel.ACK);
+ }
+
+ class MouseHandler extends MouseAdapter
+ {
+ AlarmTable holder = null;
+ public MouseHandler(AlarmTable table){
+ this.holder = table;
+ }
+ public void mouseReleased(MouseEvent e){
+ if (e.getClickCount() == 2 )
+ {
+ System.out.println("Process Double click");
+ OpenEvent();
+ }
+
+ if ( e.isPopupTrigger()){
+ int selectedRow = rowAtPoint(new Point(e.getX(),e.getY()));
+ setRowSelectionInterval(selectedRow,selectedRow);
+
+ popupMenu.show(holder, e.getX(), e.getY());
+ }
+ }
+ }
+
+ class ReadCellRenderer extends JCheckBox implements TableCellRenderer
+ {
+ Color mHighlightedBackground = (Color) (new Color(0, 0, 255)).darker().darker();
+ Color mDefaultBackground = SystemColor.window;
+ public ReadCellRenderer()
+ {
+ setBackground(Color.white);
+ setHorizontalAlignment(JLabel.CENTER);
+ }
+
+ public Component getTableCellRendererComponent( JTable table,
+ Object value,
+ boolean isSelected,
+ boolean hasFocus,
+ int row,
+ int column )
+ {
+ Boolean b = (Boolean) value;
+
+ if(b != null){
+ setSelected(b.booleanValue());
+
+ }
+
+ return this;
+ }
+ }
+
+ class SeverityRenderer extends JLabel implements TableCellRenderer
+ {
+ Color mHighlightedBackground = (Color) (new Color(0, 0, 255)).darker().darker();
+ Color mDefaultBackground = SystemColor.window;
+ Font defaultFont = new Font("Helvetica", Font.BOLD,12);
+ Font empFont = new Font("TimesRoman", Font.BOLD,18);
+ ImageIcon severityIcon = null;
+ ImageIcon criticalIcon = null;
+ ImageIcon majorIcon = null;
+ ImageIcon minorIcon = null;
+ ImageIcon infoIcon = null;
+
+ public SeverityRenderer(){
+ super("");
+ loadIcons();
+ setHorizontalAlignment(JLabel.CENTER);
+ }
+
+ private void loadIcons(){
+ String fileSep = System.getProperty("file.separator");
+ String codeBase = null;
+ String imagePath = "file:" +".."+fileSep+"Images"+fileSep;
+ String imageFile = null;
+ if(Util.applet != null){
+ codeBase = Util.applet.getCodeBase().toString();
+ System.out.println(codeBase);
+ }
+ try{
+ if(Util.applet != null){
+ imageFile = codeBase + "Images/scritical.gif";
+ }
+ else{
+ imageFile = imagePath+"scritical.gif";
+ }
+ criticalIcon = new ImageIcon(new URL(imageFile));
+
+ if(Util.applet != null){
+ imageFile = codeBase + "Images/smajor.gif";
+ }
+ else
+ imageFile = imagePath+"smajor.gif";
+ majorIcon = new ImageIcon(new URL(imageFile));
+
+ if(Util.applet != null){
+ imageFile = codeBase + "Images/sminor.gif";
+ }
+ else
+ imageFile = imagePath+"sminor.gif";
+ minorIcon = new ImageIcon(new URL(imageFile));
+
+ if(Util.applet != null){
+ imageFile = codeBase + "Images/sinformation.gif";
+ }
+ else
+ imageFile = imagePath + "sinformation.gif";
+ infoIcon = new ImageIcon(new URL(imageFile));
+ }
+ catch(MalformedURLException malEx){
+ System.out.println("Bad URL");
+ }
+ }
+
+ public Component getTableCellRendererComponent( JTable table,
+ Object value,
+ boolean isSelected,
+ boolean hasFocus,
+ int row,
+ int column ){
+
+ String severity = (String) value;
+
+ if(value != null){
+ if(severity.equals(AlarmData.AlarmSeverity[0])) {
+ setIcon(criticalIcon);
+ criticalIcon.setImageObserver(new CellImageObserver(table, row, column));
+ }
+ else if(severity.equals(AlarmData.AlarmSeverity[1])){
+ setIcon(majorIcon);
+ majorIcon.setImageObserver(new CellImageObserver(table, row, column));
+ }
+ else if (severity.equals(AlarmData.AlarmSeverity[2])){
+ setIcon(minorIcon);
+ minorIcon.setImageObserver(new CellImageObserver(table, row, column));
+ }
+ else if (severity.equals(AlarmData.AlarmSeverity[3])){
+ setIcon(infoIcon);
+ infoIcon.setImageObserver(new CellImageObserver(table, row, column));
+ }
+ }
+
+ if (isSelected){
+ setBackground(mHighlightedBackground);
+ }
+ else{
+ setBackground(mDefaultBackground);
+ }
+
+ return this;
+ }
+ }
+
+ class CellImageObserver implements ImageObserver {
+ JTable table;
+ int row;
+ int col;
+
+ CellImageObserver(JTable table,int row, int col) {
+ this.table = table;
+ this.row = row;
+ this.col = col;
+ }
+
+ public boolean imageUpdate(Image img, int flags,int x, int y, int w, int h){
+ if ((flags & (FRAMEBITS|ALLBITS)) != 0) {
+ Rectangle rect = table.getCellRect(row,col,false);
+ table.repaint(rect);
+ }
+ return (flags & (ALLBITS|ABORT)) == 0;
+ }
+ }
+
+
+ class DetailFrame extends JFrame implements ActionListener
+ {
+ JPanel mainPanel = null;
+ final int WIDTH = 520;
+ final int HEIGHT = 360;
+ final int rows = 4;
+ final int columns = 40;
+
+ JTextField alarmIdField = Util.makeTextField(false);
+ JTextField severityField = Util.makeTextField(false);
+ JTextField timestampField = Util.makeTextField(false);
+ JTextField objectField = Util.makeTextField(false);
+ JTextField subjectField = Util.makeTextField(false);
+ JTextArea messageArea = Util.makeTextArea(rows, columns, false);
+ JButton closeButton = new JButton("Close");
+
+ public DetailFrame ()
+ {
+ mainPanel = createPanel();
+ getContentPane().add(mainPanel, BorderLayout.CENTER);
+ pack();
+ setSize(getPreferredSize());
+ addWindowListener(new WindowAdapter() {
+ public void windowClosing(WindowEvent e)
+ {
+ close();
+ }
+ });
+ closeButton.addActionListener(this);
+ try
+ {
+ UIManager.setLookAndFeel( "com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
+ SwingUtilities.updateComponentTreeUI(this);
+ }
+ catch(Exception ex)
+ {
+ Util.showDialog(this, ex.toString(), "Error", JOptionPane.ERROR_MESSAGE);
+ }
+ }
+
+ public JPanel createPanel()
+ {
+ JPanel panel = Util.makeBorderPanel();
+ panel.setLayout(new BorderLayout(0, 0));
+ panel.add(makeDetailPanel(), BorderLayout.CENTER);
+ panel.add(makeMessagePanel(), BorderLayout.SOUTH);
+ return panel;
+ }
+
+ JPanel makeDetailPanel()
+ {
+ JPanel panel = Util.makeBorderPanel("Event Data");
+ GridBagConstraints gbc;
+ GridBagLayout gridbag = new GridBagLayout();
+ gbc = new GridBagConstraints();
+ JLabel label;
+ panel.setLayout(gridbag);
+
+ label = new JLabel("Event ID ", JLabel.RIGHT);
+ label.setToolTipText("Alarm ID");
+ Util.constrain(label, panel, gbc, 0,0,1,1,
+ GridBagConstraints.VERTICAL,GridBagConstraints.WEST,
+ 0.0,0.0,0,5,5,0);
+
+ Util.constrain(alarmIdField, panel, gbc, 1,0,1,1,
+ GridBagConstraints.HORIZONTAL,GridBagConstraints.WEST,
+ 100.0,100.0,0,5,5,0);
+
+ label = new JLabel("Severity ",JLabel.RIGHT);
+ label.setToolTipText("Severity of the Event");
+ Util.constrain(label, panel, gbc, 2,0,1,1,
+ GridBagConstraints.VERTICAL,GridBagConstraints.WEST,
+ 0.0,0.0,0,5,5,0);
+
+ Util.constrain(severityField, panel, gbc, 3,0,1,1,
+ GridBagConstraints.HORIZONTAL,GridBagConstraints.WEST,
+ 100.0,100.0,0,5,5,0);
+
+ label = new JLabel("Time Stamp ",JLabel.RIGHT);
+ label.setToolTipText("Event time stamp");
+ Util.constrain(label, panel, gbc, 0,1,1,1,
+ GridBagConstraints.VERTICAL,GridBagConstraints.WEST,
+ 0.0,0.0,0,5,5,0);
+
+ Util.constrain(timestampField, panel, gbc, 1,1,1,1,
+ GridBagConstraints.HORIZONTAL,GridBagConstraints.WEST,
+ 100.0,100.0,0,5,5,0);
+
+ label = new JLabel("Object ",JLabel.RIGHT);
+ label.setToolTipText("Name of the object that generated this event");
+ Util.constrain(label, panel, gbc, 2,1,1,1,
+ GridBagConstraints.VERTICAL,GridBagConstraints.WEST,
+ 0.0,0.0,0,5,5,0);
+
+ Util.constrain(objectField, panel, gbc, 3,1,1,1,
+ GridBagConstraints.HORIZONTAL,GridBagConstraints.WEST,
+ 100.0,100.0,0,5,5,0);
+
+ label = new JLabel("Subject ",JLabel.RIGHT);
+ label.setToolTipText("Subject of the Event");
+ Util.constrain(label, panel, gbc, 0,2,1,1,
+ GridBagConstraints.VERTICAL,GridBagConstraints.WEST,
+ 0.0,0.0,0,5,5,0);
+
+ Util.constrain(subjectField, panel, gbc, 1,2,3,1,
+ GridBagConstraints.HORIZONTAL,GridBagConstraints.WEST,
+ 100.0,100.0,0,5,5,0);
+
+
+ return panel;
+ }
+
+ JPanel makeMessagePanel()
+ {
+ JPanel panel = Util.makeEmptyBorderPanel();
+ panel.setLayout(new BorderLayout(0,0));
+ panel.add(messageAreaPanel(), BorderLayout.CENTER);
+ panel.add(makeButtonPanel(), BorderLayout.SOUTH);
+ return panel;
+ }
+
+ JPanel messageAreaPanel()
+ {
+ JPanel panel = Util.makeBorderPanel("Message");
+ panel.setLayout(new BorderLayout(0,0));
+ messageArea.setLineWrap(true);
+ messageArea.setWrapStyleWord(true);
+ JScrollPane scroller = new JScrollPane(messageArea);
+ panel.add(scroller, BorderLayout.CENTER);
+ return panel;
+ }
+
+ JPanel makeButtonPanel()
+ {
+ JPanel panel = new JPanel();
+ panel.setLayout(new FlowLayout());
+ panel.add(closeButton);
+ return panel;
+ }
+
+ public Dimension getPreferredSize()
+ {
+ return new Dimension(WIDTH, HEIGHT);
+ }
+
+ public void actionPerformed(ActionEvent event)
+ {
+
+ Object obj = event.getSource();
+ if (obj == closeButton)
+ close();
+ }
+
+ public void close()
+ {
+ setVisible(false);
+ }
+
+ public void setData(AlarmData data)
+ {
+ setTitle("Event Detail for Event Id: " +data.alarmId);
+ alarmIdField.setText(data.alarmId);
+ severityField.setText(data.severity);
+ timestampField.setText(data.timestamp);
+ objectField.setText(data.object);
+ subjectField.setText(data.subject);
+ messageArea.setText(data.message);
+ }
+ }
+
+}
+//$History:$
diff --git a/data/mnet/Common/Java/com/jetcell/MibWM/AlarmTableModel.java b/data/mnet/Common/Java/com/jetcell/MibWM/AlarmTableModel.java
new file mode 100644
index 0000000..0123885
--- /dev/null
+++ b/data/mnet/Common/Java/com/jetcell/MibWM/AlarmTableModel.java
@@ -0,0 +1,43 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// Class : AlarmTableModel
+// Desc :
+// Author : George Zhao
+// Hist : 06/17/1999 Initial Creation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+package com.jetcell.MibWM;
+
+import javax.swing.*;
+import javax.swing.table.*;
+import java.awt.event.*;
+import java.awt.*;
+import java.util.*;
+
+public class AlarmTableModel extends DefaultTableModel
+
+
+{
+ final static int INDEX = 6;
+ final static int READ = 0;
+ final static int ALARMID = 1;
+ final static int TIMESTAMP = 2;
+ final static int SEVERITY = 3;
+ final static int OBJECT = 4;
+ final static int SUBJECT = 5;
+ final static int MESSAGE = 6;
+ final static int ACK = 7;
+
+
+ static String ColumnTitle[] = {"Read", "Alarm ID", "Time Stamp", "Severity", "Object", "Message Subject", "","Ack"};
+ final static int NUM_COL = ColumnTitle.length;
+
+ public AlarmTableModel()
+ {
+ super(ColumnTitle, 0);
+ }
+}
+
+
+//$History:$
diff --git a/data/mnet/Common/Java/com/jetcell/MibWM/AlarmTablePopupMenu.java b/data/mnet/Common/Java/com/jetcell/MibWM/AlarmTablePopupMenu.java
new file mode 100644
index 0000000..4002b40
--- /dev/null
+++ b/data/mnet/Common/Java/com/jetcell/MibWM/AlarmTablePopupMenu.java
@@ -0,0 +1,218 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// Class : AlarmTablePopupMenu
+// Desc :
+// Author : George Zhao
+// Hist : 06/17/1999 Initial Creation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+package com.jetcell.MibWM;
+
+import java.util.*;
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+import javax.swing.text.*;
+import javax.swing.table.*;
+
+public class AlarmTablePopupMenu extends JPopupMenu implements ActionListener
+{
+ static JMenuItem openMenuItem;
+ static JMenuItem removeMenuItem;
+ static JMenuItem removeAllMenuItem;
+ static JMenuItem removeReadMenuItem;
+ static JMenuItem removeInfoMenuItem;
+ static JMenuItem refreshMenuItem;
+ static JMenuItem acknowledgeMenuItem;
+
+ static boolean iconsLoaded = false;
+ protected static AlarmTablePopupMenu popupMenu = new AlarmTablePopupMenu();
+
+ static AlarmTable invoker ;
+
+ static int x;
+ static int y;
+
+
+ /**
+ * You cannot instantiate this class. Use getPopupMenu() to get
+ * a shared instance!
+ */
+ protected AlarmTablePopupMenu()
+ {
+ openMenuItem = Util.makeMenuItem("Open Event",'O');
+ openMenuItem.setHorizontalTextPosition(SwingConstants.RIGHT);
+ openMenuItem.setHorizontalAlignment(SwingConstants.LEFT);
+ openMenuItem.addActionListener(this);
+ add(openMenuItem);
+ addSeparator();
+
+
+ /*
+ removeMenuItem = Util.makeMenuItem("Remove Event",'R');
+ removeMenuItem.setHorizontalTextPosition(SwingConstants.RIGHT);
+ removeMenuItem.setHorizontalAlignment(SwingConstants.LEFT);
+ removeMenuItem.addActionListener(this);
+ add(removeMenuItem);
+ addSeparator();
+
+ removeAllMenuItem = Util.makeMenuItem("Remove All Events", 'A');
+ removeAllMenuItem.setHorizontalTextPosition(SwingConstants.RIGHT);
+ removeAllMenuItem.setHorizontalAlignment(SwingConstants.LEFT);
+ removeAllMenuItem.addActionListener(this);
+ add(removeAllMenuItem);
+
+ removeReadMenuItem = Util.makeMenuItem("Remove Read Events", 'E');
+ removeReadMenuItem.setHorizontalTextPosition(SwingConstants.RIGHT);
+ removeReadMenuItem.setHorizontalAlignment(SwingConstants.LEFT);
+ removeReadMenuItem.addActionListener(this);
+ add(removeReadMenuItem);
+
+ removeInfoMenuItem = Util.makeMenuItem("Remove Clear Events", 'C');
+ removeInfoMenuItem.setHorizontalTextPosition(SwingConstants.RIGHT);
+ removeInfoMenuItem.setHorizontalAlignment(SwingConstants.LEFT);
+ removeInfoMenuItem.addActionListener(this);
+ add(removeInfoMenuItem);*/
+
+ // Shrinivas 20th Apr 01
+ /*addSeparator();
+ refreshMenuItem = Util.makeMenuItem("Refresh", 'R');
+ refreshMenuItem.setHorizontalTextPosition(SwingConstants.RIGHT);
+ refreshMenuItem.setHorizontalAlignment(SwingConstants.LEFT);
+ refreshMenuItem.addActionListener(this);
+ add(refreshMenuItem);*/
+ // Shrinivas 20th Apr 01
+
+ addSeparator();
+ addSeparator();
+ acknowledgeMenuItem = Util.makeMenuItem("Acknowledge", 'A');
+ acknowledgeMenuItem.setHorizontalTextPosition(SwingConstants.RIGHT);
+ acknowledgeMenuItem.setHorizontalAlignment(SwingConstants.LEFT);
+ acknowledgeMenuItem.addActionListener(this);
+ add(acknowledgeMenuItem);
+ }
+
+
+ /**
+ * returns shared instance of popupMenu
+ */
+ public static AlarmTablePopupMenu getPopupMenu()
+ {
+ return popupMenu;
+ }
+
+
+ /**
+ * update to use difference icons later!
+ */
+ void loadIcons()
+ {
+ openMenuItem.setIcon(new ImageIcon(ImageLoader.loadImage("opengray.gif")));
+ removeAllMenuItem.setIcon(new ImageIcon(ImageLoader.loadImage("delete.gif")));
+ removeReadMenuItem.setIcon(new ImageIcon(ImageLoader.loadImage("delete.gif")));
+ removeInfoMenuItem.setIcon(new ImageIcon(ImageLoader.loadImage("delete.gif")));
+ refreshMenuItem.setIcon(new ImageIcon(ImageLoader.loadImage("reset.gif")));
+ }
+
+
+ /**
+ * update to use shared clipboard access later
+ */
+ public void actionPerformed(ActionEvent e)
+ {
+ Object obj = e.getSource();
+ String selection = null;
+
+ if (obj == openMenuItem)
+ {
+ invoker.OpenEvent();
+ }
+ else if (obj == removeMenuItem)
+ {
+ invoker.RemoveEvent();
+ }
+ else if (obj == removeAllMenuItem)
+ {
+ invoker.RemoveAllEvents();
+ }
+ else if (obj == removeReadMenuItem)
+ {
+ invoker.RemoveReadEvents();
+ }
+ else if (obj == removeInfoMenuItem)
+ {
+ invoker.RemoveInfoEvents();
+ }
+ else if (obj == refreshMenuItem){
+ invoker.Refresh();
+ }
+ else if (obj == acknowledgeMenuItem){
+ invoker.Acknowledge();
+ }
+
+ }
+
+
+ /**
+ * force JTable only later
+ */
+ public void show(Component c, int x, int y)
+ {
+ invoker = (AlarmTable)c;
+ /*
+ if (iconsLoaded == false)
+ {
+ loadIcons();
+ iconsLoaded = true;
+ }
+ */
+
+
+ Point p = new Point(x,y);
+ int row = invoker.rowAtPoint(p);
+ int col = invoker.columnAtPoint(p);
+
+ /*
+ if ((row >= 0) && (col >= 0))
+ enableMenu();
+ else
+ {
+ disableMenu();
+ return;
+ }
+ */
+
+ DefaultTableModel model = (DefaultTableModel)invoker.getModel();
+ Boolean acknowledge = (Boolean) model.getValueAt(row,AlarmTableModel.ACK);
+ if(acknowledge.booleanValue()){
+ acknowledgeMenuItem.setEnabled(false);
+ }
+ else{
+ acknowledgeMenuItem.setEnabled(true);
+ }
+ this.x = x;
+ this.y = y;
+ super.show(c,x,y);
+ }
+
+
+ void disableMenu()
+ {
+ openMenuItem.setEnabled(false);
+ removeAllMenuItem.setEnabled(false);
+ removeReadMenuItem.setEnabled(false);
+ removeInfoMenuItem.setEnabled(false);
+ }
+
+
+ void enableMenu()
+ {
+ openMenuItem.setEnabled(true);
+ removeAllMenuItem.setEnabled(true);
+ removeReadMenuItem.setEnabled(true);
+ removeInfoMenuItem.setEnabled(true);
+ }
+}
+
+//$History:$
diff --git a/data/mnet/Common/Java/com/jetcell/MibWM/AlarmTableSorter.java b/data/mnet/Common/Java/com/jetcell/MibWM/AlarmTableSorter.java
new file mode 100644
index 0000000..ead2e89
--- /dev/null
+++ b/data/mnet/Common/Java/com/jetcell/MibWM/AlarmTableSorter.java
@@ -0,0 +1,97 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// Class : AlarmTableSorter
+// Desc : table sorter for Order explorer request table.
+// Author : George Zhao
+// Hist : June 18, 1999
+//
+//////////////////////////////////////////////////////////////////////////////
+
+package com.jetcell.MibWM;
+
+import java.awt.*;
+import java.util.*;
+import javax.swing.table.*;
+
+
+
+class AlarmTableSorter extends TableSorter
+{
+ public AlarmTableSorter (TableModel model)
+ {
+ super (model);
+ }
+
+ public int compareRowsByColumn(int row1, int row2, int column)
+ {
+ TableModel data = model;
+
+ // Check for nulls
+
+ Object o1 = data.getValueAt(row1, column);
+ Object o2 = data.getValueAt(row2, column);
+
+ // If both values are null return 0
+ if (o1 == null && o2 == null) {
+ return 0;
+ }
+ else if (o1 == null) { // Define null less than everything.
+ return -1;
+ }
+ else if (o2 == null) {
+ return 1;
+ }
+
+ try {
+ if (column == AlarmTableModel.ALARMID ) {
+
+ float id1 = (new Float (((String)data.getValueAt(row1, AlarmTableModel.ALARMID)).trim())).floatValue();
+ float id2 = (new Float (((String)data.getValueAt(row2, AlarmTableModel.ALARMID)).trim())).floatValue();
+
+
+ if (id1 < id2)
+ return -1;
+ else if (id1 > id2)
+ return 1;
+ else
+ return 0;
+ }
+ else if (column == AlarmTableModel.READ)
+ {
+ boolean b1 = ((Boolean) data.getValueAt(row1, column)).booleanValue();
+ boolean b2 = ((Boolean) data.getValueAt(row2, column)).booleanValue();
+
+ if(b1 && !b2) return -1;
+ else if(!b1 && b2) return 1;
+ else return 0;
+ }
+ else if (column == AlarmTableModel.ACK)
+ {
+ boolean b1 = ((Boolean) data.getValueAt(row1, column)).booleanValue();
+ boolean b2 = ((Boolean) data.getValueAt(row2, column)).booleanValue();
+
+ if(b1 && !b2) return -1;
+ else if(!b1 && b2) return 1;
+ else return 0;
+ }
+ else {
+ String s1 = (String)data.getValueAt(row1, column);
+ String s2 = (String)data.getValueAt(row2, column);
+ int result = s1.compareTo(s2);
+
+ if (result < 0)
+ return -1;
+ else if (result > 0)
+ return 1;
+ else return 0;
+ }
+ }
+ catch (NumberFormatException e)
+ {
+ System.out.println(e);
+ }
+
+ return 0;
+ }
+}
+//$History:$
diff --git a/data/mnet/Common/Java/com/jetcell/MibWM/BaseTable.java b/data/mnet/Common/Java/com/jetcell/MibWM/BaseTable.java
new file mode 100644
index 0000000..c9559f3
--- /dev/null
+++ b/data/mnet/Common/Java/com/jetcell/MibWM/BaseTable.java
@@ -0,0 +1,312 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// Class : BaseTable
+// Desc :
+// Author : George Zhao
+// Hist : 06/17/1999 Initial Creation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+package com.jetcell.MibWM;
+
+import java.util.*;
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+import javax.swing.border.*;
+import javax.swing.table.*;
+import javax.swing.event.*;
+
+public class BaseTable extends JTable
+{
+ static final int KEY_UP = 1;
+ static final int KEY_DOWN = 2;
+ static final int KEY_HOME = 3;
+ static final int KEY_END = 4;
+ static final int KEY_PGUP = 5;
+ static final int KEY_PGDN = 6;
+
+ JTableHeader tableHeader;
+ TableModel model;
+ TableSorter sorter;
+ static JPopupMenu popupMenu;
+
+ public BaseTable()
+ {
+ super();
+ modTable();
+ }
+
+ public BaseTable(Object[][] data, Object[] cols)
+ {
+ super(data,cols);
+ modTable();
+
+ }
+
+ public BaseTable(TableModel dm)
+ {
+ super();
+ model = dm;
+ modTable();
+ }
+
+
+ public BaseTable(TableModel dm, TableColumnModel cm)
+ {
+ super(dm, cm);
+ model = dm;
+ modTable();
+ }
+
+
+ public BaseTable(TableModel dm, TableColumnModel cm, ListSelectionModel sm)
+ {
+ super(dm, cm, sm);
+ model = dm;
+ modTable();
+ }
+
+
+ public BaseTable(int numRows, int numColumns)
+ {
+ super(numRows, numColumns);
+ modTable();
+ }
+
+
+ public BaseTable(Vector rowData, Vector columnNames)
+ {
+ super(rowData, columnNames);
+ modTable();
+ }
+
+ public void setPopupMenu (JPopupMenu popupMenu)
+ {
+ this.popupMenu = popupMenu;
+ }
+
+ public JPopupMenu getPopupMenu()
+ {
+ return popupMenu;
+ }
+
+
+ void modTable()
+ {
+ addKeyboardHooks();
+ addHeaderHooks();
+
+ popupMenu = TablePopupMenu.getPopupMenu();
+ add(popupMenu);
+ addMouseListener(new MouseHandler() );
+ }
+
+
+ void addHeaderHooks()
+ {
+ if( model != null )
+ {
+ sorter = new TableSorter( model );
+ sorter.addMouseListenerToHeaderInTable( this );
+ super.setModel( sorter );
+ }
+
+ }
+
+ public boolean isCellEditable(int i, int j)
+ {
+ return false;
+ }
+
+ public void makeCurrentRowVisible()
+ {
+ scrollRectToVisible(getCellRect(getSelectedRow(),0 , true));
+ }
+
+ public void selectFirstRow()
+ {
+ getSelectionModel().setSelectionInterval(0,0);
+ }
+
+ void addKeyboardHooks()
+ {
+ //debug("adding table hooks");
+ int criteria;
+ criteria = WHEN_IN_FOCUSED_WINDOW;
+ //criteria = WHEN_FOCUSED;
+ registerKeyboardAction(new TableKeyboardHandler(KEY_UP) , KeyStroke.getKeyStroke(KeyEvent.VK_UP,0), criteria);
+ registerKeyboardAction(new TableKeyboardHandler(KEY_DOWN), KeyStroke.getKeyStroke(KeyEvent.VK_DOWN,0), criteria);
+ registerKeyboardAction(new TableKeyboardHandler(KEY_HOME), KeyStroke.getKeyStroke(KeyEvent.VK_HOME,0), criteria);
+ registerKeyboardAction(new TableKeyboardHandler(KEY_END) , KeyStroke.getKeyStroke(KeyEvent.VK_END,0), criteria);
+ registerKeyboardAction(new TableKeyboardHandler(KEY_PGUP), KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP,0), criteria);
+ registerKeyboardAction(new TableKeyboardHandler(KEY_PGDN), KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN,0), criteria);
+ }
+
+ class TableKeyboardHandler extends AbstractAction
+ {
+ int key;
+ int pageInc = 5; // fix later to found out number of visible rows!
+ int row;
+ int lastRow;
+
+ public TableKeyboardHandler(int key)
+ {
+ this.key = key;
+ }
+
+ public void actionPerformed(ActionEvent e)
+ {
+ switch(key)
+ {
+ case KEY_UP :
+ //debug("Up arrow");
+ row = getSelectedRow();
+ if (row <= 0)
+ getToolkit().beep();
+ else
+ {
+ row=row-1;
+ setRowSelectionInterval (row,row);
+ updateUI();
+ }
+ break;
+
+ case KEY_DOWN :
+ //debug("Down arrow");
+ row = getSelectedRow();
+ if ((row == getRowCount()-1) || (row < 0))
+ getToolkit().beep();
+ else
+ {
+ row++;
+ setRowSelectionInterval (row,row);
+ updateUI();
+ }
+ break;
+
+ case KEY_HOME :
+ //debug("Home key");
+ row = getSelectedRow();
+ if (row <= 0)
+ getToolkit().beep();
+ else
+ {
+ setRowSelectionInterval (0,0);
+ updateUI();
+ }
+ break;
+
+ case KEY_END :
+ //debug("End key");
+ lastRow = getRowCount()-1;
+ row = getSelectedRow();
+ if ((row == lastRow) || (row < 0))
+ getToolkit().beep();
+ else
+ {
+ setRowSelectionInterval (lastRow,lastRow);
+ updateUI();
+ }
+ break;
+
+ case KEY_PGUP :
+ //debug("Page up");
+ row = getSelectedRow();
+ if (row <= 0)
+ getToolkit().beep();
+ else if (row-pageInc <= 0)
+ {
+ setRowSelectionInterval (0,0);
+ updateUI();
+ }
+ else
+ {
+ row=row-pageInc;
+ setRowSelectionInterval (row,row);
+ updateUI();
+ }
+ break;
+
+ case KEY_PGDN :
+ //debug("Page down");
+ int lastRow = getRowCount()-1;
+ row = getSelectedRow();
+ if ((row == lastRow) || (row < 0))
+ getToolkit().beep();
+ else if (row+pageInc >= lastRow)
+ {
+ setRowSelectionInterval (lastRow,lastRow);
+ updateUI();
+ }
+ else
+ {
+ row+=pageInc;
+ setRowSelectionInterval (row,row);
+ updateUI();
+ }
+ break;
+
+ default :
+ System.out.println("Key not handled " + key);
+ break;
+ }
+
+ makeCurrentRowVisible();
+ }
+
+ }
+
+
+ class MouseHandler extends MouseAdapter
+ {
+ public void mouseReleased(MouseEvent e)
+ {
+ if ( e.isPopupTrigger())
+ {
+ popupMenu.show(BaseTable.this, e.getX(), e.getY());
+ }
+ }
+ }
+
+ public void setScrollPane(JScrollPane p)
+ {
+ // only here for compatibility with drop1 code. remove later!
+ }
+
+ public void setColumnWidth(int columnIndex, int minWidth, int maxWidth)
+ {
+ TableColumn column = (TableColumn) getColumn( getColumnName( columnIndex ) );
+
+ column.setMinWidth(minWidth);
+ column.setMaxWidth(maxWidth);
+ }
+
+ public String getDataFromTable( int col )
+ {
+ if ( getRowCount() > 0 )
+ {
+ int row = getSelectedRow();
+
+ if (row < 0)
+ {
+ setRowSelectionInterval(0,0);
+ row = getSelectedRow();
+ }
+
+ return (String) getModel().getValueAt( row, col );
+ }
+ else
+ return "";
+ }
+
+ public void setColumnHeaderTitle( int column, String value )
+ {
+ DefaultTableColumnModel cm = (DefaultTableColumnModel)getColumnModel();
+ TableColumn tc = cm.getColumn( column );
+ tc.setHeaderValue( value );
+ }
+
+
+}
+//$History:$ \ No newline at end of file
diff --git a/data/mnet/Common/Java/com/jetcell/MibWM/ImageLoader.java b/data/mnet/Common/Java/com/jetcell/MibWM/ImageLoader.java
new file mode 100644
index 0000000..62111f2
--- /dev/null
+++ b/data/mnet/Common/Java/com/jetcell/MibWM/ImageLoader.java
@@ -0,0 +1,136 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// Class : ImageLoader
+// Desc : Use to load images from the Images directory.
+// Author : George Zhao
+// History: April 22, 1999 Intial Creation.
+//////////////////////////////////////////////////////////////////////////////
+
+package com.jetcell.MibWM;
+
+import java.awt.*;
+import java.net.*;
+import java.util.*;
+import javax.swing.*;
+import com.jetcell.MibWM.Images.ImageStub;
+
+public class ImageLoader
+{
+ private static Hashtable imageCache = new Hashtable();
+
+
+ /**
+ * load image from com/jetcell/MibWM/Images
+ */
+ public synchronized static Image loadImage(String filename)
+ {
+ Image image = null;
+
+ /*
+ if (ImageLoader.imageInCache(filename))
+ image = ImageLoader.getImageFromCache(filename);
+ else*/
+ {
+ if ( Util.applet != null )
+ {
+
+ /**
+ * load using applet method
+ */
+
+ try {
+ URL url = new URL(Util.applet.getCodeBase()+ "com/jetcell/MibWM/Images/" + filename);
+ image = Util.applet.getImage(url);
+ }
+ catch(Exception e) {}
+ //image = Util.applet.getImage(Util.applet.getCodeBase(), "com/jetcell/MibWM/Images/" + filename);
+
+
+ if (image == null) System.out.println("Image is NULL: " +filename);
+ }
+ else
+ {
+ /**
+ * load using application method
+ */
+
+ URL url = new ImageStub().getClass().getResource(filename);
+
+ Toolkit tk = java.awt.Toolkit.getDefaultToolkit();
+
+ try
+ {
+ image = tk.createImage((java.awt.image.ImageProducer) url.getContent());
+ }
+ catch (java.io.IOException e)
+ {
+ System.out.println("[ImageLoader] " + e.toString());
+ }
+ }
+
+ /**
+ * block while waiting for image to load
+ */
+
+ if (image != null)
+ {
+ MediaTracker tracker = new MediaTracker(new Component() {} );
+ tracker.addImage(image, 0);
+ try
+ {
+ tracker.waitForID(0);
+ }
+ catch (InterruptedException e)
+ {
+ System.out.println("[ImageLoader] " + e.toString());
+ }
+
+ /**
+ * add to cache
+ */
+ ImageLoader.putImageInCache(filename, image);
+ }
+ }
+
+ return image;
+ }
+
+
+ /**
+ * load icon from com/mci/vdds/Images
+ */
+ public synchronized static ImageIcon loadIcon(String filename)
+ {
+ return new ImageIcon(loadImage(filename));
+ }
+
+ private static boolean imageInCache(String filename)
+ {
+ if (imageCache.containsKey(filename))
+ return true;
+ else
+ return false;
+ }
+
+ private static Image getImageFromCache(String filename)
+ {
+ return (Image)imageCache.get(filename);
+ }
+
+ private static void putImageInCache(String filename, Image image)
+ {
+ imageCache.put(filename, image);
+ }
+
+ public static void main(String argv[])
+ {
+ JFrame f = new JFrame();
+ ImageIcon icon = ImageLoader.loadIcon("closed.gif");
+ JButton b = new JButton(icon);
+ System.out.println("after new messagepanel");
+ f.setBounds(0,0,100,100);
+ f.getContentPane().add(b);
+ f.setVisible(true);
+ }
+}
+//$History:$ \ No newline at end of file
diff --git a/data/mnet/Common/Java/com/jetcell/MibWM/Makefile b/data/mnet/Common/Java/com/jetcell/MibWM/Makefile
new file mode 100644
index 0000000..2bf2ffa
--- /dev/null
+++ b/data/mnet/Common/Java/com/jetcell/MibWM/Makefile
@@ -0,0 +1,38 @@
+####################################################################
+#
+# FILE NAME: Makefile
+#
+# DESCRIPTION: This makefile creates the vipercell related class
+# files
+# COMPONENTS:
+#
+#
+# NOTES:
+#
+# (C) Copyright 1999 JetCell Inc., CA, USA http://www.jetcell.com/
+#
+# REVISION HISTORY
+#__________________________________________________________________
+#----------+--------+----------------------------------------------
+# Name | Date | Reason
+#----------+--------+----------------------------------------------
+# Bhawani |11/28/99| Initial Draft
+#----------+--------+----------------------------------------------
+####################################################################
+#/
+
+CODEBASE = ../../..
+
+
+include $(CODEBASE)/java.mk
+
+
+all: $(CLASS_LIST)
+
+
+clean:
+ $(RM) *.class
+
+cleanall:
+ $(RM) *.class
+
diff --git a/data/mnet/Common/Java/com/jetcell/MibWM/TableMap.java b/data/mnet/Common/Java/com/jetcell/MibWM/TableMap.java
new file mode 100644
index 0000000..cdbb4e3
--- /dev/null
+++ b/data/mnet/Common/Java/com/jetcell/MibWM/TableMap.java
@@ -0,0 +1,104 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// Class : TableMap
+// Desc :
+// Author : George Zhao
+// Hist : 06/17/1999 Initial Creation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+/**
+ * based on Sun TableMap. -gz
+ * @version 1.4 12/17/97
+ * @author Philip Milne */
+
+package com.jetcell.MibWM;
+
+import javax.swing.table.*;
+import javax.swing.event.TableModelListener;
+import javax.swing.event.TableModelEvent;
+
+public class TableMap extends DefaultTableModel implements TableModelListener
+{
+ protected TableModel model;
+
+ public TableModel getModel() {
+ return model;
+ }
+
+ public void setModel(TableModel model) {
+ this.model = model;
+ model.addTableModelListener(this);
+ }
+
+ // By default, Implement TableModel by forwarding all messages
+ // to the model.
+
+ public Object getValueAt(int aRow, int aColumn) {
+ return model.getValueAt(aRow, aColumn);
+ }
+
+ public void setValueAt(Object aValue, int aRow, int aColumn) {
+ model.setValueAt(aValue, aRow, aColumn);
+ }
+
+ public int getRowCount() {
+ return (model == null) ? 0 : model.getRowCount();
+ }
+
+ public int getColumnCount() {
+ return (model == null) ? 0 : model.getColumnCount();
+ }
+
+ public String getColumnName(int aColumn) {
+ return model.getColumnName(aColumn);
+ }
+
+ public Class getColumnClass(int aColumn)
+ {
+ if (model.getColumnCount() == 0)
+ return model.getColumnClass(aColumn);
+
+ Object value = model.getValueAt(0,aColumn);
+ return value == null ? Object.class : value.getClass();
+ }
+
+ public boolean isCellEditable(int row, int column) {
+ return model.isCellEditable(row, column);
+ }
+
+ public void addColumn(Object col)
+ {
+ if ( model instanceof DefaultTableModel )
+ ( (DefaultTableModel)model).addColumn( col );
+ else
+ throw new RuntimeException("ERROR: Subclass of DefaultTableModel required.");
+
+ }
+
+
+ public void addRow(Object rowData[])
+ {
+ ( (DefaultTableModel)model).addRow( rowData );
+ }
+
+ public void removeRow(int rowIndex)
+ {
+ ( (DefaultTableModel)model).removeRow( rowIndex );
+ }
+
+ //
+ // Implementation of the TableModelListener interface,
+ //
+
+ // By default forward all events to all the listeners.
+ public void tableChanged(TableModelEvent e) {
+ fireTableChanged(e);
+ }
+
+ public void insertRow(int row, Object rowData[])
+ {
+ ( (DefaultTableModel)model).insertRow(row, rowData);
+ }
+}
+//$History:$ \ No newline at end of file
diff --git a/data/mnet/Common/Java/com/jetcell/MibWM/TablePopupMenu.java b/data/mnet/Common/Java/com/jetcell/MibWM/TablePopupMenu.java
new file mode 100644
index 0000000..2df4e3e
--- /dev/null
+++ b/data/mnet/Common/Java/com/jetcell/MibWM/TablePopupMenu.java
@@ -0,0 +1,195 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// Class : TablePopupMenu
+// Desc :
+// Author : George Zhao
+// Hist : 06/17/1999 Initial Creation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+package com.jetcell.MibWM;
+
+import java.util.*;
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+import javax.swing.text.*;
+
+public class TablePopupMenu extends JPopupMenu implements ActionListener
+{
+ static JMenuItem copyCellMenuItem;
+ static JMenuItem copyRowMenuItem;
+ static JMenuItem copyColumnMenuItem;
+ static JMenuItem copyTableMenuItem;
+
+ static boolean iconsLoaded = false;
+ static JTable invoker ;
+
+ static int x;
+ static int y;
+
+ protected static TablePopupMenu popupMenu = new TablePopupMenu();
+
+
+ /**
+ * You cannot instantiate this class. Use getPopupMenu() to get
+ * a shared instance!
+ */
+ protected TablePopupMenu()
+ {
+ copyCellMenuItem = Util.makeMenuItem("Copy Cell",'C');
+ copyCellMenuItem.setHorizontalTextPosition(SwingConstants.RIGHT);
+ copyCellMenuItem.setHorizontalAlignment(SwingConstants.LEFT);
+ copyCellMenuItem.addActionListener(this);
+ add(copyCellMenuItem);
+
+ copyRowMenuItem = Util.makeMenuItem("Copy Row", 'R');
+ copyRowMenuItem.setHorizontalTextPosition(SwingConstants.RIGHT);
+ copyRowMenuItem.setHorizontalAlignment(SwingConstants.LEFT);
+ copyRowMenuItem.addActionListener(this);
+ add(copyRowMenuItem);
+
+ copyColumnMenuItem = Util.makeMenuItem("Copy Column", 'L');
+ copyColumnMenuItem.setHorizontalTextPosition(SwingConstants.RIGHT);
+ copyColumnMenuItem.setHorizontalAlignment(SwingConstants.LEFT);
+ copyColumnMenuItem.addActionListener(this);
+ add(copyColumnMenuItem);
+
+ copyTableMenuItem = Util.makeMenuItem("Copy Table", 'T');
+ copyTableMenuItem.setHorizontalTextPosition(SwingConstants.RIGHT);
+ copyTableMenuItem.setHorizontalAlignment(SwingConstants.LEFT);
+ copyTableMenuItem.addActionListener(this);
+ add(copyTableMenuItem);
+ }
+
+
+ /**
+ * returns shared instance of popupMenu
+ */
+ public static TablePopupMenu getPopupMenu()
+ {
+ return popupMenu;
+ }
+
+
+ /**
+ * update to use difference icons later!
+ */
+ void loadIcons()
+ {
+ if(Util.applet == null)
+ {
+ copyCellMenuItem.setIcon(new ImageIcon(ImageLoader.loadImage("copy.gif")));
+ copyRowMenuItem.setIcon(new ImageIcon(ImageLoader.loadImage("copy.gif")));
+ copyColumnMenuItem.setIcon(new ImageIcon(ImageLoader.loadImage("copy.gif")));
+ copyTableMenuItem.setIcon(new ImageIcon(ImageLoader.loadImage("copy.gif")));
+ }
+ }
+
+
+ /**
+ * update to use shared clipboard access later
+ */
+ public void actionPerformed(ActionEvent e)
+ {
+ Object obj = e.getSource();
+
+ Point p = new Point(x,y);
+ int row = invoker.rowAtPoint(p);
+ int col = invoker.columnAtPoint(p);
+
+ String selection = null;
+
+ if (obj == copyCellMenuItem)
+ {
+ selection = invoker.getValueAt(row,col).toString();
+ }
+ else if (obj == copyRowMenuItem)
+ {
+ for(int i=0; i < invoker.getColumnCount(); i++)
+ {
+ Object cell = invoker.getValueAt(row,i);
+ if (cell != null)
+ selection += cell.toString() + " ";
+ }
+ }
+ else if (obj == copyColumnMenuItem)
+ {
+ for(int i=0; i < invoker.getRowCount(); i++)
+ {
+ Object cell = invoker.getValueAt(i,col);
+ if (cell != null)
+ selection += cell.toString() + " ";
+ }
+ }
+ else if (obj == copyTableMenuItem)
+ {
+ for(int i=0; i < invoker.getRowCount(); i++)
+ {
+ for(int j=0; j < invoker.getColumnCount(); j++)
+ {
+ Object cell = invoker.getValueAt(i,j);
+ if (cell != null)
+ selection += cell.toString() + " ";
+ }
+
+ selection += "\n";
+ }
+ }
+
+
+ TextClipboard.setText(selection);
+
+ }
+
+
+ /**
+ * force JTable only later
+ */
+ public void show(Component c, int x, int y)
+ {
+ invoker = (JTable)c;
+
+ if (iconsLoaded == false)
+ {
+ loadIcons();
+ iconsLoaded = true;
+ }
+
+ Point p = new Point(x,y);
+ int row = invoker.rowAtPoint(p);
+ int col = invoker.columnAtPoint(p);
+
+ if ((row >= 0) && (col >= 0))
+ enableMenu();
+ else
+ {
+ disableMenu();
+ return;
+ }
+
+ this.x = x;
+ this.y = y;
+ super.show(c,x,y);
+ }
+
+
+ void disableMenu()
+ {
+ copyCellMenuItem.setEnabled(false);
+ copyRowMenuItem.setEnabled(false);
+ copyColumnMenuItem.setEnabled(false);
+ copyTableMenuItem.setEnabled(false);
+ }
+
+
+ void enableMenu()
+ {
+ copyCellMenuItem.setEnabled(true);
+ copyRowMenuItem.setEnabled(true);
+ copyColumnMenuItem.setEnabled(true);
+ copyTableMenuItem.setEnabled(true);
+ }
+}
+
+//$History:$ \ No newline at end of file
diff --git a/data/mnet/Common/Java/com/jetcell/MibWM/TableSorter.java b/data/mnet/Common/Java/com/jetcell/MibWM/TableSorter.java
new file mode 100644
index 0000000..51324bb
--- /dev/null
+++ b/data/mnet/Common/Java/com/jetcell/MibWM/TableSorter.java
@@ -0,0 +1,360 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// Class : TableSorter
+// Desc :
+// Author : George Zhao
+// Hist : 06/17/1999 Initial Creation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+/**
+ * based on Sun TableSorter. -gz
+ * @version 1.5 12/17/97
+ * @author Philip Milne
+ */
+
+package com.jetcell.MibWM;
+
+import java.util.*;
+
+import javax.swing.table.TableModel;
+import javax.swing.event.TableModelEvent;
+
+// Imports for picking up mouse events from the JTable.
+
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.awt.event.InputEvent;
+import javax.swing.JTable;
+import javax.swing.table.JTableHeader;
+import javax.swing.table.TableColumn;
+import javax.swing.table.TableColumnModel;
+
+public class TableSorter extends TableMap
+{
+ int indexes[];
+ Vector sortingColumns = new Vector();
+ boolean ascending = true;
+ int compares;
+ int sortByColumnInd = 1;
+
+ public TableSorter()
+ {
+ indexes = new int[0]; // For consistency.
+ }
+
+ public TableSorter(TableModel model)
+ {
+ setModel(model);
+ }
+
+ public void setModel(TableModel model) {
+ super.setModel(model);
+ reallocateIndexes();
+ }
+
+ public int compareRowsByColumn(int row1, int row2, int column)
+ {
+ Class type = model.getColumnClass(column);
+
+ TableModel data = model;
+
+ // Check for nulls
+
+ Object o1 = data.getValueAt(row1, column);
+ Object o2 = data.getValueAt(row2, column);
+
+ // If both values are null return 0
+ if (o1 == null && o2 == null) {
+ return 0;
+ }
+ else if (o1 == null) { // Define null less than everything.
+ return -1;
+ }
+ else if (o2 == null) {
+ return 1;
+ }
+
+/* We copy all returned values from the getValue call in case
+an optimised model is reusing one object to return many values.
+The Number subclasses in the JDK are immutable and so will not be used in
+this way but other subclasses of Number might want to do this to save
+space and avoid unnecessary heap allocation.
+*/
+ if (type.getSuperclass() == java.lang.Number.class)
+ {
+ Number n1 = (Number)data.getValueAt(row1, column);
+ double d1 = n1.doubleValue();
+ Number n2 = (Number)data.getValueAt(row2, column);
+ double d2 = n2.doubleValue();
+
+ if (d1 < d2)
+ return -1;
+ else if (d1 > d2)
+ return 1;
+ else
+ return 0;
+ }
+ else if (type == java.util.Date.class)
+ {
+ Date d1 = (Date)data.getValueAt(row1, column);
+ long n1 = d1.getTime();
+ Date d2 = (Date)data.getValueAt(row2, column);
+ long n2 = d2.getTime();
+
+ if (n1 < n2)
+ return -1;
+ else if (n1 > n2)
+ return 1;
+ else return 0;
+ }
+ else if (type == String.class)
+ {
+ String s1 = (String)data.getValueAt(row1, column);
+ String s2 = (String)data.getValueAt(row2, column);
+ int result = s1.compareTo(s2);
+
+ if (result < 0)
+ return -1;
+ else if (result > 0)
+ return 1;
+ else return 0;
+ }
+ else if (type == Boolean.class)
+ {
+ Boolean bool1 = (Boolean)data.getValueAt(row1, column);
+ boolean b1 = bool1.booleanValue();
+ Boolean bool2 = (Boolean)data.getValueAt(row2, column);
+ boolean b2 = bool2.booleanValue();
+
+ if (b1 == b2)
+ return 0;
+ else if (b1) // Define false < true
+ return 1;
+ else
+ return -1;
+ }
+ else
+ {
+ Object v1 = data.getValueAt(row1, column);
+ String s1 = v1.toString();
+ Object v2 = data.getValueAt(row2, column);
+ String s2 = v2.toString();
+ int result = s1.compareTo(s2);
+
+ if (result < 0)
+ return -1;
+ else if (result > 0)
+ return 1;
+ else return 0;
+ }
+ }
+
+ public int compare(int row1, int row2)
+ {
+ compares++;
+ for(int level = 0; level < sortingColumns.size(); level++)
+ {
+ Integer column = (Integer)sortingColumns.elementAt(level);
+ int result = compareRowsByColumn(row1, row2, column.intValue());
+ if (result != 0)
+ return ascending ? result : -result;
+ }
+ return 0;
+ }
+
+ public void reallocateIndexes()
+ {
+ int rowCount = model.getRowCount();
+ // Set up a new array of indexes with the right number of elements
+ // for the new data model.
+ indexes = new int[rowCount];
+
+ // Initialise with the identity mapping.
+ for(int row = 0; row < rowCount; row++)
+ indexes[row] = row;
+ }
+
+ public void tableChanged(TableModelEvent e)
+ {
+ reallocateIndexes();
+ super.tableChanged(e);
+ sortByColumnInd();
+ }
+
+ public void checkModel()
+ {
+ if ( indexes.length == 0 )
+ reallocateIndexes();
+
+ if (indexes.length != model.getRowCount()) {
+ System.out.println("Sorter not informed of a change in model.");
+ }
+ }
+
+ public void sort(Object sender)
+ {
+ checkModel();
+
+ compares = 0;
+ // n2sort();
+ // qsort(0, indexes.length-1);
+ shuttlesort((int[])indexes.clone(), indexes, 0, indexes.length);
+ }
+
+ public void n2sort() {
+ for(int i = 0; i < getRowCount(); i++) {
+ for(int j = i+1; j < getRowCount(); j++) {
+ if (compare(indexes[i], indexes[j]) == -1) {
+ swap(i, j);
+ }
+ }
+ }
+ }
+
+ // This is a home-grown implementation which we have not had time
+ // to research - it may perform poorly in some circumstances. It
+ // requires twice the space of an in-place algorithm and makes
+ // NlogN assigments shuttling the values between the two
+ // arrays. The number of compares appears to vary between N-1 and
+ // NlogN depending on the initial order but the main reason for
+ // using it here is that, unlike qsort, it is stable.
+ public void shuttlesort(int from[], int to[], int low, int high) {
+ if (high - low < 2) {
+ return;
+ }
+ int middle = (low + high)/2;
+ shuttlesort(to, from, low, middle);
+ shuttlesort(to, from, middle, high);
+
+ int p = low;
+ int q = middle;
+
+ /* This is an optional short-cut; at each recursive call,
+ check to see if the elements in this subset are already
+ ordered. If so, no further comparisons are needed; the
+ sub-array can just be copied. The array must be copied rather
+ than assigned otherwise sister calls in the recursion might
+ get out of sinc. When the number of elements is three they
+ are partitioned so that the first set, [low, mid), has one
+ element and and the second, [mid, high), has two. We skip the
+ optimisation when the number of elements is three or less as
+ the first compare in the normal merge will produce the same
+ sequence of steps. This optimisation seems to be worthwhile
+ for partially ordered lists but some analysis is needed to
+ find out how the performance drops to Nlog(N) as the initial
+ order diminishes - it may drop very quickly. */
+
+ if (high - low >= 4 && compare(from[middle-1], from[middle]) <= 0) {
+ for (int i = low; i < high; i++) {
+ to[i] = from[i];
+ }
+ return;
+ }
+
+ // A normal merge.
+
+ for(int i = low; i < high; i++) {
+ if (q >= high || (p < middle && compare(from[p], from[q]) <= 0)) {
+ to[i] = from[p++];
+ }
+ else {
+ to[i] = from[q++];
+ }
+ }
+ }
+
+ public void swap(int i, int j) {
+ int tmp = indexes[i];
+ indexes[i] = indexes[j];
+ indexes[j] = tmp;
+ }
+
+ public boolean getAscending()
+ {
+ return ascending;
+ }
+
+ // The mapping only affects the contents of the data rows.
+ // Pass all requests to these rows through the mapping array: "indexes".
+
+ public Object getValueAt(int aRow, int aColumn)
+ {
+ checkModel();
+ if (aRow >= 0 && aRow <model.getRowCount())
+ return model.getValueAt(indexes[aRow], aColumn);
+ return null;
+ }
+
+ public void setValueAt(Object aValue, int aRow, int aColumn)
+ {
+ checkModel();
+ model.setValueAt(aValue, indexes[aRow], aColumn);
+ }
+
+ public void sortByColumn(int column) {
+ sortByColumn(column, true);
+ }
+
+ public void sortByColumn(int column, boolean ascending) {
+ this.ascending = ascending;
+ sortingColumns.removeAllElements();
+ sortingColumns.addElement(new Integer(column));
+ sort(this);
+ super.tableChanged(new TableModelEvent(this));
+ }
+
+ // There is no-where else to put this.
+ // Add a mouse listener to the Table to trigger a table sort
+ // when a column heading is clicked in the JTable.
+ public void addMouseListenerToHeaderInTable(JTable table) {
+ final TableSorter sorter = this;
+ final JTable tableView = table;
+ tableView.setColumnSelectionAllowed(false);
+ MouseAdapter listMouseListener = new MouseAdapter() {
+ public void mouseClicked(MouseEvent e) {
+ TableColumnModel columnModel = tableView.getColumnModel();
+ int viewColumn = columnModel.getColumnIndexAtX(e.getX());
+ sortByColumnInd = tableView.convertColumnIndexToModel(viewColumn);
+ if(e.getClickCount() == 1 && sortByColumnInd != -1) {
+ int shiftPressed = e.getModifiers()&InputEvent.SHIFT_MASK;
+ //boolean ascending = (shiftPressed == 0);
+ boolean ascending = getAscending();
+ sorter.sortByColumn(sortByColumnInd, ascending);
+ }
+ }
+ };
+ JTableHeader th = tableView.getTableHeader();
+ th.addMouseListener(listMouseListener);
+ }
+
+ public void sortByColumnInd(){
+ sortByColumn(sortByColumnInd);
+ }
+ public void filteredRemoveRow(int row){
+ checkModel();
+ super.removeRow(indexes[row]);
+ }
+
+ public int getIndexAtRow(int row){
+ return indexes[row];
+ }
+}
+
+
+// $Log: TableSorter.java,v $
+// Revision 1.2 1999-12-21 13:35:06-08 klim
+// Fixes sorting reset problem
+//
+// Revision 1.1 1999-11-28 22:51:20-08 bsapkota
+// Initial revision
+//
+//
+// Rev 1.6 Jun 23 1998 12:13:00 GZHAO
+//add boundary check.
+//
+// Rev 1.5 Jun 02 1998 14:11:22 GZHAO
+//toggle the ascending for table sort.
+//
+// Rev 1.4 Jun 02 1998 12:52:10 GZHAO
+//modify System.out to Debug.out.
diff --git a/data/mnet/Common/Java/com/jetcell/MibWM/TextClipboard.java b/data/mnet/Common/Java/com/jetcell/MibWM/TextClipboard.java
new file mode 100644
index 0000000..a7876db
--- /dev/null
+++ b/data/mnet/Common/Java/com/jetcell/MibWM/TextClipboard.java
@@ -0,0 +1,80 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// Class : TextClipboard
+// Desc : Clipboard abstraction for working in both applet and application
+// Author : George Zhao
+// Created: 6/8/98
+//
+//////////////////////////////////////////////////////////////////////////////
+
+package com.jetcell.MibWM;
+
+import java.io.*;
+import java.awt.*;
+import java.awt.datatransfer.*;
+
+public abstract class TextClipboard
+{
+ private static String clipboard;
+
+ private static ClipboardOwner defaultClipboardOwner = new ClipboardObserver();
+
+ static class ClipboardObserver implements ClipboardOwner
+ {
+ public void lostOwnership(Clipboard clipboard, Transferable contents)
+ {
+ }
+ }
+
+
+ /**
+ * Set the value of the clipboard
+ * @param s string value
+ */
+ public static synchronized void setText(String s)
+ {
+ if (s == null)
+ s = "";
+
+ if (Util.applet != null)
+ clipboard = s;
+ else
+ Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(s), defaultClipboardOwner);
+ }
+
+
+ /**
+ * Get the string contents of the clipboard
+ */
+ public static synchronized String getText()
+ {
+ if (Util.applet != null)
+ return clipboard;
+ else
+ {
+ String s = null;
+ Transferable t = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(defaultClipboardOwner);
+ if (t == null)
+ return "";
+ else
+ try
+ {
+ s = (String)(t.getTransferData(DataFlavor.stringFlavor));
+ }
+ catch (UnsupportedFlavorException e)
+ {
+ System.out.println(e);
+ }
+ catch (IOException e)
+ {
+ System.out.println(e);
+ }
+ finally
+ {
+ return s;
+ }
+ }
+ }
+}
+
+//$History:$ \ No newline at end of file
diff --git a/data/mnet/Common/Java/com/jetcell/MibWM/TextComponentPopupMenu.java b/data/mnet/Common/Java/com/jetcell/MibWM/TextComponentPopupMenu.java
new file mode 100644
index 0000000..a653722
--- /dev/null
+++ b/data/mnet/Common/Java/com/jetcell/MibWM/TextComponentPopupMenu.java
@@ -0,0 +1,280 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// Class : TextComponentPopupMenu
+// Desc : Specialized popup menu for subclasses of JTextComponent
+// Author : George Zhao
+//
+//////////////////////////////////////////////////////////////////////////////
+
+package com.jetcell.MibWM;
+
+import java.util.*;
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+import javax.swing.text.*;
+
+/**
+ * Custom popup menu for subclasses of JTextComponent. Includes cut,copy,paste,
+ * paste recent, and delete.
+ *
+ * @see VDDSTextField
+ * @version 1.0
+ * @author Semir Patel
+ */
+
+public class TextComponentPopupMenu extends JPopupMenu implements ActionListener
+{
+ /**
+ * Maximum number of elements in Paste Recent submenu
+ */
+ static final int RECENT_LIST_SIZE = 4;
+
+
+ /**
+ * Popup menu items
+ */
+ static JMenuItem cutMenuItem;
+ static JMenuItem copyMenuItem;
+ static JMenuItem pasteMenuItem;
+ static JMenu pasteRecentMenu;
+ static JMenuItem deleteMenuItem;
+ static JMenuItem descriptionMenuItem;
+
+ static boolean iconsLoaded = false;
+
+ /**
+ * JTextComponent that invokes this popup menu
+ */
+ static JTextComponent invoker;
+
+
+ /**
+ * Starting and ending selection indices for the text component
+ */
+ static int start;
+ static int end;
+
+ /**
+ * shared instance of popup menu
+ */
+ protected static TextComponentPopupMenu popupMenu = new TextComponentPopupMenu();
+
+
+ private TextComponentPopupMenu()
+ {
+ cutMenuItem = Util.makeMenuItem("Cut",'t');
+ cutMenuItem.setHorizontalTextPosition(SwingConstants.RIGHT);
+ cutMenuItem.setHorizontalAlignment(SwingConstants.LEFT);
+ cutMenuItem.addActionListener(this);
+ add(cutMenuItem);
+
+ copyMenuItem = Util.makeMenuItem("Copy",'C');
+ copyMenuItem.setHorizontalTextPosition(SwingConstants.RIGHT);
+ copyMenuItem.setHorizontalAlignment(SwingConstants.LEFT);
+ copyMenuItem.addActionListener(this);
+ add(copyMenuItem);
+
+ pasteMenuItem = Util.makeMenuItem("Paste",'P');
+ pasteMenuItem.setHorizontalTextPosition(SwingConstants.RIGHT);
+ pasteMenuItem.setHorizontalAlignment(SwingConstants.LEFT);
+ pasteMenuItem.addActionListener(this);
+ add(pasteMenuItem);
+
+ pasteRecentMenu = new JMenu("Paste Recent");
+ pasteRecentMenu.setHorizontalTextPosition(SwingConstants.RIGHT);
+ pasteRecentMenu.setHorizontalAlignment(SwingConstants.LEFT);
+ pasteRecentMenu.registerKeyboardAction(null, KeyStroke.getKeyStroke('R',java.awt.Event.ALT_MASK,false),
+ JComponent.WHEN_IN_FOCUSED_WINDOW);
+ add(pasteRecentMenu);
+
+ deleteMenuItem = Util.makeMenuItem("Delete",'D');
+ deleteMenuItem.setHorizontalTextPosition(SwingConstants.RIGHT);
+ deleteMenuItem.setHorizontalAlignment(SwingConstants.LEFT);
+ deleteMenuItem.addActionListener(this);
+ add(deleteMenuItem);
+
+ addSeparator();
+ descriptionMenuItem = Util.makeMenuItem("Description", 'P');
+ descriptionMenuItem.setHorizontalTextPosition(SwingConstants.RIGHT);
+ descriptionMenuItem.setHorizontalAlignment(SwingConstants.LEFT);
+ descriptionMenuItem.addActionListener(this);
+ add(descriptionMenuItem);
+ }
+
+
+ /**
+ * accessor for shared instance of popup menu
+ */
+ public static TextComponentPopupMenu getPopupMenu()
+ {
+ return popupMenu;
+ }
+
+ void loadIcons()
+ {
+ cutMenuItem.setIcon(new ImageIcon(ImageLoader.loadImage("cut.gif")));
+ copyMenuItem.setIcon(new ImageIcon(ImageLoader.loadImage("copy.gif")));
+ pasteMenuItem.setIcon(new ImageIcon(ImageLoader.loadImage("paste.gif")));
+ pasteRecentMenu.setIcon(new ImageIcon(ImageLoader.loadImage("pasterecent.gif")));
+ deleteMenuItem.setIcon(new ImageIcon(ImageLoader.loadImage("delete.gif")));
+ }
+
+ /**
+ * Action listener for menu items
+ */
+ public void actionPerformed(ActionEvent e)
+ {
+ if (e.getSource() == cutMenuItem)
+ {
+ invoker.select(start,end);
+ TextClipboard.setText(invoker.getSelectedText());
+ invoker.replaceSelection("");
+ }
+ else if (e.getSource() == copyMenuItem)
+ {
+ invoker.select(start,end);
+ TextClipboard.setText(invoker.getSelectedText());
+ }
+ else if (e.getSource() == pasteMenuItem)
+ {
+ invoker.replaceSelection(TextClipboard.getText());
+ }
+ else if (e.getSource() == deleteMenuItem)
+ {
+ invoker.select(start,end);
+ invoker.replaceSelection("");
+ }
+ else if (e.getSource() == descriptionMenuItem)
+ {
+ /*
+ JOptionPane.showMessageDialog(Util.browser,
+ "Description of this field, range, detail meaning etc goes here.",
+ "Description", JOptionPane.INFORMATION_MESSAGE);
+ */
+ }
+ else if (e.getSource() instanceof JMenuItem)
+ {
+ invoker.select(start,end);
+ invoker.replaceSelection(((JMenuItem)e.getSource()).getText());
+ }
+
+ }
+
+ /**
+ * Shows popup menu at specified coords with text component selection info
+ * @param c Invoker
+ * @param x Absolute x location
+ * @param y Absolute y location
+ * @param start Start index of selection
+ * @param end End index of selection
+ */
+ public void show(Component c, int x, int y, int start, int end)
+ {
+ this.start = start;
+ this.end = end;
+ show(c,x,y);
+ }
+
+ public void show(Component c, int x, int y)
+ {
+ if (iconsLoaded == false)
+ {
+ loadIcons();
+ iconsLoaded = true;
+ }
+
+ if (c instanceof JTextComponent)
+ {
+ invoker = (JTextComponent)c;
+ int len = invoker.getText().length();
+ if (!invoker.isEditable())
+ {
+ cutMenuItem.setEnabled(false);
+ pasteMenuItem.setEnabled(false);
+ pasteRecentMenu.setEnabled(false);
+ deleteMenuItem.setEnabled(false);
+
+ if (len > 0)
+ copyMenuItem.setEnabled(true);
+ else
+ copyMenuItem.setEnabled(false);
+ }
+ else
+ {
+ if ((len > 0) && (start != end))
+ {
+ cutMenuItem.setEnabled(true);
+ copyMenuItem.setEnabled(true);
+ deleteMenuItem.setEnabled(true);
+ }
+ else
+ {
+ cutMenuItem.setEnabled(false);
+ copyMenuItem.setEnabled(false);
+ deleteMenuItem.setEnabled(false);
+ }
+
+ pasteMenuItem.setEnabled(true);
+
+ if (pasteRecentMenu.getMenuComponentCount() > 0)
+ pasteRecentMenu.setEnabled(true);
+ else
+ pasteRecentMenu.setEnabled(false);
+ }
+
+ super.show(invoker,x,y);
+ }
+ }
+
+ /**
+ * Adds entry to Paste Recent menu. List works like FIFO queue.
+ * @param s String to add to the paste recent menu
+ */
+ void addToMostRecentList(String s)
+ {
+ int cnt = pasteRecentMenu.getItemCount();
+
+ for (int i=0; i<cnt; i++)
+ if (pasteRecentMenu.getItem(i).getText().equals(s))
+ return;
+
+ if (cnt < RECENT_LIST_SIZE)
+ {
+ JMenuItem menuItem = Util.makeMenuItem();
+ pasteRecentMenu.add(menuItem);
+ menuItem.addActionListener(this);
+ cnt = pasteRecentMenu.getMenuComponentCount();
+
+ if (cnt == 1)
+ pasteRecentMenu.getItem(0).setText(s);
+ else
+ {
+ for (int i=cnt-1; i>=1; i--)
+ pasteRecentMenu.getItem(i).setText(pasteRecentMenu.getItem(i-1).getText());
+ pasteRecentMenu.getItem(0).setText(s);
+ }
+
+ }
+ else
+ {
+ for (int i=cnt-1; i>=1; i--)
+ pasteRecentMenu.getItem(i).setText(pasteRecentMenu.getItem(i-1).getText());
+ pasteRecentMenu.getItem(0).setText(s);
+ }
+ }
+
+ public void setVisible(boolean b)
+ {
+ /**
+ * Workaround for swing 0.7 bug.
+ * Get rid of visible submenu if showing
+ */
+ if (b == false)
+ pasteRecentMenu.setPopupMenuVisible(false);
+
+ super.setVisible(b);
+ }
+
+}
+//$History:$ \ No newline at end of file
diff --git a/data/mnet/Common/Java/com/jetcell/MibWM/Util.java b/data/mnet/Common/Java/com/jetcell/MibWM/Util.java
new file mode 100644
index 0000000..9612b8e
--- /dev/null
+++ b/data/mnet/Common/Java/com/jetcell/MibWM/Util.java
@@ -0,0 +1,779 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// Class : Util
+// Desc : Utility class for MIB Web Management
+// Author : George Zhao
+// History: April 22, 1999
+//
+//////////////////////////////////////////////////////////////////////////////
+
+package com.jetcell.MibWM;
+
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+import javax.swing.border.*;
+import javax.swing.text.*;
+import javax.swing.event.*;
+
+import java.applet.*;
+import java.util.*;
+
+
+public abstract class Util
+{
+ public static TitledBorder titleBorder;
+ static JPanel p;
+ public static Applet applet = null;
+
+ //undo
+ public static boolean debug = false;
+
+ public static final int BORDER_INSET = 5;
+
+ public static final Border EMPTY_BORDER_STYLE = new EmptyBorder(BORDER_INSET, BORDER_INSET, BORDER_INSET, BORDER_INSET);
+ public static final Border BORDER_STYLE = new CompoundBorder(new EmptyBorder(BORDER_INSET, BORDER_INSET, BORDER_INSET, BORDER_INSET),
+ new CompoundBorder(new EtchedBorder(Color.gray, Color.white),
+ new EmptyBorder(BORDER_INSET, BORDER_INSET, BORDER_INSET, BORDER_INSET)));
+
+ static final int BUTTON_TOP = 1;
+ static final int BUTTON_BOTTOM = 1;
+ static final int BUTTON_LEFT = 1;
+ static final int BUTTON_RIGHT = 1;
+ /**
+ * The default number of characters for text field.
+ */
+ public static int TEXTFIELD_NUM_CHARS = 12;
+
+ /**
+ * The default number of characters for text field.
+ */
+ public static int DATEFIELD_NUM_CHARS = 10;
+
+ /**
+ * The default number of characters for text field.
+ */
+ public static int TIMEFIELD_NUM_CHARS = 12;
+
+ /**
+ * Creates a popup menu with items in an array of string.
+ * No action listener is to be added for this method.
+ * @param items an array of String for the menu items
+ */
+ public static PopupMenu makePopupMenu(String[] items)
+ {
+ PopupMenu popup = new PopupMenu();
+ for (int i=0; i < items.length; i++) {
+ popup.add(new MenuItem(items[i]));
+ }
+ MenuItem mItem = new MenuItem("Copy");
+ popup.add(mItem);
+ return popup;
+ }
+
+ /**
+ * Creates a menu with a name of your choice, items in an array of strings, acttionCommands being
+ * items with spaces trimmed, and an action listener for all items.
+ * @param menuName the name of the menu
+ * @param items an array of String for the items
+ * @param listener action listener
+ */
+ public static JMenu makeMenu(String menuName, char hotkey, String[] items, ActionListener listener)
+ {
+ JMenu menu = makeMenu(menuName, hotkey);
+ JMenu submenu = null;
+ JMenuItem menuItem = null;
+ String itemString;
+ String queryName;
+ String submenuItems;
+ int comma;
+
+ for (int i=0; i < items.length; i++) {
+ //parse the items string
+ int index;
+ if ( (index = items[i].indexOf(":")) >= 0 ) {
+ //has submenu
+ queryName = items[i].substring(0,index).trim();
+ submenu = makeMenu( queryName );
+ submenuItems = items[i].substring(index+1).trim();
+ while ( submenuItems.length() > 0 ) {
+ comma = submenuItems.indexOf(",");
+ if ( comma >= 0 ) {
+ itemString = submenuItems.substring(0, comma).trim();
+ submenuItems = submenuItems.substring(comma+1).trim();
+ } else {
+ itemString = submenuItems;
+ submenuItems = "";
+ }
+ menuItem = makeMenuItem(itemString);
+ menuItem.setActionCommand( trimSpaces(queryName + ":" + itemString) );
+ if ( listener != null ) {
+ menuItem.addActionListener( listener );
+ }
+ submenu.add(menuItem);
+ }
+ menu.add( submenu );
+ } else { //no submenu
+ menuItem = makeMenuItem(items[i]);
+ menuItem.setActionCommand( trimSpaces(items[i]) );
+ if ( listener != null ) {
+ menuItem.addActionListener( listener );
+ }
+ menu.add( menuItem );
+ }
+ }
+ return menu;
+ }
+
+ /**
+ * Creates a menu with a name of your choice, items and action commands in an array of strings,
+ * and an action listener for all items.
+ * @param menuName the name of the menu
+ * @param items an array of String for the items
+ * @param commands action commands in an array of strings
+ * @param listener action listener
+ */
+ public static JMenu makeMenu(String menuName, char hotkey, String[] items, String[] commands, ActionListener listener)
+ {
+ JMenu menu = makeMenu(menuName, hotkey);
+ int index;
+ for (int i=0; i < items.length; i++) {
+ if ( (index = items[i].indexOf("_") ) >= 0 ) {
+ JMenu subMenu = makeMenu(items[i].substring(0, index));
+ JMenuItem item = makeMenuItem(items[i].substring(index+1) );
+ if ( listener != null ) {
+ item.addActionListener( listener );
+ }
+ subMenu.add(item);
+ menu.add(subMenu);
+ } else {
+ JMenuItem menuItem = makeMenuItem(items[i]);
+ menuItem.setActionCommand( commands[i] );
+ if ( listener != null )
+ menuItem.addActionListener( listener );
+ menu.add( menuItem );
+ }
+ }
+ return menu;
+ }
+
+ public static JMenu makeMenu(String name)
+ {
+ JMenu menu = new JMenu(name);
+ return menu;
+ }
+
+ public static JMenu makeMenu (String name, char mnemonic)
+ {
+ JMenu menu = new JMenu(name);
+ menu.setMnemonic(mnemonic);
+
+ return menu;
+ }
+
+
+
+ /**
+ * Creates a Swing label with preferred size and Style Guide conforming attributes
+ * @param text the text of Label
+ */
+ public static JLabel makeLabel(String text)
+ {
+ JLabel label = new JLabel(text,JLabel.RIGHT);
+ //label.setSize(label.getPreferredSize());
+ label.setVerticalAlignment(SwingConstants.CENTER);
+ return label;
+ }
+
+ /**
+ * Creates a label with alignment
+ * @param text the text of Label
+ * @alignment alignment horizontal alignment - JLabel.{LEFT,RIGHT,CENTER}
+ */
+ public static JLabel makeLabel(String text, int alignment)
+ {
+ JLabel label = makeLabel(text);
+ label.setHorizontalAlignment(alignment);
+ return label;
+ }
+
+ public static JLabel makeLabel(String text, char hotkey)
+ {
+ JLabel label = makeLabel(text);
+ label.setDisplayedMnemonic(hotkey);
+ return label;
+ }
+
+ public static JLabel makeLabel(String text, char hotkey, int alignment)
+ {
+ JLabel label = makeLabel(text, alignment);
+ label.setDisplayedMnemonic(hotkey);
+ return label;
+ }
+
+ public static JLabel makeLabel(String text, char hotkey, Component target)
+ {
+ JLabel label = makeLabel(text, hotkey);
+ label.setLabelFor(target);
+ return label;
+ }
+
+ public static JLabel makeLabel(String text, char hotkey, Component target, int alignment)
+ {
+ JLabel label = makeLabel(text, hotkey, target);
+ label.setHorizontalAlignment(alignment);
+ return label;
+ }
+
+ public static JTextField makeTextField()
+ {
+ return makeTextField(TEXTFIELD_NUM_CHARS);
+ }
+
+ /**
+ * Creates an non-editable Swing text field for holding numChars characters
+ * @param numChars holding numChars characters in width
+ */
+ public static JTextField makeTextField(int numChars)
+ {
+ return makeTextField("", numChars, false);
+ }
+
+ /**
+ * Creates a non-editable Swing text field with content text and default width
+ * @param text the text of field
+ */
+ public static JTextField makeTextField(String text)
+ {
+ return makeTextField(text, TEXTFIELD_NUM_CHARS, false);
+ }
+
+ /**
+ * Creates a Swing text field with intial content text, numChars in width, editable as set
+ * @param text the text of field
+ * @param numChars holding numChars characters for width
+ * @param editable to set editable or not
+ */
+ public static JTextField makeTextField(String text, int numChars, boolean editable)
+ {
+ WMTextField textField = new WMTextField( text, numChars );
+ textField.setEditable(editable);
+ return textField;
+ }
+
+ /**
+ * Creates a Swing text field with intial content text, numChars in width, editable as set
+ * @param dateDocument the date formating document
+ * @param text the text of field
+ * @param numChars holding numChars characters for width
+ * @param editable to set editable or not
+ */
+ /*
+ public static JTextField makeTextField( Document dateDocument, String text, int numChars, boolean editable)
+ {
+ JTextField textField = new WMTextField( dateDocument, text, numChars);
+ textField.setEditable(editable);
+ return textField;
+ }
+ */
+
+ /**
+ * Creates a Swing non-editable text field with intial content text, numChars in width
+ * @param text the text of field
+ * @param numChars holding numChars characters for width
+ */
+ public static JTextField makeTextField(String text, int numChars)
+ {
+ return makeTextField(text, numChars, false);
+ }
+
+ /**
+ * Creates a Swing text field with editability settable
+ * @param editable to set editable or not
+ */
+ public static JTextField makeTextField(boolean editable)
+ {
+ return makeTextField("", TEXTFIELD_NUM_CHARS, editable);
+ }
+
+ public static JTextField makeTextField(boolean editable, String markup)
+ {
+ WMTextField field= (WMTextField) makeTextField("", TEXTFIELD_NUM_CHARS, editable);
+ field.setMagicMarkup(markup);
+ return field;
+ }
+
+ /**
+ * Creates a Swing text field with editability settable and with numChars in width
+ * @param numChars holding numChars characters for width
+ * @param editable to set editable or not
+ */
+ public static JTextField makeTextField(int numChars, boolean editable)
+ {
+ return makeTextField("", numChars, editable);
+ }
+
+
+ /**
+ * Creates a Swing button
+ * @param text the text on the button
+ */
+ public static JButton makeButton(String text)
+ {
+ JButton button = new JButton(text);
+ button.setMargin(new Insets(BUTTON_TOP,BUTTON_BOTTOM,BUTTON_LEFT,BUTTON_RIGHT));
+ return button;
+ }
+
+ /**
+ * Creates a Swing button with shortcut
+ * @param text the text on the button
+ * @param hotkey mnemonic character (underlined)
+ */
+ public static JButton makeButton(String text, char hotkey)
+ {
+ JButton button = makeButton(text);
+ button.registerKeyboardAction(null, KeyStroke.getKeyStroke(hotkey,java.awt.Event.ALT_MASK,false),
+ JComponent.WHEN_IN_FOCUSED_WINDOW);
+ button.setMnemonic(hotkey);
+ return button;
+ }
+
+ /**
+ * Creates a Swing button with shortcut and tooltip
+ * @param text the text on the button
+ * @param hotkey mnemonic character (underlined)
+ * @param tooltip text for the button's tooltip
+ */
+ public static JButton makeButton(String text, char hotkey, String tooltip)
+ {
+ JButton button = makeButton(text);
+ button.setMnemonic(hotkey);
+ button.setToolTipText(tooltip);
+ return button;
+ }
+
+
+ /**
+ * Creates a Swing button with shortcut, tooltip, and listener
+ * @param text the text on the button
+ * @param hotkey mnemonic character (underlined)
+ * @param tooltip text for the button's tooltip
+ * @param listener actionlistener
+ */
+ public static JButton makeButton(String text, char hotkey, String tooltip, ActionListener listener)
+ {
+ JButton button = makeButton(text, hotkey, tooltip);
+ button.addActionListener(listener);
+ return button;
+ }
+
+ /**
+ * Create a JButton with Icon
+ * @param text the text on the button
+ * @param icon the image on the button
+ */
+ public static JButton makeButton(String text, ImageIcon icon)
+ {
+ JButton button = new JButton(text, icon);
+ button.setMargin(new Insets(BUTTON_TOP,BUTTON_BOTTOM,BUTTON_LEFT,BUTTON_RIGHT));
+ return button;
+ }
+
+ /**
+ * create JButton with icon and hot key
+ */
+ public static JButton makeButton(String text, ImageIcon icon, char hotkey)
+ {
+ JButton button = makeButton(text, icon);
+ button.setMnemonic(hotkey);
+ return button;
+ }
+
+ /**
+ * create JButton with icon, hotkey and tooltip
+ * @param text
+ * @param icon
+ * @param hotkey
+ * @param tooltip
+ */
+ public static JButton makeButton(String text, ImageIcon icon, char hotkey, String tooltip)
+ {
+ JButton button = makeButton(text, icon, hotkey);
+ button.setToolTipText(tooltip);
+ return button;
+ }
+
+ /**
+ * create JButton with icon, hotkey and tooltip, and listener
+ * @param text
+ * @param icon
+ * @param hotkey
+ * @param tooltip
+ * @param listener
+ */
+ public static JButton makeButton(String text, ImageIcon icon, char hotkey, String tooltip, ActionListener listener)
+ {
+ JButton button = makeButton(text, icon, hotkey, tooltip);
+ button.addActionListener(listener);
+ return button;
+ }
+
+
+ /**
+ * create JButton with icon and tooltip
+ */
+ public static JButton makeButton(ImageIcon icon, String tooltip)
+ {
+ JButton button = new JButton(icon);
+ button.setMargin(new Insets(BUTTON_TOP,BUTTON_BOTTOM,BUTTON_LEFT,BUTTON_RIGHT));
+ button.setToolTipText(tooltip);
+ return button;
+ }
+
+ /**
+ * Creates a Swing panel
+ */
+ public static JPanel makePanel()
+ {
+ JPanel p = new JPanel();
+ return p;
+ }
+
+ /**
+ * Creates a panel with layout
+ */
+ public static JPanel makePanel(LayoutManager layout)
+ {
+ JPanel p = makePanel();
+ p.setLayout(layout);
+ return p;
+ }
+
+ /**
+ * Creates a Swing bordered panel
+ * @param title the title of the border
+ */
+ public static JPanel makeBorderPanel(String title)
+ {
+ p = makePanel();
+ p.setBorder(BORDER_STYLE);
+ titleBorder = new TitledBorder(p.getBorder(), title);
+ p.setBorder(titleBorder);
+ return p;
+ }
+ public static void setBorderTitle(String title){
+ System.out.println("setting title" + title);
+ titleBorder.setTitle(title);
+ p.validate();
+ }
+
+ public static String getBorderTitle(){
+ return titleBorder.getTitle();
+ }
+
+ /**
+ * Creates a Swing bordered panel with layout
+ * @param title the title of the border
+ * @param layout layout
+ */
+ public static JPanel makeBorderPanel(String title, LayoutManager layout)
+ {
+ JPanel p = makeBorderPanel(title);
+ p.setLayout(layout);
+ return p;
+ }
+
+
+ /**
+ * Creates a Swing bordered panel with no title
+ */
+ public static JPanel makeBorderPanel()
+ {
+ return makeBorderPanel("");
+ }
+
+
+ /**
+ * Creates a Swing bordered panel with NO border
+ * Why this ? to add the space of border to line up with other bordered panels
+ */
+ public static JPanel makeEmptyBorderPanel()
+ {
+ JPanel p = makePanel();
+ p.setBorder(EMPTY_BORDER_STYLE);
+ return p;
+ }
+
+ /**
+ * Creates a Swing bordered panel with NO border
+ * Is this different from makeEmptyBorderPanel ?
+ * To be answered....
+ */
+ public static JPanel makeHugeEmptyBorderPanel()
+ {
+ JPanel p = makePanel();
+ p.setBorder(new CompoundBorder(EMPTY_BORDER_STYLE,
+ EMPTY_BORDER_STYLE));
+ return p;
+ }
+
+ /**
+ * Remove all space characters in a given string.
+ * @param s the string to be trimmed
+ */
+ public static String trimSpaces(String s)
+ {
+ String r="";
+ if ( s == null )
+ return null;
+
+ for (int i=0; i < s.length(); i++)
+ if ( s.charAt(i) != ' ' )
+ r = r + s.charAt(i);
+
+ return r;
+ }
+
+
+ /**
+ * Makes a JRadioButton showing text with key as the accelerator
+ * @param text the text of the button
+ * @param key the accelerator key
+ */
+ public static JRadioButton makeRadioButton(String text, char key)
+ {
+ JRadioButton rb = new JRadioButton(text);
+ rb.setMnemonic(key);
+ return rb;
+ }
+
+
+ /**
+ * Makes a JRadioButton showing text without key accelerator
+ * @param text the text of the button
+ */
+ public static JRadioButton makeRadioButton(String text)
+ {
+ JRadioButton rb = new JRadioButton(text);
+ return rb;
+ }
+
+ public static JTextArea makeTextArea(int r, int c, boolean editable)
+ {
+ JTextArea area = new JTextArea(r,c);
+ area.setEditable(editable);
+
+ return area;
+ }
+
+
+ public static JTextArea makeTextArea()
+ {
+ return makeTextArea("");
+ }
+
+ /**
+ * Makes a text area with a populated string
+ * @param text populate area with string
+ */
+ public static JTextArea makeTextArea(String s)
+ {
+ return new JTextArea(s);
+ }
+
+ public static JComboBox makeComboBox(boolean editable)
+ {
+ JComboBox cb = new JComboBox();
+ cb.setEditable( editable );
+ return cb;
+ }
+
+
+ /**
+ * Makes a JComboBox with an array of String for items with default size
+ * @param items an array of strings
+ * @param selectedItemIndex the index of the item to be selected by default
+ * @param editable editable or not
+ */
+ public static JComboBox makeComboBox(String[] items, int selectedItemIndex,
+ boolean editable)
+ {
+ return makeComboBox(items, selectedItemIndex, editable, null);
+ }
+
+ /**
+ * Makes a JComboBox with an array of String for items
+ * @param items an array of strings
+ * @param selectedItemIndex the index of the item to be selected by default
+ * @param editable editable or not
+ * @param dimension the dimension of the box
+ */
+ public static JComboBox makeComboBox(String[] items, int selectedItemIndex,
+ boolean editable, Dimension dimension)
+ {
+ JComboBox cb = new JComboBox();
+ for (int i=0; i < items.length; i++)
+ cb.addItem(items[i]);
+
+ cb.setEditable( editable );
+ cb.setSelectedItem( items[selectedItemIndex] );
+ if ( dimension != null )
+ cb.setPreferredSize( dimension );
+
+ return cb;
+ }
+
+ /**
+ * Makes an empty menu item.
+ */
+ public static JMenuItem makeMenuItem()
+ {
+ return makeMenuItem("");
+ }
+
+ /**
+ * Makes a menu item with an icon.
+ * @param icon image icon
+ */
+ public static JMenuItem makeMenuItem(Icon icon)
+ {
+ JMenuItem m = makeMenuItem();
+ m.setIcon(icon);
+ return m;
+ }
+
+ /**
+ * Makes a menu item with a label and icon.
+ * @param text menu label
+ * @param icon image icon
+ */
+ public static JMenuItem makeMenuItem(String text,Icon icon)
+ {
+ JMenuItem m = makeMenuItem(text);
+ m.setIcon(icon);
+ return m;
+ }
+
+ /**
+ * Makes a menu item with a label and shortcut key.
+ * @param text menu label
+ * @param mnemonic underlined character in label
+ */
+ public static JMenuItem makeMenuItem(String text, char mnemonic)
+ {
+ JMenuItem m = makeMenuItem(text);
+ m.setMnemonic(mnemonic);
+ m.registerKeyboardAction(null, KeyStroke.getKeyStroke(mnemonic,java.awt.Event.ALT_MASK,false),
+ JComponent.WHEN_IN_FOCUSED_WINDOW);
+ return m;
+ }
+
+ /**
+ * Makes a menu item with a label
+ * @param text menu label
+ */
+ public static JMenuItem makeMenuItem(String text)
+ {
+ return new JMenuItem(text);
+ }
+
+ public static JMenuItem makeMenuItem(String text, Icon icon, char mnemonic)
+ {
+ JMenuItem m = new JMenuItem(icon);
+ m.setText(text);
+ m.setMnemonic(mnemonic);
+
+ return m;
+ }
+
+
+ /**
+ * Makes a text area that looks like a multiline
+ * wrapping label that word wraps
+ * @param initial value of textarea
+ */
+ public static JTextArea makeWrappingLabel(String s)
+ {
+ JTextArea ta = new JTextArea(s);
+ ta.setLineWrap(true);
+ //ta.setWrapStyleWord(true);
+ ta.setOpaque(false);
+ ta.setEditable(false);
+ ta.setBorder(new EmptyBorder(0,0,0,0));
+ ta.setSelectionColor(UIManager.getDefaults().getColor("Label.background"));
+ ta.setFont(UIManager.getDefaults().getFont("Label.font"));
+ return ta;
+ }
+
+ static public void constrain(Component component, Container container, GridBagConstraints gbc,
+ int grid_x, int grid_y, int grid_width, int grid_height,
+ int fill, int anchor, double weight_x, double weight_y,
+ int top, int left, int bottom, int right)
+ {
+ gbc.gridx = grid_x;
+ gbc.gridy = grid_y;
+ gbc.gridwidth = grid_width;
+ gbc.gridheight = grid_height;
+ gbc.fill = fill;
+ gbc.anchor = anchor;
+ gbc.weightx = weight_x;
+ gbc.weighty = weight_y;
+ if (top+bottom+left+right > 0)
+ gbc.insets = new Insets(top, left, bottom, right);
+
+ ((GridBagLayout)container.getLayout()).setConstraints(component, gbc);
+ container.add(component);
+ }
+
+ static public void showDialog(JFrame frame, String message, String title, int type)
+ {
+ JOptionPane.showMessageDialog(frame, message, title, type);
+ }
+
+ static public void showDialog(String message, String title)
+ {
+ showDialog(message, title, JOptionPane.INFORMATION_MESSAGE);
+ }
+
+ static public void showDialog(String message, String title, int type)
+ {
+ showDialog(new JFrame(), message, title, type);
+ }
+
+ static public void showDialog(String message)
+ {
+ showDialog(message, "");
+ }
+
+ static public void showDialog(Exception e)
+ {
+ showDialog(e.toString(), "Exception");
+ }
+
+ static public String average(Vector v)
+ {
+ int sum =0;
+ for(int i=0; i< v.size(); i++)
+ {
+ try {
+ sum += Integer.parseInt((String) v.elementAt(i));
+ }
+ catch(Exception e) {}
+
+ }
+
+ return String.valueOf(sum/v.size());
+ }
+
+ static public boolean IsDigit(String s)
+ {
+ for (int i=0; i< s.length(); i++)
+ {
+ if (!Character.isDigit(s.charAt(i)))
+ return false;
+ }
+ return true;
+ }
+}
+//$History:$
diff --git a/data/mnet/Common/Java/com/jetcell/MibWM/WMTextField.java b/data/mnet/Common/Java/com/jetcell/MibWM/WMTextField.java
new file mode 100644
index 0000000..ff7ca7e
--- /dev/null
+++ b/data/mnet/Common/Java/com/jetcell/MibWM/WMTextField.java
@@ -0,0 +1,156 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// Class : WMTextField
+// Desc : TextField widget for Web Management Browser
+// Author : George Zhao
+// History: April 22, 1999 Initial Creation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+package com.jetcell.MibWM;
+
+import java.util.*;
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+
+/**
+ * Subclass of JTextfield that add a right mouse button triggered
+ * popupmenu for cut/copy/paste/delete functionality.
+ *
+ * @see TextComponentPopupMenu
+ * @version 1.0
+ * @author George Zhao
+ */
+
+public class WMTextField extends JTextField implements FocusListener
+{
+ static TextComponentPopupMenu popupMenu = TextComponentPopupMenu.getPopupMenu();
+
+ /**
+ * Previous value is tracked to make sure duplicates don't make it into
+ * the paste recent menu.
+ */
+ String previousValue="";
+ String magicMarkup = "";
+
+ public WMTextField()
+ {
+ super();
+ init();
+ }
+
+ public WMTextField(String text)
+ {
+ super(text);
+ init();
+ }
+
+ public WMTextField(int columns)
+ {
+ super(columns);
+ init();
+ }
+
+ public WMTextField(String text, int columns)
+ {
+ super(text,columns);
+ init();
+ }
+
+ /**
+ * Adds focusListener to textfield
+ */
+ void init()
+ {
+ addFocusListener(this);
+ //{{INIT_CONTROLS
+ //}}
+ }
+
+
+ public void focusGained(FocusEvent e) {};
+
+ /**
+ * Listens for focusLost event to trigger updates to
+ * the paste recent popup menu
+ * @param e FocusEvent
+ */
+ public void focusLost(FocusEvent e)
+ {
+ String value = getTrimmedText();
+ if ((value.length() > 0) && (!value.equals(previousValue)))
+ {
+ previousValue = value;
+ popupMenu.addToMostRecentList(value);
+ }
+ }
+
+ /**
+ * Captures right mouse button mouse events to invoke popup menu.
+ * @param e MouseEvent
+ */
+ public void processMouseEvent(MouseEvent e)
+ {
+ if (e.getModifiers() == InputEvent.BUTTON3_MASK)
+ {
+ if (e.isPopupTrigger())
+ {
+ popupMenu.show(e.getComponent(),
+ e.getX(),
+ e.getY(),
+ getSelectionStart(),
+ getSelectionEnd());
+ }
+ }
+ else
+ super.processMouseEvent(e);
+ }
+
+ /**
+ * Returns text without with leading and trailing spaces
+ */
+ public String getTrimmedText()
+ {
+ return getText().trim();
+ }
+
+ /**
+ * Sets the text. Keeps track of previous value.
+ */
+ public void setText(String s)
+ {
+ super.setText(s);
+ previousValue = s;
+ repaint();
+ }
+
+ /**
+ * Swing bug - force repaint on setEditable() to refresh color
+ */
+ public void setEditable(boolean b)
+ {
+ super.setEditable(b);
+ if(b) {
+ //setBackground(UIManager.getDefaults().getColor("TextField.background"));
+ setBackground(Color.white);
+ }
+ else {
+ //setBackground(UIManager.getDefaults().getColor("Label.background"));
+ setBackground(Color.lightGray);
+ }
+ repaint();
+ }
+
+ public void setMagicMarkup(String markup)
+ {
+ magicMarkup = markup;
+ }
+
+ public String getMagicMarkup()
+ {
+ return magicMarkup;
+ }
+}
+
+//$History:$ \ No newline at end of file
diff --git a/data/mnet/Common/Java/java.mk b/data/mnet/Common/Java/java.mk
new file mode 100644
index 0000000..7bf6cf7
--- /dev/null
+++ b/data/mnet/Common/Java/java.mk
@@ -0,0 +1,60 @@
+####################################################################
+#
+# FILE NAME: Java.mk
+#
+# DESCRIPTION: This file needs to be included by every makefile that
+# compiles Java source files.
+#
+# COMPONENTS:
+#
+#
+# NOTES:
+#
+# (C) Copyright 1999 JetCell Inc., CA, USA http://www.jetcell.com/
+#
+# REVISION HISTORY
+#__________________________________________________________________
+#----------+--------+----------------------------------------------
+# Name | Date | Reason
+#----------+--------+----------------------------------------------
+# Bhawani |11/28/99| Iniitial Draft
+#----------+--------+----------------------------------------------
+####################################################################
+#/
+
+# Hard-coded path should point to the network drive
+RLROOT = ..\..\..\THIRD_PARTY\OamTools
+RLROOT2 = ..\..\THIRD_PARTY\OamTools
+RLIROOT = $(RLROOT)\rl
+RLIROOT2 = $(RLROOT2)\rl
+JDKROOT = $(CODEBASE)\..\..\THIRD_PARTY\OamTools\jdk1.3
+
+RM = del
+CP = copy
+
+MIBWMPATH = $(CODEBASE)\com\jetcell\MibWM
+VIPERCELL = $(MIBWMPATH)
+VIPERBASE = $(MIBWMPATH)\ViperBase
+COMMON = $(CODEBASE)\Java
+OUTPUTDIR = $(CODEBASE)\..\..\GMC\GMCManager
+ALARMAPPLETDIR = $(CODEBASE)\AlarmApplet
+
+ifeq ($(SOURCE_LIST),)
+ SOURCE_LIST = $(wildcard *.java)
+
+endif
+
+CLASS_LIST = $(SOURCE_LIST:.java=.class)
+
+# java compiler and archive maker
+JAR = $(JDKROOT)\bin\jar.exe
+JAVAC = $(JDKROOT)\bin\javac.exe
+
+CLASSPATH = .;$(ALARMAPPLETDIR);$(CODEBASE);$(JDKROOT)/lib;$(JDKROOT)/lib/classes.zip;$(RLROOT);/$(RLIROOT)/jcit/symbeans.jar;$(RLIROOT)/jcit/Jars/Gauges.jar;$(RLIROOT)/jcit/Jars/RLBeans.jar
+
+
+# rule to compile Java source files
+%.class : %.java
+# - @ $(RM) $(subst /,$(DIRCHAR),$@)
+ $(JAVAC) -classpath $(CLASSPATH) $(subst /,\, $<)
+
diff --git a/data/mnet/Common/Os/Makefile b/data/mnet/Common/Os/Makefile
new file mode 100644
index 0000000..9347a18
--- /dev/null
+++ b/data/mnet/Common/Os/Makefile
@@ -0,0 +1,28 @@
+##########################################################
+#
+# (c) Copyright Cisco 2000
+# All Rights Reserved
+#
+# Use Examples:
+#
+# Case 1: make all VOB=GP10 -
+# Places .out in VOB/bin directory
+#
+# Case 2: make all VOB=GP10 APPDIR=Host\vxTemplate\bin -
+# Places .o file(s) in VOB/$(APPDIR) directory.
+#
+# Note: This make file must reference a VOB that
+# has a defs.mk in the top level directory.
+#
+##########################################################
+
+SUBDIRS = src loadmodule
+
+# TOP_OF_VOB must be defined before including l3defs.mk
+TOP_OF_VOB = ..\..
+
+VOBDIR = $(TOP_OF_VOB)\$(VOB)
+
+include $(VOBDIR)\l3defs.mk
+
+
diff --git a/data/mnet/Common/Os/include/JCMsgQDefs.h b/data/mnet/Common/Os/include/JCMsgQDefs.h
new file mode 100644
index 0000000..45e2730
--- /dev/null
+++ b/data/mnet/Common/Os/include/JCMsgQDefs.h
@@ -0,0 +1,40 @@
+// *******************************************************************
+//
+// (c) Copyright Cisco 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// Status : Under development
+// File : JCMsgQDefs.h
+// Author(s) : Tim Olson
+// Create Date : 9/18/2000
+// Description :
+//
+// *******************************************************************
+#ifndef _JCMSGQDEFS_H_
+#define _JCMSGQDEFS_H_ /* include once only */
+
+#include "Os/JCMsgQueue.h"
+#include "MnetModuleId.h"
+
+
+/* THIS IS FOR MESSAGE QUEUE INTERNAL ONLY!!!! */
+
+typedef struct jc_msg_hdr {
+ JCMsgQueue *rplyQ; /* identifier of queue to which to reply,
+ if any */
+ unsigned int msgType; /* module dependent message type */
+ MNET_MODULE_ID modId; /* module ID of sender */
+ int bytes; /* size of associated data */
+ } JC_MSG_HDR;
+/* data follows header */
+
+
+#define JC_MSG_HDR_SIZE sizeof(JC_MSG_HDR)
+
+
+#endif
diff --git a/data/mnet/Common/Os/loadmodule/LoadModule.cpp b/data/mnet/Common/Os/loadmodule/LoadModule.cpp
new file mode 100644
index 0000000..a339b48
--- /dev/null
+++ b/data/mnet/Common/Os/loadmodule/LoadModule.cpp
@@ -0,0 +1,195 @@
+// *******************************************************************
+//
+// (c) Copyright Cisco 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// Status : Under development
+// File : LoadModule.cpp
+// Author(s) : Kevin Lim
+// Create Date : 04-14-99
+// Description : Functions to load modules
+//
+// *******************************************************************
+
+// *******************************************************************
+// Include Files.
+// *******************************************************************
+#include "vxWorks.h"
+#include "dosFsLib.h"
+#include "loadLib.h"
+#include "ioLib.h"
+#include "stdio.h"
+#include "string.h"
+
+#ifdef GMC_VOB_SPECIFIC
+#include <oam_api.h>
+#include <vipermib.h>
+#endif /* GMC_VOB_SPECIFIC */
+
+#define UNIX_FILE_EOFS
+
+#ifdef UNIX_FILE_EOFS
+#define EOL_TRUNC_LEN 1
+#else
+#define EOL_TRUNC_LEN 2
+#endif
+
+// *******************************************************************
+int viperLoad(char * filename)
+{
+ int fd;
+ MODULE_ID mId;
+
+#ifdef NEVER // changed from GMC_VOB_SPECIFIC by oleg
+ Ss7Type* networkType;
+ char* fn;
+
+ if ((fn = strstr(filename, "gmccpapp.out"))
+ != NULL)
+ {
+ if( NULL != ( networkType = (Ss7Type*)oam_getMibAddress( MIB_ss7NetworkType ) ))
+ {
+
+ if (*networkType == ansi)
+ {
+ printf ("Mib returned ansi for loading.\n");
+ strcpy(fn, "gmccpapp-ansi.out");
+ }
+ else
+ {
+ printf ("Mib returned itu for loading.\n");
+ strcpy(fn, "gmccpapp-itu.out");
+ }
+ }
+ else
+ {
+ printf ("Major Error reading network type from the Mib. Cannot load GMC CP.\n");
+ return (-1);
+ }
+ }
+
+#endif /* GMC_VOB_SPECIFIC */
+
+ printf("Loading %s\n", filename);
+ fd = open (filename, 0, 0);
+ if(fd == ERROR)
+ {
+ // error on open object file
+ printf("[loadMod] Fatal Error on fopen(%s) return ERROR\n", filename);
+ return ERROR;
+ }
+ mId = loadModule (fd, LOAD_ALL_SYMBOLS);
+ if(mId == NULL)
+ {
+ // error on loading module
+ printf("[loadMod] Fatal Error on loadModule() return NULL\n");
+ return (-1);
+ }
+ close (fd);
+ return (int)mId;
+}
+
+// *******************************************************************
+#define VIPER_MAX_BASE_PREFIX 100
+#define VIPER_MAX_MODULE_LINE 180
+// *******************************************************************
+extern "C"
+{
+void viperLoadList(char * filename, char * base, int append)
+{
+ char base_line[VIPER_MAX_MODULE_LINE];
+ char line[VIPER_MAX_MODULE_LINE];
+ FILE * fd;
+ char * lp;
+ int base_len = strlen(base);
+ int i, line_len;
+ bool done = false;
+
+ if(base_len > VIPER_MAX_BASE_PREFIX){
+ printf("[viperLoadList] base string too long %d\n", base_len);
+ return;
+ }
+ else{
+ for(i=0; i<base_len; i++) base_line[i] = base[i];
+ base_line[i]='/';
+ base_len++;
+ }
+
+ if(append){
+ int filename_len = strlen(filename);
+ if((base_len+filename_len)>VIPER_MAX_MODULE_LINE){
+ printf("[viperLoadList] base + module list name too long: %d\n", base_line+filename_len);
+ printf("%s%s\n", base_line, filename);
+ return;
+ }
+ for(i=0; i<filename_len; i++) base_line[base_len+i] = filename[i];
+ // mark null
+ base_line[base_len+i] = '\0';
+ fd = fopen(base_line, "r");
+ if(fd == NULL){
+ printf("[viperLoadList] Error on openning module list file: %s\n", base_line);
+ return;
+ }
+ else{
+ printf("[viperLoadList] Loading modules from: %s\n", base_line);
+ }
+ }
+ else{
+ fd = fopen(filename, "r");
+ if(fd == NULL){
+ printf("[viperLoadList] Error on openning module list file: %s\n", filename);
+ return;
+ }
+ else{
+ printf("[viperLoadList] Loading modules from: %s\n", filename);
+ }
+ }
+
+ while(!done){
+ lp = fgets(line, 80, fd);
+ if(lp == NULL){
+ done = true;
+ }
+ else{ // parse the line
+ line_len = strlen(lp);
+ if(lp[0] == '#'){ // do not append base
+ if(line_len>VIPER_MAX_MODULE_LINE){
+ printf("[viperLoadList] module line too long: %d\n", line_len);
+ printf("%s\n", line);
+ fclose(fd);
+ return;
+ }
+ // mark null at eol
+ lp[line_len-EOL_TRUNC_LEN] = '\0';
+ viperLoad(&line[1]); // exclude #
+ }
+ else if(lp[0] == '!'){ // comment fields
+ printf("%s", lp);
+ }
+ else if(line_len<3){ // probably blank line
+
+ }
+ else{ //append to the line
+ if((base_len+line_len)>VIPER_MAX_MODULE_LINE){
+ printf("[viperLoadList] base + module line too long: %d\n", base_line+line_len);
+ printf("%s%s\n", base_line, line);
+ fclose(fd);
+ return;
+ }
+ for(i=0; i<line_len; i++) base_line[base_len+i] = lp[i];
+ // mark null
+ base_line[base_len+i-EOL_TRUNC_LEN] = '\0';
+ viperLoad(base_line);
+ }
+ } // end parse
+ }
+ fclose(fd);
+}
+}
+
+
diff --git a/data/mnet/Common/Os/loadmodule/Makefile b/data/mnet/Common/Os/loadmodule/Makefile
new file mode 100644
index 0000000..5eeffdb
--- /dev/null
+++ b/data/mnet/Common/Os/loadmodule/Makefile
@@ -0,0 +1,62 @@
+##########################################################
+#
+# (c) Copyright Cisco 2000
+# All Rights Reserved
+#
+# Use Examples:
+#
+# Case 1:
+# make all VOB=GP10 -
+# Places .out in VOB/bin directory
+#
+# Case 2:
+# make all VOB=GP10 APPDIR=Host\<Application Name>\<Source Directory> -
+# Places .o file(s) in VOB\$(APPDIR)\bin directory.
+#
+# <Application Name> = Name of Application directory
+# <Source Directory> = application sub directory where the calling
+# Makefile resides.
+#
+# Example: make all VOB=GP10 APPDIR=Host\vxTemplate\src
+#
+#
+# Note: This make file must reference a VOB that
+# has a defs.mk in the top level directory.
+#
+##########################################################
+
+# TOP_OF_VOB must be defined before including l3defs.mk
+TOP_OF_VOB = ..\..
+
+# Name of this App's Directory
+COMMON_APP_DIR = loadmodule
+
+VOB2DIR = $(TOP_OF_VOB)\..\$(VOB)
+BINDIR = ..\bin
+
+ifeq ($(APPDIR),)
+ MY_OUTPUT = $(VOB2DIR)\bin\$(COMMON_APP_DIR).out
+else
+ MY_OUTPUT = $(OBJDIR)\$(COMMON_APP_DIR).out
+endif
+
+include $(VOB2DIR)\l3defs.mk
+
+
+all: $(MY_OUTPUT)
+
+$(MY_OUTPUT): $(MODULE_OBJS)
+ $(LD) -r -o $@.tmp $(MODULE_OBJS)
+ $(NM) $@.tmp | munch > _ctdt.c
+ $(CC) -traditional $(CC_ARCH_SPEC) -c _ctdt.c
+ $(LD) -r -o $@ _ctdt.o $@.tmp
+ $(RM)$(subst /,$(DIRCHAR), _ctdt.c _ctdt.o $@.tmp)
+
+
+cleanall:
+ @for %f in ($(notdir $(MODULE_OBJS))) do \
+ $(RM) ..\bin\%f
+
+ $(RM) $(MY_OUTPUT)
+
+
diff --git a/data/mnet/Common/Os/src/JCCTimer.cpp b/data/mnet/Common/Os/src/JCCTimer.cpp
new file mode 100644
index 0000000..d2de948
--- /dev/null
+++ b/data/mnet/Common/Os/src/JCCTimer.cpp
@@ -0,0 +1,91 @@
+// *******************************************************************
+//
+// (c) Copyright Cisco 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// Status : Under development
+// File : JCCTimer.cpp
+// Author(s) : Bhava Nelakanti
+// Create Date : 10-19-98
+// Description : interface specification for - JCCTimer
+//
+// *******************************************************************
+
+// *******************************************************************
+// Include Files.
+// *******************************************************************
+
+#include <stdio.h>
+#include "Os/JCCTimer.h"
+
+extern "C" int sysClkRateGet (void);
+
+#define JCCLog printf
+
+int JCCTimer::tickPerSec = sysClkRateGet();
+
+
+void JCCTimer::cancelTimer()
+{
+ if (timerSet_ == true)
+ {
+ wdCancel(timerId_);
+ timerSet_ = false;
+ }
+}
+
+JCCTimer::~JCCTimer()
+{
+ wdDelete(timerId_);
+}
+
+JCCTimer::JCCTimer (FUNCPTR fPtr ,
+ int timerData)
+ :timerData_(timerData),
+ funcPtr_ (fPtr) ,
+ timerSet_ (false)
+{
+ init ();
+}
+
+
+JCCTimer::JCCTimer (FUNCPTR fPtr)
+ :timerData_(-1) ,
+ funcPtr_ (fPtr) ,
+ timerSet_ (false)
+{
+ init ();
+}
+
+
+void JCCTimer::setTimer(int howLong)
+{
+ if (timerSet_ == true)
+ {
+ cancelTimer();
+ }
+
+ wdStart(timerId_, howLong, funcPtr_, timerData_);
+
+ timerSet_ = true;
+}
+
+
+void JCCTimer::init()
+{
+ if (!tickPerSec)
+ tickPerSec = sysClkRateGet ();
+
+ if ((timerId_ = wdCreate()) == NULL)
+ {
+ // Handle Operating System Resource Allocation Error
+ JCCLog("JCC Error - Operating System Resource Allocation Error:\n");
+ JCCLog(" - WatchDog Timer could not be created.\n");
+ }
+}
+
diff --git a/data/mnet/Common/Os/src/JCModule.cpp b/data/mnet/Common/Os/src/JCModule.cpp
new file mode 100644
index 0000000..a94a73b
--- /dev/null
+++ b/data/mnet/Common/Os/src/JCModule.cpp
@@ -0,0 +1,470 @@
+// *******************************************************************
+//
+// (c) Copyright Cisco 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// Status : Under development
+// File : JCModule.cpp
+// Author(s) : Tim Olson
+// Create Date : 10/18/2000
+// Description :
+//
+// *******************************************************************
+
+#include <stdio.h>
+#include <errNoLib.h>
+#include <string.h>
+#include <ioLib.h>
+#include <dbgLib.h>
+#include <usrLib.h>
+#include "Os/JCModule.h"
+#include "AlarmCode.h"
+
+/*----------------------------------------------------------------------------**
+**
+** METHOD NAME: JCModule constructor
+**
+** PURPOSE: Initialize data members for JCModule object.
+**
+** INPUT PARAMETERS: id - module id
+**
+** RETURN VALUE(S): none
+**
+**----------------------------------------------------------------------------*/
+JCModule::JCModule
+(
+ MNET_MODULE_ID id,
+ JC_SYSCMD_FUNC cmdFunc,
+ char *cmdFuncStr
+) : modId(id), numRun(0), numSub(0)
+{
+ char *name = GetMnetModuleName(id);
+ if (name)
+ {
+ modName = new char[strlen(name) + 1];
+ if (modName)
+ {
+ strcpy(modName, name);
+ }
+ else
+ {
+ printf("JCModule::JCModule ERROR: Unable to allocate memory\n");
+ }
+ }
+ else
+ {
+ modName = 0;
+ }
+
+
+ if (!TestSym(cmdFuncStr))
+ {
+ syscmd = cmdFunc;
+ isModuleLoaded = TRUE;
+ }
+ else
+ {
+ isModuleLoaded = FALSE;
+ }
+
+ for (int i=0; i < MAX_NUM_SUB_TASKS; i++)
+ {
+ tasks[i] = 0;
+ }
+}
+
+
+
+/*----------------------------------------------------------------------------**
+**
+** METHOD NAME: JCModule destructor
+**
+** PURPOSE: Delete data members for JCModule object.
+**
+** INPUT PARAMETERS: none
+**
+** RETURN VALUE(S): none
+**
+**----------------------------------------------------------------------------*/
+JCModule::~JCModule ()
+{
+ delete [] modName;
+}
+
+
+
+/*----------------------------------------------------------------------------**
+**
+** METHOD NAME: JCModule InsertTaskInfo
+**
+** PURPOSE: InsertTaskInfo adds the task object to the list of tasks
+** currently running under this module.
+**
+** INPUT PARAMETERS: id - module id
+** pTask - pointer to the new task object
+**
+** RETURN VALUE(S): none
+**
+**----------------------------------------------------------------------------*/
+void JCModule::InsertTaskInfo(MNET_MODULE_ID id, JCTask *pTask)
+{
+ for (int j=0; j < MNET_MAX_MODULE_IDS; j++)
+ {
+ if (systemModules[j])
+ {
+ if (systemModules[j]->modId == id)
+ {
+ for (int i=0; i < MAX_NUM_SUB_TASKS; i++)
+ {
+ if (!systemModules[j]->tasks[i])
+ {
+ systemModules[j]->tasks[i] = pTask;
+ systemModules[j]->numSub++;
+ break;
+ }
+ }
+ break;
+ }
+ }
+ }
+}
+
+
+
+
+/*----------------------------------------------------------------------------**
+**
+** METHOD NAME: JCModule StartModule
+**
+** PURPOSE: StartModule sends a SYS_START system command to the module.
+**
+** INPUT PARAMETERS: none
+**
+** RETURN VALUE(S): TRUE - if module is loaded
+** FALSE - if module is not loaded
+**
+**----------------------------------------------------------------------------*/
+bool JCModule::StartModule()
+{
+ bool ret = FALSE;
+
+ if (isModuleLoaded)
+ {
+ if (!numRun)
+ {
+ printf("SysCommand(SYS_START): %s\n", modName);
+
+ syscmd(SYS_START);
+ numRun++;
+ }
+ else
+ {
+ printf("Module %d already started\n", modId);
+ }
+ ret = TRUE;
+ }
+
+ return(ret);
+}
+
+
+/*----------------------------------------------------------------------------**
+**
+** METHOD NAME: JCModule ShutdownModule
+**
+** PURPOSE: StartModule sends a SYS_SHUTDOWN system command to the module.
+**
+** INPUT PARAMETERS: none
+**
+** RETURN VALUE(S): none
+**
+**----------------------------------------------------------------------------*/
+void JCModule::ShutdownModule()
+{
+ if (isModuleLoaded)
+ {
+ printf("SysCommand(SYS_SHUTDOWN): %s\n", modName);
+ syscmd(SYS_SHUTDOWN);
+ }
+}
+
+
+/*----------------------------------------------------------------------------**
+**
+** METHOD NAME: JCModule RebootModule
+**
+** PURPOSE: StartModule sends a SYS_REBOOT system command to the module.
+**
+** INPUT PARAMETERS: none
+**
+** RETURN VALUE(S): none
+**
+**----------------------------------------------------------------------------*/
+void JCModule::RebootModule()
+{
+ if (isModuleLoaded)
+ {
+ printf("SysCommand(SYS_REBOOT): %s\n", modName);
+ syscmd(SYS_REBOOT);
+ }
+}
+
+
+/*----------------------------------------------------------------------------**
+**
+** METHOD NAME: JCModule CheckModule
+**
+** PURPOSE: CheckModule verifies that all tasks associated with this module
+** are currently running.
+**
+** INPUT PARAMETERS: pTask - if problems a pointer to the troubled task
+** with the highest criticality
+**
+** RETURN VALUE(S): SYSTEM_MODULE_STATUS
+**
+**----------------------------------------------------------------------------*/
+SYSTEM_MODULE_STATUS JCModule::CheckModule(JCTask **pTask)
+{
+ SYSTEM_MODULE_STATUS retCode = MODULE_OK;
+ *pTask = 0;
+ if (isModuleLoaded)
+ {
+ char *tName;
+ for(int i=0; i < numSub; i++){
+ // check for exit abnormal
+ tName = taskName(tasks[i]->GetTaskId());
+ if(tName == NULL)
+ {
+ printf("Alert! found missing task(%s)\n", tasks[i]->GetTaskName());
+
+ if (!*pTask)
+ {
+ retCode = TASK_MISSING;
+ *pTask = tasks[i];
+ }
+ else if ((tasks[i]->GetTaskImportance() == JC_CRITICAL_TASK) &&
+ ((*pTask)->GetTaskImportance() == JC_NON_CRITICAL_TASK))
+ {
+ retCode = TASK_MISSING;
+ *pTask = tasks[i];
+ }
+ }
+ // check for suspended
+ else if(taskIsSuspended(tasks[i]->GetTaskId()))
+ {
+ char coreFileName[128];
+ char *pMnetBase;
+ int coreFd = ERROR;
+ int stdoutFd, stderrFd;
+
+ // Create a core file for this task.
+ pMnetBase = getenv("MNET_BASE");
+
+ if (pMnetBase && !tasks[i]->GetTaskAlarmStatus())
+ {
+ strcpy(coreFileName, pMnetBase);
+ strcat(coreFileName, "\\");
+ strcat(coreFileName, tasks[i]->GetTaskName());
+ strcat(coreFileName, ".dmp");
+
+ // If the file was created replace stdout and stderr with the
+ // file descriptor for the task core file.
+ if ((coreFd = creat(coreFileName, O_RDWR)) != ERROR)
+ {
+ stdoutFd = ioGlobalStdGet(1);
+ stderrFd = ioGlobalStdGet(2);
+ ioGlobalStdSet(1, coreFd);
+ ioGlobalStdSet(2, coreFd);
+ }
+ }
+
+ printf("Alert! found suspended task(%s)\n", tasks[i]->GetTaskName());
+ tt(tasks[i]->GetTaskId());
+ ti(tasks[i]->GetTaskId());
+ tasks[i]->ExecuteCoreDumpFunc();
+
+ // If a core file was created then return stdout and stderr.
+ if (coreFd != ERROR)
+ {
+ ioGlobalStdSet(1, stdoutFd);
+ ioGlobalStdSet(2, stderrFd);
+ close(coreFd);
+ printf("Alert! found suspended task(%s)\n", tasks[i]->GetTaskName());
+ tt(tasks[i]->GetTaskId());
+ ti(tasks[i]->GetTaskId());
+ tasks[i]->ExecuteCoreDumpFunc();
+ }
+
+ if (!*pTask)
+ {
+ retCode = TASK_SUSPENDED;
+ *pTask = tasks[i];
+ }
+ else if ((tasks[i]->GetTaskImportance() == JC_CRITICAL_TASK) &&
+ ((*pTask)->GetTaskImportance() == JC_NON_CRITICAL_TASK))
+ {
+ retCode = TASK_SUSPENDED;
+ *pTask = tasks[i];
+ }
+ }
+ }
+ }
+
+ return(retCode);
+}
+
+
+/*----------------------------------------------------------------------------**
+**
+** METHOD NAME: JCModule AllTasksInMainLoop
+**
+** PURPOSE: Check to see if all tasks are in the main loop.
+**
+** INPUT PARAMETERS: none
+**
+** RETURN VALUE(S): TRUE - all in main
+** FALSE - not all tasks in main loop
+**
+**----------------------------------------------------------------------------*/
+bool JCModule::AllTasksInMainLoop()
+{
+ for (int i=0; i < MNET_MAX_MODULE_IDS; i++)
+ {
+ if (systemModules[i])
+ {
+ for (int j=0; j < MAX_NUM_SUB_TASKS; j++)
+ {
+ if (systemModules[i]->tasks[j])
+ {
+ if (systemModules[i]->tasks[j]->GetTaskStatus() != JC_TASK_LOOP)
+ {
+ return (FALSE);
+ }
+ }
+ }
+ }
+ }
+
+ return (TRUE);
+}
+
+
+/*----------------------------------------------------------------------------**
+**
+** METHOD NAME: JCModule ShowModuleStat
+**
+** PURPOSE: Display module status.
+**
+** INPUT PARAMETERS: none
+**
+** RETURN VALUE(S): none
+**
+**----------------------------------------------------------------------------*/
+extern "C"
+{
+void ShellShowModuleStat()
+{
+ JCModule::ShowModuleStat();
+}
+}
+
+void JCModule::ShowModuleStat()
+{
+ int totalTasks, totalInit, totalIdle, totalLoop, totalExit, totalUnknown;
+
+ printf ("System Module Status\n");
+
+ for (int i=0; i < MNET_MAX_MODULE_IDS; i++)
+ {
+ if (systemModules[i])
+ {
+ totalTasks = 0;
+ totalInit = 0;
+ totalIdle = 0;
+ totalLoop = 0;
+ totalExit = 0;
+ totalUnknown = 0;
+
+ for (int j=0; j < MAX_NUM_SUB_TASKS; j++)
+ {
+ if (systemModules[i]->tasks[j])
+ {
+ totalTasks++;
+ switch (systemModules[i]->tasks[j]->GetTaskStatus())
+ {
+ case JC_TASK_IDLE :
+ totalIdle++;
+ break;
+ case JC_TASK_INIT :
+ totalInit++;
+ break;
+ case JC_TASK_LOOP :
+ totalLoop++;
+ break;
+ case JC_TASK_EXIT :
+ totalExit++;
+ break;
+ default :
+ totalUnknown++;
+ }
+ }
+ }
+ printf("\tModule - %s\n", systemModules[i]->modName);
+ printf("\t\tTotalTasks(%d) Idle(%d) Init(%d) Loop(%d) Exit(%d) Unknown(%d)\n",
+ totalTasks, totalIdle, totalInit, totalLoop, totalExit, totalUnknown);
+ }
+ }
+
+}
+
+
+/*----------------------------------------------------------------------------**
+**
+** METHOD NAME: JCModule CheckSym
+**
+** PURPOSE: CheckSym does a string compare to see if against the symbol.
+**
+** INPUT PARAMETERS: none
+**
+** RETURN VALUE(S): 0 - string match
+** 1 - no string match
+**
+**----------------------------------------------------------------------------*/
+int JCModule::CheckSym(char *name, int val, SYM_TYPE type, int arg, UINT16 group)
+{
+ if(strstr(name, (char *)arg))
+ {
+ return 0; // exit symEach
+ }
+ return 1; // continue
+}
+
+/*----------------------------------------------------------------------------**
+**
+** METHOD NAME: JCModule TestSym
+**
+** PURPOSE: Loop through each symbol in the symbol table testing if the
+** string given matches a valid symbol.
+**
+** INPUT PARAMETERS: none
+**
+** RETURN VALUE(S): 0 - symbol found
+** 1 - symbol not found
+**
+**----------------------------------------------------------------------------*/
+int JCModule::TestSym(char *str)
+{
+ SYMBOL *symbol = symEach(sysSymTbl, (FUNCPTR)JCModule::CheckSym, (int)str);
+
+ if(symbol) return 0;
+ else
+ {
+ printf("[WARNING] function not found from symbol table: %s\n", str);
+ return 1;
+ }
+}
diff --git a/data/mnet/Common/Os/src/JCMsgQueue.cpp b/data/mnet/Common/Os/src/JCMsgQueue.cpp
new file mode 100644
index 0000000..f58a9b2
--- /dev/null
+++ b/data/mnet/Common/Os/src/JCMsgQueue.cpp
@@ -0,0 +1,197 @@
+// *******************************************************************
+//
+// (c) Copyright Cisco 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// Status : Under development
+// File : JCMsgQueue.cpp
+// Author(s) : Tim Olson
+// Create Date : 10/18/2000
+// Description :
+//
+// *******************************************************************
+//
+// Revision history:
+// ===================================================================
+// Igal | 11/30/00 | Fixed incorrect max message size acceptable by the queue
+// -------------------------------------------------------------------
+//
+//
+
+#include <stdio.h>
+#include <errNoLib.h>
+#include <string.h>
+#include "Os/JCMsgQueue.h"
+#include "JCMsgQDefs.h"
+
+#define PADDING 4
+
+/*----------------------------------------------------------------------------**
+**
+** METHOD NAME: JCMsgQueue constructor
+**
+** PURPOSE: Initialize data members for JCMsgQueue object. A message
+** queue for the native operating system will be created.
+**
+** INPUT PARAMETERS: maxMsgs - max msgs that can be queued
+** maxMsgLength - max bytes in a msg
+** options - message queue options (MSG_Q_FIFO or
+** MSG_Q_PRIORITY)
+**
+** RETURN VALUE(S): none
+** Note: If the message queue cannot be created msgQId will be set to NULL
+**
+**----------------------------------------------------------------------------*/
+JCMsgQueue::JCMsgQueue
+(
+ int maxMsgs, /* max msgs that can be queued */
+ int maxMsgLength, /* max bytes in a msg */
+ int options /* message queue options */
+) : msgQMaxLen(maxMsgLength+PADDING)
+{
+ if (!(msgQId = msgQCreate(maxMsgs, msgQMaxLen + JC_MSG_HDR_SIZE, options)))
+ {
+ printf("Error creating message queue %s\n", errnoGet());
+ }
+
+ if (!(msgQSndBuf = new char[msgQMaxLen + JC_MSG_HDR_SIZE]))
+ {
+ printf("Error: unable to allocate msg buffer memory\n");
+ }
+
+ if (!(msgQRcvBuf = new char[msgQMaxLen + JC_MSG_HDR_SIZE]))
+ {
+ printf("Error: unable to allocate msg buffer memory\n");
+ }
+}
+
+/*----------------------------------------------------------------------------**
+**
+** METHOD NAME: JCMsgQueue destructor
+**
+** PURPOSE: Delete data members for JCMsgQueue object.
+**
+** INPUT PARAMETERS: none
+**
+** RETURN VALUE(S): none
+**
+**----------------------------------------------------------------------------*/
+JCMsgQueue::~JCMsgQueue ()
+{
+ if (msgQDelete(msgQId) != OK)
+ {
+ printf("Error deleting message queue %s\n", errnoGet());
+ }
+
+ delete [] msgQSndBuf;
+ delete [] msgQRcvBuf;
+}
+
+
+/*----------------------------------------------------------------------------**
+**
+** METHOD NAME: JCMsgQueue::JCMsgQSend
+**
+** PURPOSE: JCMsgQSend sends the specified message to the specified message
+** queue. The buffer given will be copied into a local send buffer prior
+** to sending the message.
+**
+** INPUT PARAMETERS: replyMsgQ - message queue to use for sending a reply
+** msgType - type of message being sent
+** modId - module ID of sender
+** buffer - message to send
+** nBytes - number of bytes in the message
+** timeout - ticks to wait
+** priority - priority of the message (normal or urgent)
+**
+** RETURN VALUE(S): JC_STATUS
+**
+**----------------------------------------------------------------------------*/
+JC_STATUS JCMsgQueue::JCMsgQSend
+(
+ JCMsgQueue *replyMsgQ,
+ unsigned int msgType,
+ MNET_MODULE_ID modId,
+ char * buffer,
+ unsigned int nBytes,
+ int timeout,
+ int priority
+)
+{
+ // Verify a few parameters first.
+ if (nBytes && !buffer)
+ return JC_PARAM_INVALID;
+
+ if (nBytes > msgQMaxLen-PADDING)
+ return JC_MSG_LENGTH_ERROR;
+
+ // Build message in the receive message buffer for this queue.
+ JC_MSG_HDR *pMsg = (JC_MSG_HDR *)msgQSndBuf;
+
+ pMsg->rplyQ = replyMsgQ;
+ pMsg->msgType = msgType ;
+ pMsg->modId = modId ;
+ pMsg->bytes = nBytes ;
+ if (buffer)
+ memcpy (msgQSndBuf + JC_MSG_HDR_SIZE, buffer, nBytes);
+
+ return (msgQSend(msgQId, msgQSndBuf, nBytes + JC_MSG_HDR_SIZE, timeout, priority));
+}
+
+
+/*----------------------------------------------------------------------------**
+**
+** METHOD NAME: JCMsgQueue::JCMsgQReceive
+**
+** PURPOSE: JCMsgQReceive.
+**
+** INPUT PARAMETERS: replyMsgQ - message queue to use for sending a reply
+** msgType - type of message being sent
+** modId - module ID of sender
+** buffer - message to send
+** nBytes - number of bytes in the message
+** timeout - ticks to wait
+**
+** RETURN VALUE(S): number of bytes received
+**
+**----------------------------------------------------------------------------*/
+int JCMsgQueue::JCMsgQReceive
+(
+ JCMsgQueue **replyMsgQ,
+ unsigned int *msgType,
+ MNET_MODULE_ID *modId,
+ char * buffer,
+ unsigned int *nBytes,
+ int timeout
+)
+{
+ int bytesRcvd;
+
+ // Verify a few parameters first.
+ if ((!buffer) || (!replyMsgQ) || (!msgType) || (!nBytes))
+ return JC_PARAM_INVALID;
+
+
+ // Wait here for a message to arrive or timeout number of ticks to expire.
+ if ((bytesRcvd = msgQReceive(msgQId, msgQRcvBuf, msgQMaxLen + JC_MSG_HDR_SIZE,
+ timeout)) != ERROR)
+ {
+ // Access the message header at the start of the buffer.
+ JC_MSG_HDR *pMsg = (JC_MSG_HDR *)msgQRcvBuf;
+
+ *replyMsgQ = pMsg->rplyQ;
+ *msgType = pMsg->msgType;
+ *modId = pMsg->modId;
+ *nBytes = pMsg->bytes;
+
+ // Message contents should follow the message header.
+ memcpy(buffer, msgQRcvBuf + JC_MSG_HDR_SIZE, bytesRcvd - JC_MSG_HDR_SIZE);
+ }
+
+ return (bytesRcvd);
+}
diff --git a/data/mnet/Common/Os/src/JCMutex.cpp b/data/mnet/Common/Os/src/JCMutex.cpp
new file mode 100644
index 0000000..5077cf5
--- /dev/null
+++ b/data/mnet/Common/Os/src/JCMutex.cpp
@@ -0,0 +1,43 @@
+// *******************************************************************
+//
+// (c) Copyright CISCO Systems, 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// Status : Under development
+// File : JCMutex.cpp
+// Author(s) : Igal Gutkin
+// Create Date : 11/06/00
+// Description : JCMutex class (Mutual-Exclusion Semapore) implementation
+//
+// *******************************************************************
+
+#include "Os\JCMutex.h"
+
+
+JCMutex::JCMutex ()
+{
+ semId_ = semMCreate (SEM_Q_PRIORITY | SEM_DELETE_SAFE | SEM_INVERSION_SAFE);
+}
+
+
+bool JCMutex::take ()
+{
+ return (semId_ && semTake (semId_, WAIT_FOREVER) == OK);
+}
+
+
+bool JCMutex::give ()
+{
+ return (semId_ && semGive (semId_) == OK);
+}
+
+
+JCMutex::~JCMutex ()
+{
+ semDelete (semId_);
+}
diff --git a/data/mnet/Common/Os/src/JCTask.cpp b/data/mnet/Common/Os/src/JCTask.cpp
new file mode 100644
index 0000000..8488da3
--- /dev/null
+++ b/data/mnet/Common/Os/src/JCTask.cpp
@@ -0,0 +1,193 @@
+// *******************************************************************
+//
+// (c) Copyright Cisco 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// Status : Under development
+// File : JCTask.cpp
+// Author(s) : Tim Olson
+// Create Date : 10/18/2000
+// Description :
+//
+// *******************************************************************
+
+#include <stdio.h>
+#include <errNoLib.h>
+#include <string.h>
+#include "Os/JCTask.h"
+#include "Os/JCModule.h"
+
+SEM_ID *pMnetSyncSem;
+
+/*----------------------------------------------------------------------------**
+**
+** METHOD NAME: JCTask constructor
+**
+** PURPOSE: Initialize data members for JCTask object.
+**
+** INPUT PARAMETERS: name - name of the task
+**
+** RETURN VALUE(S): none
+**
+**----------------------------------------------------------------------------*/
+JCTask::JCTask
+(
+ char *name /* name of the task */
+) : taskStatus(JC_TASK_IDLE), taskAlarmed(FALSE)
+{
+ if (name)
+ {
+ taskName = new char[strlen(name) + 1];
+ if (taskName)
+ {
+ strcpy(taskName, name);
+ }
+ else
+ {
+ printf("JCTask::JCTask ERROR: Unable to allocate memory\n");
+ }
+ }
+ else
+ {
+ taskName = 0;
+ }
+}
+
+
+
+/*----------------------------------------------------------------------------**
+**
+** METHOD NAME: JCTask destructor
+**
+** PURPOSE: Delete data members for JCTask object.
+**
+** INPUT PARAMETERS: none
+**
+** RETURN VALUE(S): none
+**
+**----------------------------------------------------------------------------*/
+JCTask::~JCTask ()
+{
+ delete [] taskName;
+}
+
+
+
+
+/*----------------------------------------------------------------------------**
+**
+** METHOD NAME: JCTask::JCTaskSpawn
+**
+** PURPOSE: Spawn a task.
+**
+** INPUT PARAMETERS: priority - (0-255)
+** options - option word
+** stackSize - size in bytes of stack
+** entryPt - entry point of task
+** arg1 - argument 1 passed to entryPt
+** arg2 - argument 1 passed to entryPt
+** arg3 - argument 1 passed to entryPt
+** arg4 - argument 1 passed to entryPt
+** arg5 - argument 1 passed to entryPt
+** arg6 - argument 1 passed to entryPt
+** arg7 - argument 1 passed to entryPt
+** arg8 - argument 1 passed to entryPt
+** arg9 - argument 1 passed to entryPt
+** arg10 - NOT AN ARGUMENT!!!! This parameter can be used
+** to pass a function pointer to a function that
+** will be called if the task is suspended.
+** modId - module id number
+** importance - critical or non-critical
+**
+** RETURN VALUE(S): taskId or ERROR
+**
+**----------------------------------------------------------------------------*/
+int JCTask::JCTaskSpawn
+(
+ int priority, /* priority of new task */
+ int options, /* task option word */
+ int stackSize, /* size (bytes) of stack needed plus name */
+ FUNCPTR entryPt, /* entry point of new task */
+ int arg1, /* 1st of 10 req'd task args to pass to func */
+ int arg2,
+ int arg3,
+ int arg4,
+ int arg5,
+ int arg6,
+ int arg7,
+ int arg8,
+ int arg9,
+ int arg10,
+ MNET_MODULE_ID modId,
+ JC_TASK_IMPORTANCE importance
+)
+{
+
+ JCModule::InsertTaskInfo(modId, this);
+ taskPri = priority;
+ taskOpt = options;
+ taskStackSize = stackSize;
+ taskEntryPt = entryPt;
+ taskArg1 = arg1;
+ taskArg2 = arg2;
+ taskArg3 = arg3;
+ taskArg4 = arg4;
+ taskArg5 = arg5;
+ taskArg6 = arg6;
+ taskArg7 = arg7;
+ taskArg8 = arg8;
+ taskArg9 = arg9;
+ taskArg10 = arg10;
+ taskImportance = importance;
+ moduleId = modId;
+ taskStatus = JC_TASK_INIT;
+ coreDumpFunc = (FUNCPTR)arg10;
+
+ taskId = taskSpawn(taskName, priority, options, stackSize, entryPt,
+ arg1, arg2, arg3, arg4, arg5,
+ arg6, arg7, arg8, arg9, 0);
+
+ return(taskId);
+}
+
+
+/*----------------------------------------------------------------------------**
+**
+** METHOD NAME: JCTask::JCTaskEnterLoop()
+**
+** PURPOSE:
+**
+** INPUT PARAMETERS: none
+**
+** RETURN VALUE(S): none
+**
+**----------------------------------------------------------------------------*/
+void JCTask::JCTaskEnterLoop()
+{
+ taskStatus = JC_TASK_LOOP;
+
+ // Spin here waiting for all other tasks to call enter loop.
+ if (pMnetSyncSem)
+ semBTake(*pMnetSyncSem, WAIT_FOREVER);
+}
+
+/*----------------------------------------------------------------------------**
+**
+** METHOD NAME: JCTask::JCTaskNormExit()
+**
+** PURPOSE:
+**
+** INPUT PARAMETERS: none
+**
+** RETURN VALUE(S): none
+**
+**----------------------------------------------------------------------------*/
+void JCTask::JCTaskNormExit()
+{
+ taskStatus = JC_TASK_EXIT;
+}
diff --git a/data/mnet/Common/Os/src/Makefile b/data/mnet/Common/Os/src/Makefile
new file mode 100644
index 0000000..e5c0242
--- /dev/null
+++ b/data/mnet/Common/Os/src/Makefile
@@ -0,0 +1,62 @@
+##########################################################
+#
+# (c) Copyright Cisco 2000
+# All Rights Reserved
+#
+# Use Examples:
+#
+# Case 1:
+# make all VOB=GP10 -
+# Places .out in VOB/bin directory
+#
+# Case 2:
+# make all VOB=GP10 APPDIR=Host\<Application Name>\<Source Directory> -
+# Places .o file(s) in VOB\$(APPDIR)\bin directory.
+#
+# <Application Name> = Name of Application directory
+# <Source Directory> = application sub directory where the calling
+# Makefile resides.
+#
+# Example: make all VOB=GP10 APPDIR=Host\vxTemplate\src
+#
+#
+# Note: This make file must reference a VOB that
+# has a defs.mk in the top level directory.
+#
+##########################################################
+
+# TOP_OF_VOB must be defined before including l3defs.mk
+TOP_OF_VOB = ..\..
+
+# Name of this App's Directory
+COMMON_APP_DIR = os
+
+VOB2DIR = $(TOP_OF_VOB)\..\$(VOB)
+BINDIR = ..\bin
+
+ifeq ($(APPDIR),)
+ MY_OUTPUT = $(VOB2DIR)\bin\$(COMMON_APP_DIR).out
+else
+ MY_OUTPUT = $(OBJDIR)\$(COMMON_APP_DIR).out
+endif
+
+include $(VOB2DIR)\l3defs.mk
+
+
+all: $(MY_OUTPUT)
+
+$(MY_OUTPUT): $(MODULE_OBJS)
+ $(LD) -r -o $@.tmp $(MODULE_OBJS)
+ $(NM) $@.tmp | munch > _ctdt.c
+ $(CC) -traditional $(CC_ARCH_SPEC) -c _ctdt.c
+ $(LD) -r -o $@ _ctdt.o $@.tmp
+ $(RM)$(subst /,$(DIRCHAR), _ctdt.c _ctdt.o $@.tmp)
+
+
+cleanall:
+ @for %f in ($(notdir $(MODULE_OBJS))) do \
+ $(RM) ..\bin\%f
+
+ $(RM) $(MY_OUTPUT)
+
+
diff --git a/data/mnet/Common/Os/test/Makefile b/data/mnet/Common/Os/test/Makefile
new file mode 100644
index 0000000..2ca8e4a
--- /dev/null
+++ b/data/mnet/Common/Os/test/Makefile
@@ -0,0 +1,65 @@
+##########################################################
+#
+# (c) Copyright Cisco 2000
+# All Rights Reserved
+#
+# Use Examples:
+#
+# Case 1:
+# make all VOB=GP10 -
+# Places .out in VOB/bin directory
+#
+# Case 2:
+# make all VOB=GP10 APPDIR=Host\<Application Name>\<Source Directory> -
+# Places .o file(s) in VOB\$(APPDIR)\bin directory.
+#
+# <Application Name> = Name of Application directory
+# <Source Directory> = application sub directory where the calling
+# Makefile resides.
+#
+# Example: make all VOB=GP10 APPDIR=Host\vxTemplate\src
+#
+#
+# Note: This make file must reference a VOB that
+# has a defs.mk in the top level directory.
+#
+##########################################################
+
+# TOP_OF_VOB must be defined before including l3defs.mk
+TOP_OF_VOB = ..\..\..
+
+# Name of this App's Directory
+COMMON_APP_DIR = Os
+
+VOB2DIR = $(TOP_OF_VOB)\$(VOB)
+BINDIR = ..\bin
+
+ifeq ($(APPDIR),)
+ MY_OUTPUT = $(VOB2DIR)\bin\OsTest.out
+else
+ MY_OUTPUT = $(OBJDIR)\OsTest.out
+endif
+
+include $(VOB2DIR)\l3defs.mk
+
+
+all: $(MY_OUTPUT)
+
+$(MY_OUTPUT): $(MODULE_OBJS)
+ $(LD) -r -o $@.tmp $(MODULE_OBJS)
+ $(NM) $@.tmp | munch > _ctdt.c
+ $(CC) -traditional $(CC_ARCH_SPEC) -c _ctdt.c
+ $(LD) -r -o $@ _ctdt.o $@.tmp
+ $(RM)$(subst /,$(DIRCHAR), _ctdt.c _ctdt.o $@.tmp)
+ifneq ($(APPDIR),)
+ $(CP) $(BINDIR)\*.o $(VOB2DIR)\$(APPDIR)\bin\*.o
+endif
+
+
+cleanall:
+ @for %f in ($(notdir $(MODULE_OBJS))) do \
+ $(RM) ..\bin\%f
+
+ $(RM) $(MY_OUTPUT)
+
+
diff --git a/data/mnet/Common/Os/test/MsgQTest.cpp b/data/mnet/Common/Os/test/MsgQTest.cpp
new file mode 100644
index 0000000..e762b40
--- /dev/null
+++ b/data/mnet/Common/Os/test/MsgQTest.cpp
@@ -0,0 +1,91 @@
+// *******************************************************************
+//
+// (c) Copyright Cisco 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// Status : Under development
+// File : MsgQTest.cpp
+// Author(s) : Tim Olson
+// Create Date : 10/18/2000
+// Description :
+//
+// *******************************************************************
+
+
+#include <stdio.h>
+#include "Os/JCMsgQueue.h"
+
+JCMsgQueue *pMsgQ;
+bool isTestComplete = FALSE;
+
+extern "C"
+{
+void InitializeQueue()
+{
+ pMsgQ = new JCMsgQueue(10, 256, JC_MSG_Q_FIFO);
+
+ if (pMsgQ->JCGetMsgQId() == 0)
+ {
+ printf("Error creating test message queue\n");
+ return;
+ }
+
+ JC_MSG_Q_ID replyMsgQ;
+ unsigned int msgType;
+ char buffer[256];
+ unsigned int nBytes;
+ MNET_MODULE_ID modId;
+
+ while (!isTestComplete)
+ {
+ JC_STATUS status;
+ if ((status = pMsgQ->JCMsgQReceive(&replyMsgQ, &msgType, &modId, buffer, &nBytes,
+ JC_WAIT_FOREVER)) == JC_OK)
+ {
+ printf("Received a test message!\n");
+ printf("\treplyMsgQ = %x\n", replyMsgQ);
+ printf("\tmsgType = %x\n", msgType);
+ printf("\tmodId = %x\n", modId);
+ printf("\tnBytes = %x\n", nBytes);
+ printf("\tbuffer = ");
+ for (int i=0; i < nBytes; i++)
+ printf("%02x ", buffer[i]);
+ printf("\n");
+ }
+ else
+ {
+ printf("Error receiving message - errcode %x\n", status);
+ }
+ }
+}
+
+
+
+void SendToQueue()
+{
+ char msg[256];
+ JC_STATUS status;
+
+ // build a test message
+ for (int i=0; i < 16; i++)
+ {
+ msg[i] = (char)i;
+ }
+
+ isTestComplete = TRUE;
+ unsigned int msgType = 13;
+ unsigned int msgLen = 16;
+
+ if ((status = pMsgQ->JCMsgQSend((JC_MSG_Q_ID)0xabcd0123, msgType, LOGGER, msg, msgLen, JC_WAIT_FOREVER,
+ JC_MSG_PRI_NORMAL)) != JC_OK)
+ {
+ printf("Error sending test message - errcode %x\n", status);
+ }
+}
+
+} \ No newline at end of file
diff --git a/data/mnet/Common/Pm/Makefile b/data/mnet/Common/Pm/Makefile
new file mode 100644
index 0000000..2466a80
--- /dev/null
+++ b/data/mnet/Common/Pm/Makefile
@@ -0,0 +1,47 @@
+##########################################################
+#
+# (c) Copyright Cisco 2000
+# All Rights Reserved
+#
+# Use Examples:
+#
+# Case 1:
+# make all VOB=GP10 -
+# Places .out in VOB/bin directory
+#
+# Case 2:
+# make all VOB=GP10 APPDIR=Host\<Application Name>\<Source Directory> -
+# Places .o file(s) in VOB\$(APPDIR)\bin directory.
+#
+# <Application Name> = Name of Application directory
+# <Source Directory> = application sub directory where the calling
+# Makefile resides.
+#
+# Example: make all VOB=GP10 APPDIR=Host\vxTemplate\src
+#
+# (OPTIONAL) Append REPLACE - Replaces the List of directories
+# to be used in the SUBDIRS variable
+#
+# Example: make all VOB=GP10 APPDIR=Host\vxTemplate\src REPLACE="src_api src_debug"
+#
+# Note: This make file must reference a VOB that
+# has a defs.mk in the top level directory.
+#
+##########################################################
+
+SUBDIRS = src
+
+# TOP_OF_VOB must be defined before including l3defs.mk
+TOP_OF_VOB = ..
+
+VOBDIR = $(TOP_OF_VOB)/../$(VOB)
+
+# Allows a sub-set of the source code directories to be used
+
+ifneq ($(REPLACE),)
+ SUBDIRS = $(REPLACE)
+endif
+
+include $(VOBDIR)\l3defs.mk
+
+
diff --git a/data/mnet/Common/Pm/src/Makefile b/data/mnet/Common/Pm/src/Makefile
new file mode 100644
index 0000000..303ab8f
--- /dev/null
+++ b/data/mnet/Common/Pm/src/Makefile
@@ -0,0 +1,61 @@
+##########################################################
+#
+# (c) Copyright Cisco 2000
+# All Rights Reserved
+#
+# Use Examples:
+#
+# Case 1:
+# make all VOB=GP10 -
+# Places .out in VOB/bin directory
+#
+# Case 2:
+# make all VOB=GP10 APPDIR=Host\<Application Name>\<Source Directory> -
+# Places .o file(s) in VOB\$(APPDIR)\bin directory.
+#
+# <Application Name> = Name of Application directory
+# <Source Directory> = application sub directory where the calling
+# Makefile resides.
+#
+# Example: make all VOB=GP10 APPDIR=Host\vxTemplate\src
+#
+#
+# Note: This make file must reference a VOB that
+# has a defs.mk in the top level directory.
+#
+##########################################################
+
+# TOP_OF_VOB must be defined before including l3defs.mk
+TOP_OF_VOB = ..\..
+
+# Name of this App's Directory
+THIS_APP_DIR = Pm
+
+VOB2DIR = $(TOP_OF_VOB)\..\$(VOB)
+BINDIR = ..\bin
+
+ifeq ($(APPDIR),)
+ MY_OUTPUT = $(VOB2DIR)\bin\pm.out
+else
+ MY_OUTPUT = $(OBJDIR)\pm_com.out
+endif
+
+include $(VOB2DIR)\l3defs.mk
+
+
+all: $(MY_OUTPUT)
+
+$(MY_OUTPUT): $(MODULE_OBJS)
+ $(LD) -r -o $@.tmp $(MODULE_OBJS)
+ $(NM) $@.tmp | munch > _ctdt.c
+ $(CC) -traditional $(CC_ARCH_SPEC) -c _ctdt.c
+ $(LD) -r -o $@ _ctdt.o $@.tmp
+ $(RM)$(subst /,$(DIRCHAR), _ctdt.c _ctdt.o $@.tmp)
+
+cleanall:
+ @for %f in ($(notdir $(MODULE_OBJS))) do \
+ $(RM) ..\bin\%f
+
+ $(RM) $(MY_OUTPUT)
+
+
diff --git a/data/mnet/Common/Pm/src/pm_common.cpp b/data/mnet/Common/Pm/src/pm_common.cpp
new file mode 100644
index 0000000..817e905
--- /dev/null
+++ b/data/mnet/Common/Pm/src/pm_common.cpp
@@ -0,0 +1,406 @@
+#include <stdio.h>
+#include <string.h>
+#include <semlib.h>
+#include <tickLib.h>
+
+#include "defs.h"
+#ifndef UNIT_TEST_PMCLASS
+#include "vipermib.h"
+#endif
+#include "pm/pm_common.h"
+
+/*
+ * PM_BaseObject::takeSemaphore
+ */
+bool PM_BaseObject::takeSemaphore()
+{
+ if (m_semaphore != NULL)
+ semTake(m_semaphore,WAIT_FOREVER);
+ return(TRUE);
+}
+
+/*
+ * PM_BaseObject::giveSemaphore
+ */
+bool PM_BaseObject::giveSemaphore()
+{
+ if (m_semaphore != NULL)
+ semGive(m_semaphore);
+ return(TRUE);
+}
+
+/*
+ * PM_SimpleCounter::reset
+ */
+void PM_SimpleCounter::reset()
+{
+ takeSemaphore();
+ currentInterval=0;
+ maxValue[currentInterval] = value[currentInterval] = 0;
+ giveSemaphore();
+}
+
+/*
+ * PM_SimpleCounter::increment()
+ */
+bool PM_SimpleCounter::increment()
+{
+ takeSemaphore();
+ value[currentInterval]++;
+ if( maxValue[currentInterval] < value[currentInterval] ) {
+ maxValue[currentInterval] = value[currentInterval];
+ }
+ giveSemaphore();
+ return(TRUE);
+}
+
+
+/*
+ * PM_SimpleCounter::increment(int x)
+ */
+bool PM_SimpleCounter::increment(int x)
+{
+ takeSemaphore();
+ value[currentInterval] += x;
+ if( maxValue[currentInterval] < value[currentInterval] ) {
+ maxValue[currentInterval] = value[currentInterval];
+ }
+ giveSemaphore();
+ return(TRUE);
+}
+
+
+/*
+ * PM_SimpleCounter::decrement
+ */
+bool PM_SimpleCounter::decrement()
+{
+ takeSemaphore();
+ value[currentInterval]--;
+ giveSemaphore();
+ return(TRUE);
+}
+
+/*
+ * PM_SimpleCounter::getValue
+ */
+int PM_SimpleCounter::getValue()
+{
+ int return_value;
+ takeSemaphore();
+ return_value = value[currentInterval];
+ giveSemaphore();
+ return(return_value);
+
+}
+
+/*
+ * PM_SimpleCounter::setValue
+ */
+bool PM_SimpleCounter::setValue(int new_value)
+{
+ takeSemaphore();
+ value[currentInterval] = new_value;
+ if( maxValue[currentInterval] < value[currentInterval] ) {
+ maxValue[currentInterval] = value[currentInterval];
+ }
+ giveSemaphore();
+ return(TRUE);
+
+}
+
+
+/*
+ * PM_SimpleCounter::getMaxValue
+ */
+int PM_SimpleCounter::getMaxValue()
+{
+ int return_value=0,count;
+ takeSemaphore();
+ return_value = maxValue[currentInterval];
+ giveSemaphore();
+ return(return_value);
+
+}
+
+
+
+/*
+ * PM_SimpleCounter::advanceInterval
+ */
+void PM_SimpleCounter::advanceInterval()
+{
+ takeSemaphore();
+ if (++currentInterval >= PM_MAX_INTERVAL) {
+ currentInterval = 0;
+ }
+ maxValue[currentInterval] = value[currentInterval] = 0;
+ giveSemaphore();
+ return;
+}
+
+
+
+/*
+ * PM_PerCauseCounter::reset
+ */
+void PM_PerCauseCounter::reset()
+{
+ int count;
+ for(count=0;count<PM_MAX_CAUSES;count++){
+ perCauseCounter[count].reset();
+ }
+}
+
+
+/*
+ * PM_PerCauseCounter::getValue
+ */
+int PM_PerCauseCounter::getValue(CauseCode cause)
+{
+ if (cause < PM_MAX_CAUSES)
+ return(perCauseCounter[cause].getValue());
+ else
+ return(0);
+}
+
+
+/*
+ * PM_PerCauseCounter::advanceInterval
+ */
+void PM_PerCauseCounter::advanceInterval()
+{
+ int count;
+ for(count=0;count<PM_MAX_CAUSES;count++) {
+ perCauseCounter[count].advanceInterval();
+ }
+}
+
+/*
+ * PM_PerCauseCounter::increment
+ */
+bool PM_PerCauseCounter::increment(CauseCode cause)
+{
+ int index;
+
+ index = pm_map_cause_to_index(cause);
+
+ if (index < PM_CURRENT_MAX_CAUSES)
+ perCauseCounter[index].increment();
+ else printf("PM ERRRO: Invalid Cause Code %d passed in from API\n", (int) cause );
+}
+
+
+/*
+ * PM_PerCauseCounter::decrement
+ */
+bool PM_PerCauseCounter::decrement(CauseCode cause)
+{
+ int index;
+
+ index = pm_map_cause_to_index(cause);
+
+ if (index < PM_CURRENT_MAX_CAUSES)
+ perCauseCounter[index].decrement();
+ else printf("PM ERRRO: Invalid Cause Code %d passed in from API\n", (int) cause );
+}
+
+
+/*
+ * PM_StatisticCounter::reset
+ */
+void PM_StatisticCounter::reset()
+{
+ /*
+ * quicker way of cleaning up all the variables
+ * is to memset
+ */
+ takeSemaphore();
+ currentInterval = 0;
+ numRecords[currentInterval]=0;
+ for(int i=0;i< PM_MAX_RECORDS;i++) records[currentInterval][i]=0;
+ giveSemaphore();
+}
+
+
+/*
+ * PM_StatisticCounter::addRecord
+ */
+bool PM_StatisticCounter::addRecord(int value)
+{
+ takeSemaphore();
+ if (numRecords[currentInterval] >= PM_MAX_RECORDS) {
+ /*
+ * No more records can be added now
+ */
+ giveSemaphore();
+ return(FALSE);
+ }
+ records[currentInterval][numRecords[currentInterval]++] = value;
+ giveSemaphore();
+ return(TRUE);
+}
+
+
+/*
+ * PM_StatisticCounter::getMeanValue
+ */
+int PM_StatisticCounter::getMeanValue()
+{
+ int index,total=0;
+ takeSemaphore();
+ for(index=0;index<numRecords[currentInterval];index++) {
+ total += records[currentInterval][index];
+ }
+ giveSemaphore();
+ if (numRecords[currentInterval] == 0) return(0);
+ return(total / numRecords[currentInterval]);
+}
+
+
+/*
+ * PM_StatisticCounter::getMaxValue
+ */
+int PM_StatisticCounter::getMaxValue()
+{
+ int maxValue=0,index;
+ takeSemaphore();
+ for(index=0;index<numRecords[currentInterval];index++) {
+ if (records[currentInterval][index] > maxValue) {
+ maxValue = records[currentInterval][index];
+ }
+ }
+ giveSemaphore();
+ return(maxValue);
+}
+
+
+/*
+ * PM_StatisticCounter::advanceInterval
+ */
+void PM_StatisticCounter::advanceInterval()
+{
+ takeSemaphore();
+ int count,last_record;
+ BOOL not_zero=FALSE;
+
+ if (numRecords[currentInterval] != 0) {
+ last_record = records[currentInterval][numRecords[currentInterval]-1];
+ not_zero = TRUE;
+ }
+
+ if (++currentInterval >= PM_MAX_INTERVAL) {
+ currentInterval = 0;
+ }
+ for(count=0;count<PM_MAX_RECORDS;count++)
+ records[currentInterval][count] = 0;
+ numRecords[currentInterval]=0;
+ giveSemaphore();
+ if (not_zero) {
+ addRecord(last_record);
+ }
+}
+
+/*
+ * PM_AccumTimeCounter::reset
+ */
+void PM_AccumTimeCounter::reset()
+{
+ takeSemaphore();
+ currentInterval = 0;
+ for(int i=0;i< PM_MAX_INTERVAL;i++)
+ {
+ accumValue[i]=0;
+ lastStart[i]=0;
+ state[i]=false;
+ }
+ giveSemaphore();
+}
+
+/*
+ * PM_AccumTimeCounter::start
+ */
+void PM_AccumTimeCounter::start()
+{
+ // start the counter
+ takeSemaphore();
+ if( ! state[currentInterval]) {
+ lastStart[currentInterval]=tickGet();
+ state[currentInterval]=true;
+ }
+ giveSemaphore();
+}
+
+/*
+ * PM_AccumTimeCounter::stop
+ */
+void PM_AccumTimeCounter::stop()
+{
+ // stop the counter
+ takeSemaphore();
+ if( state[currentInterval]) {
+ accumValue[currentInterval] += (tickGet() - lastStart[currentInterval]);
+ state[currentInterval]=false;
+ }
+ giveSemaphore();
+}
+
+/*
+ * PM_AccumTimeCounter::getValue
+ */
+int PM_AccumTimeCounter::getValue()
+{
+ int value;
+ // start the counter
+ takeSemaphore();
+ if( state[currentInterval] ) {
+ // do not change the current state, return the last accumulated value plus the
+ // timer value up the now
+ value = accumValue[currentInterval] + tickGet() - lastStart[currentInterval];
+ giveSemaphore();
+ return value;
+ }
+ else
+ {
+ // timer is not running, the accumValue shoudl hold the correct data
+ value = accumValue[currentInterval];
+ giveSemaphore();
+ return value;
+ }
+
+}
+
+
+/*
+ * PM_AccumTimeCounter::advanceInterval
+ */
+void PM_AccumTimeCounter::advanceInterval()
+{
+ takeSemaphore();
+ int currentTick;
+ if( state[currentInterval] ) {
+ // timer is running
+ currentTick = tickGet();
+ accumValue[currentInterval] += (currentTick - lastStart[currentInterval]);
+ state[currentInterval]=false;
+ // advance the interval
+ currentInterval = (currentInterval + 1 ) % PM_MAX_INTERVAL;
+ // carry over the last interval's timer status and tick
+ lastStart[currentInterval] = currentTick;
+ accumValue[currentInterval] = 0;
+ state[currentInterval]=true;
+ } else {
+ // timer is NOT running, directly advance the interval
+ currentInterval = (currentInterval + 1 ) % PM_MAX_INTERVAL;
+ lastStart[currentInterval] = 0;
+ accumValue[currentInterval] = 0;
+ state[currentInterval]=false;
+ }
+ giveSemaphore();
+}
+
+
+
+
+
+
diff --git a/data/mnet/Common/apm/include/apmdefs.h b/data/mnet/Common/apm/include/apmdefs.h
new file mode 100644
index 0000000..71c8d7d
--- /dev/null
+++ b/data/mnet/Common/apm/include/apmdefs.h
@@ -0,0 +1,51 @@
+#ifndef __APMDEFS_H__
+#define __APMDEFS_H__
+
+// *******************************************************************
+//
+// (c) Copyright CISCO Systems Inc. 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// Status : Under development
+// File : apmdefs.h
+// Author(s) : MindTree
+// Create Date : 3/12/00
+// Description : Common definitions to be used by APM
+//
+// *******************************************************************
+
+// this port numbers are used by PM and Alarm Module resp.
+#define PM_SERVER_PORT 11789
+#define AM_SERVER_PORT 11788
+
+// this new port numbers are used betw, APM1, APM2, APM2Gui ...
+
+//March 29 fix
+//#define APM2_SERVER_PORT 11795
+#define APM3_SERVER_PORT 11796
+#define APM_GUI_PORT 11797
+#define AM_APPLET_PORT 11798
+
+
+
+// TODO: this enumeration clashes with another definition
+// needs to be cleaned up by the next build
+typedef enum RET_STATUS{
+ STATUS_OK = 0 ,
+ STATUS_ERROR = -1
+ };
+
+//Used for Windows Services.
+#if defined(_WINDOWS_) || defined(WIN32)
+#define kMaxEventMsgLen 1024
+#define APP_APPROX_MAX_INIT_TIME 2000 /* milliseconds */
+typedef RET_STATUS STATUS;
+#endif
+
+
+#endif /* __APMDEFS_H__ */
diff --git a/data/mnet/Common/bssgp/Makefile b/data/mnet/Common/bssgp/Makefile
new file mode 100644
index 0000000..bd4611d
--- /dev/null
+++ b/data/mnet/Common/bssgp/Makefile
@@ -0,0 +1,47 @@
+##########################################################
+#
+# (c) Copyright Cisco 2000
+# All Rights Reserved
+#
+# Use Examples:
+#
+# Case 1:
+# make all VOB=GP10 -
+# Places .out in VOB/bin directory
+#
+# Case 2:
+# make all VOB=GP10 APPDIR=Host\<Application Name>\<Source Directory> -
+# Places .o file(s) in VOB\$(APPDIR)\bin directory.
+#
+# <Application Name> = Name of Application directory
+# <Source Directory> = application sub directory where the calling
+# Makefile resides.
+#
+# Example: make all VOB=GP10 APPDIR=Host\vxTemplate\src
+#
+# (OPTIONAL) Append REPLACE - Replaces the List of directories
+# to be used in the SUBDIRS variable
+#
+# Example: make all VOB=GP10 APPDIR=Host\vxTemplate\src REPLACE=src
+#
+# Note: This make file must reference a VOB that
+# has a defs.mk in the top level directory.
+#
+##########################################################
+
+SUBDIRS = src
+
+# TOP_OF_VOB must be defined before including l3defs.mk
+TOP_OF_VOB = ..\..
+
+VOBDIR = $(TOP_OF_VOB)\$(VOB)
+
+# Allows a sub-set of the source code directories to be used
+
+ifneq ($(REPLACE),)
+ SUBDIRS = $(REPLACE)
+endif
+
+include $(VOBDIR)\l3defs.mk
+
+
diff --git a/data/mnet/Common/bssgp/src/Makefile b/data/mnet/Common/bssgp/src/Makefile
new file mode 100644
index 0000000..a8da67c
--- /dev/null
+++ b/data/mnet/Common/bssgp/src/Makefile
@@ -0,0 +1,61 @@
+##########################################################
+#
+# (c) Copyright Cisco 2000
+# All Rights Reserved
+#
+# Use Examples:
+#
+# Case 1:
+# make all VOB=GP10 -
+# Places .out in VOB/bin directory
+#
+# Case 2:
+# make all VOB=GP10 APPDIR=Host\<Application Name>\<Source Directory> -
+# Places .o file(s) in VOB\$(APPDIR)\bin directory.
+#
+# <Application Name> = Name of Application directory
+# <Source Directory> = application sub directory where the calling
+# Makefile resides.
+#
+# Example: make all VOB=GP10 APPDIR=Host\vxTemplate\src
+#
+#
+# Note: This make file must reference a VOB that
+# has a defs.mk in the top level directory.
+#
+##########################################################
+
+# TOP_OF_VOB must be defined before including l3defs.mk
+TOP_OF_VOB = ..\..\..
+
+# Name of this App's Directory
+THIS_APP_DIR = bssgp
+
+VOB2DIR = $(TOP_OF_VOB)\$(VOB)
+BINDIR = ..\bin
+
+ifeq ($(APPDIR),)
+ MY_OUTPUT = $(VOB2DIR)\bin\$(THIS_APP_DIR).out
+else
+ MY_OUTPUT = $(OBJDIR)\$(THIS_APP_DIR).out
+endif
+
+include $(VOB2DIR)\l3defs.mk
+
+
+all: $(MY_OUTPUT)
+
+$(MY_OUTPUT): $(MODULE_OBJS)
+ $(LD) -r -o $@.tmp $(MODULE_OBJS)
+ $(NM) $@.tmp | munch > _ctdt.c
+ $(CC) -traditional $(CC_ARCH_SPEC) -c _ctdt.c
+ $(LD) -r -o $@ _ctdt.o $@.tmp
+ $(RM)$(subst /,$(DIRCHAR), _ctdt.c _ctdt.o $@.tmp)
+
+cleanall:
+ @for %f in ($(notdir $(MODULE_OBJS))) do \
+ $(RM) ..\bin\%f
+
+ $(RM) $(MY_OUTPUT)
+
+
diff --git a/data/mnet/Common/bssgp/src/bssgp_decoder.cpp b/data/mnet/Common/bssgp/src/bssgp_decoder.cpp
new file mode 100644
index 0000000..b12d340
--- /dev/null
+++ b/data/mnet/Common/bssgp/src/bssgp_decoder.cpp
@@ -0,0 +1,2520 @@
+/*
+ ****************************************************************************************
+ * *
+ * Copyright Cisco Systems, Inc 2000 All rights reserved *
+ * *
+ * File : bssgp_decoder.cpp *
+ * *
+ * Description : Decoding functions for the BSS-GP layer module *
+ * *
+ * Author : Dinesh Nambisan *
+ * *
+ *--------------------------- Notes ----------------------------------------------------*
+ * References are to sections numbers of the BSSGP spec. (GSM 08.18) unless otherwise *
+ * indicated *
+ *----------------------- Revision history ---------------------------------------------*
+ * Time | Date | Name | Description *
+ *--------------------------------------------------------------------------------------*
+ * 00:00 |10/10/00 | DSN | File created *
+ * | | | *
+ ****************************************************************************************
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include "bssgp\bssgp_prot.h"
+#include "bssgp\bssgp_util.h"
+#include "bssgp\bssgp_decoder.h"
+#include "bssgp\bssgp_ie_decoder.h"
+#include "bssgp\bssgp_util.h"
+#include "bssgp\bssgp_api.h"
+#include "bssgp\bssgp_unitdata.h"
+
+
+/*
+ * MAIN TO DO: Use the incoming bool flag to see if we just need protocol decode functionality
+ * or if we need to actually process the msg
+ *
+ */
+
+
+
+/*
+ * bssgp_decode_msg
+ *
+ * Notes : entry point for packets sent through BSSGP, either from the
+ * IP network side or to the IP network side (in the latter
+ * case, it is being used more as a protocol decoder, with
+ * the boolean flag incoming set to FALSE)
+ */
+BOOL
+bssgp_decode_msg(UINT8 *msg,UINT16 msg_len,BOOL incoming,
+ BSSGP_NETWORK_QOS_LEVEL qos_level,BSSGP_BVCI bvci,BOOL *free_buff)
+{
+ DBG_FUNC("bssgp_decode_msg",BSSGP_LAYER);
+ DBG_ENTER();
+ BOOL status = FALSE;
+ UINT8 *byte;
+ UINT16 index = 0, pdu_len;
+
+ byte = (UINT8*)&msg[index];
+
+ pdu_len = msg_len - 1;
+
+
+ DBG_TRACE("PDU Type : %s",bssgp_util_get_pdu_type_str((BSSGP_PDU_TYPE)*byte));
+
+ switch(*byte) {
+ case BSSGP_PDU_DL_UNITDATA: {
+ status = bssgp_decode_dl_unitdata(&msg[index],&pdu_len,qos_level);
+ *free_buff = TRUE;
+ }
+ break;
+
+ case BSSGP_PDU_UL_UNITDATA:{
+ status = bssgp_decode_ul_unitdata(&msg[index],&pdu_len,qos_level,bvci);
+ *free_buff = TRUE;
+ }
+ break;
+
+ case BSSGP_PDU_RA_CAP:{
+ status = bssgp_decode_radio_cap(&msg[index],&pdu_len,incoming);
+ *free_buff = TRUE;
+ }
+ break;
+ case BSSGP_PDU_PAGING_PS:{
+ status = bssgp_decode_paging_ps(&msg[index],&pdu_len,incoming);
+ *free_buff = TRUE;
+ }
+ break;
+
+ case BSSGP_PDU_RA_CAP_UPDATE:{
+ status = bssgp_decode_radio_cap_update(&msg[index],&pdu_len,incoming);
+ *free_buff = TRUE;
+ }
+ break;
+
+ case BSSGP_PDU_RA_CAP_UPDATE_ACK:{
+ status = bssgp_decode_radio_cap_update_ack(&msg[index],&pdu_len,incoming);
+ *free_buff = TRUE;
+ }
+ break;
+
+ case BSSGP_PDU_RADIO_STATUS:{
+ status = bssgp_decode_radio_status(&msg[index],&pdu_len,incoming);
+ *free_buff = TRUE;
+ }
+ break;
+
+ case BSSGP_PDU_SUSPEND:{
+ status = bssgp_decode_suspend(&msg[index],&pdu_len,incoming);
+ *free_buff = TRUE;
+ }
+ break;
+
+ case BSSGP_PDU_SUSPEND_ACK:{
+ status = bssgp_decode_suspend_ack(&msg[index],&pdu_len,incoming);
+ *free_buff = TRUE;
+ }
+ break;
+
+ case BSSGP_PDU_SUSPEND_NACK:{
+ status = bssgp_decode_suspend_nack(&msg[index],&pdu_len,incoming);
+ *free_buff = TRUE;
+ }
+ break;
+
+ case BSSGP_PDU_RESUME:{
+ status = bssgp_decode_resume(&msg[index],&pdu_len,incoming);
+ *free_buff = TRUE;
+ }
+ break;
+
+ case BSSGP_PDU_RESUME_ACK:{
+ status = bssgp_decode_resume_ack(&msg[index],&pdu_len,incoming);
+ *free_buff = TRUE;
+ }
+ break;
+
+ case BSSGP_PDU_RESUME_NACK:{
+ status = bssgp_decode_resume_nack(&msg[index],&pdu_len,incoming);
+ *free_buff = TRUE;
+ }
+ break;
+
+ case BSSGP_PDU_FLOW_CONTROL_MS:{
+ status = bssgp_decode_flow_control_ms(&msg[index],&pdu_len,incoming);
+ }
+ break;
+
+ case BSSGP_PDU_FLOW_CONTROL_MS_ACK:{
+ status = bssgp_decode_flow_control_ms_ack(&msg[index],&pdu_len,incoming);
+ }
+ break;
+
+ case BSSGP_PDU_FLUSH_LL:{
+ status = bssgp_decode_flush_ll(&msg[index],&pdu_len,incoming);
+ }
+ break;
+
+ case BSSGP_PDU_FLUSH_LL_ACK:{
+ status = bssgp_decode_flush_ll_ack(&msg[index],&pdu_len,incoming);
+ }
+ break;
+
+ case BSSGP_PDU_FLOW_CONTROL_BVC:{
+ status = bssgp_decode_flow_control_bvc(&msg[index],&pdu_len,incoming);
+ }
+ break;
+
+ case BSSGP_PDU_FLOW_CONTROL_BVC_ACK:{
+ status = bssgp_decode_flow_control_bvc_ack(&msg[index],&pdu_len,incoming);
+ }
+ break;
+ /*
+ case BSSGP_PDU_PTM_UNITDATA:{
+ status = bssgp_decode_ptm_unitdata(&msg[index],&pdu_len,incoming,qos_level);
+ }
+ break;
+
+ case BSSGP_PDU_PAGING_CS:{
+ status = bssgp_decode_paging_cs(&msg[index],&pdu_len,incoming);
+ }
+ break;*/
+
+ case BSSGP_PDU_BVC_BLOCK:{
+ status = bssgp_decode_block(&msg[index],&pdu_len,incoming);
+ }
+ break;
+
+ case BSSGP_PDU_BVC_BLOCK_ACK:{
+ status = bssgp_decode_block_ack(&msg[index],&pdu_len,incoming);
+ }
+ break;
+
+ case BSSGP_PDU_RESET:{
+ status = bssgp_decode_reset(&msg[index],&pdu_len,incoming);
+ }
+ break;
+
+ case BSSGP_PDU_RESET_ACK:{
+ status = bssgp_decode_reset_ack(&msg[index],&pdu_len,incoming);
+ }
+ break;
+
+ case BSSGP_PDU_UNBLOCK:{
+ status = bssgp_decode_unblock(&msg[index],&pdu_len,incoming);
+ }
+ break;
+
+ case BSSGP_PDU_UNBLOCK_ACK:{
+ status = bssgp_decode_unblock_ack(&msg[index],&pdu_len,incoming);
+ }
+ break;
+
+ case BSSGP_PDU_LLC_DISCARDED:{
+ status = bssgp_decode_llc_discarded(&msg[index],&pdu_len,incoming);
+ }
+ break;
+ /*
+ case BSSGP_PDU_SGSN_INVOKE_TRACE:{
+ status = bssgp_decode_invoke_trace(&msg[index],&pdu_len,incoming);
+ }
+ break;*/
+
+ case BSSGP_PDU_STATUS:{
+ status = bssgp_decode_status(&msg[index],&pdu_len,incoming);
+ }
+ break;
+
+ default:{
+ DBG_ERROR("Unknown PDU ! Error");
+ }
+ } /* End of switch pdu_type */
+
+ DBG_LEAVE();
+ return (status);
+}
+
+
+
+/*
+ * bssgp_decode_dl_unitdata
+ *
+ * # DL-Unitdata is from GS --> MS in direction
+ * # Decode functions are triggered on rx of data from the network side
+ * # Hence this function would be called only on the GP-10 platform;
+ * and we need to Q the unitdata onto the buffer Qs to be picked up by RLC
+ *
+ */
+BOOL
+bssgp_decode_dl_unitdata(UINT8 *msg,UINT16 *msg_len, BSSGP_NETWORK_QOS_LEVEL qos_level)
+{
+ DBG_FUNC("bssgp_decode_dl_unitdata",BSSGP_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 index = 0;
+ BSSGP_DL_UNITDATA_MSG dl_unitdata;
+
+
+
+ byte = (UINT8*)&msg[index];
+ index++;
+
+ /* Check the PDU type */
+ if (*byte != BSSGP_PDU_DL_UNITDATA) {
+ DBG_ERROR("PDU type no DL UNITDATA; %s type",bssgp_util_get_pdu_type_str((BSSGP_PDU_TYPE)*byte));
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ memset(&dl_unitdata,0,sizeof(dl_unitdata));
+
+ DBG_TRACE("Decoding DL-Unitdata message");
+
+ /* Decode the individual IE indicators */
+
+ bssgp_ie_decode_tlli(&dl_unitdata.tlli,&msg[index],&index, BSSGP_FORMAT_V);
+
+ bssgp_ie_decode_qos_profile(&dl_unitdata.qos_profile,&msg[index],&index, BSSGP_FORMAT_V);
+
+ bssgp_ie_decode_qos_params(&dl_unitdata.qos_params,&msg[index],&index);
+
+ bssgp_ie_decode_pdu_lifetime(&dl_unitdata.pdu_lifetime,&msg[index],&index);
+
+ while(index < *msg_len) {
+ byte = (UINT8*)&msg[index];
+ switch(*byte) {
+ case BSSGP_IEI_TLLI:{
+ bssgp_ie_decode_tlli(&dl_unitdata.tlli_old,&msg[index],&index, BSSGP_FORMAT_TLV);
+ }
+ break;
+
+ case BSSGP_IEI_IMSI:{
+ bssgp_ie_decode_imsi(&dl_unitdata.imsi,&msg[index],&index);
+ }
+ break;
+
+ case BSSGP_IEI_MS_RADIO_ACCESS_CAP:{
+ bssgp_ie_decode_ms_ra_cap(&dl_unitdata.radio_access_cap,&msg[index],&index);
+ }
+ break;
+
+ case BSSGP_IEI_DRX_PARAMS:{
+ bssgp_ie_decode_drx_params(&dl_unitdata.drx_params,&msg[index],&index);
+ }
+ break;
+
+ case BSSGP_IEI_ALIGNMENT_OCTETS:{
+ bssgp_ie_decode_alignment_octets(&msg[index],&index);
+ }
+ break;
+
+ case BSSGP_IEI_LSA_INFORMATION:{
+ bssgp_ie_decode_lsa_info(&dl_unitdata.lsa_info,&msg[index],&index);
+ }
+ break;
+
+ case BSSGP_IEI_LLC_PDU:{
+#ifdef WIN32
+ LLC_PDU pdu;
+ pdu.data = bssgp_ie_decode_llc_pdu_ext(&pdu.data_len,&msg[index],&index);
+ llcwin32_pdu_handler(pdu);
+#else
+ bssgp_ie_decode_llc_pdu(&dl_unitdata, &msg[index],&index);
+ bssgp_udt_put_buffer_in_q(dl_unitdata.tlli.tlli,qos_level,(UINT8*)dl_unitdata.pdu.data,dl_unitdata.pdu.data_len,
+ dl_unitdata);
+
+#endif
+ }
+ break;
+
+ default: {
+ DBG_ERROR("BSSGP: Invalid IEI found in DL-UNITDATA decode %#x\n", *byte);
+ DBG_LEAVE();
+ return (FALSE);
+ /* TO DO : Report error to BSSGP peer here */
+ }
+ break;
+ }/* end of switch */
+ } /* end of while */
+
+ /* TO DO : Need to check for mandatory IEs & do the needful */
+
+ *msg_len -= index;
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+/*
+ * bssgp_decode_ul_unitdata
+ *
+ * # UL-Unitdata is from MS --> GS in direction
+ * # Decode functions are triggered on rx of data from the network side
+ * # Hence this function would be called only on the GS platform;
+ * and we need to pass on the unitdata to LLC (no need for Qing for Uplink)
+ */
+BOOL
+bssgp_decode_ul_unitdata(UINT8 *msg,UINT16 *msg_len,BSSGP_NETWORK_QOS_LEVEL qos_level,BSSGP_BVCI bvci)
+{
+ DBG_FUNC("bssgp_decode_ul_unitdata",BSSGP_LAYER);
+ DBG_ENTER();
+ UINT8 *byte;
+ UINT16 index = 0;
+ T_RIL3_IE_QOS_PROFILE_ID qos_profile;
+ RIL3_IE_CELL_IDENTIFIER cell_id;
+ RIL3_IE_LSA_IDENTIFIER_LIST lsa_id_list;
+ LLC_PDU pdu;
+ RIL3_TLLI tlli;
+ byte = (UINT8*)&msg[index];
+ index++;
+
+ /* Check the PDU type */
+ if (*byte != BSSGP_PDU_UL_UNITDATA) {
+ DBG_ERROR("PDU type not UL UNITDATA; %s type",bssgp_util_get_pdu_type_str((BSSGP_PDU_TYPE)*byte));
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+
+ DBG_TRACE("Decoding UL-Unitdata message");
+
+ bssgp_ie_decode_tlli(&tlli,&msg[index],&index, BSSGP_FORMAT_V);
+
+ bssgp_ie_decode_qos_profile(&qos_profile,&msg[index],&index, BSSGP_FORMAT_V);
+
+ while(index < *msg_len) {
+ byte = (UINT8*)&msg[index];
+ switch(*byte) {
+ case BSSGP_IEI_CELL_ID:{
+ bssgp_ie_decode_cell_id(&cell_id,&msg[index],&index);
+ }
+ break;
+
+ case BSSGP_IEI_ALIGNMENT_OCTETS:{
+ bssgp_ie_decode_alignment_octets(&msg[index],&index);
+ }
+ break;
+
+ case BSSGP_IEI_LSA_ID_LIST:{
+ bssgp_ie_decode_lsa_identifier_list(&lsa_id_list,&msg[index],&index);
+ }
+ break;
+
+ case BSSGP_IEI_LLC_PDU:{
+ pdu.data = bssgp_ie_decode_llc_pdu_ext(&pdu.data_len,&msg[index],&index);
+#if defined(MNET_GS)
+ /* Hate to wrap an ifdef; but no other way to retain most of the common code */
+ bssgp_api_send_ul_unitdata(tlli.tlli,cell_id.cell_id,cell_id.routing_area,pdu.data,pdu.data_len,bvci);
+#endif
+ }
+ break;
+ default: {
+ DBG_ERROR("BSSGP: Invalid IEI found in UL-UNITDATA decode %#x\n", *byte);
+ DBG_LEAVE();
+ return (FALSE);
+ /* TO DO : need to report error to peer BSSGP */
+ }
+ break;
+ } /* end of switch */
+ } /* end of while loop */
+
+
+ /* TO DO : Need to check for the presence of mandatory IEs */
+
+ *msg_len -= index;
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+/*
+ * bssgp_decode_paging
+ *
+ * Paging PDU defined in 08.18:-
+ *
+ * |-------------------------|
+ * | PDU Type |
+ * | IMSI |
+ * | DRX Params |
+ * | BVCI |
+ * | Location Area |
+ * | Routing Area |
+ * | BSS Area Indication |
+ * | QoS Profile |
+ * | P-TMSI |
+ * |-------------------------|
+ *
+ * From GS --> GP-10
+ */
+BOOL
+bssgp_decode_paging_ps(UINT8 *msg,UINT16 *msg_len, BOOL incoming)
+{
+ DBG_FUNC("bssgp_decode_paging_ps",BSSGP_LAYER);
+ DBG_ENTER();
+ UINT8 *byte;
+ UINT16 index = 0;
+ BSSGP_API_MSG api_msg;
+ BSSGP_PAGING_PS_MSG *paging_msg;
+
+
+ byte = (UINT8*)&msg[index];
+ index++;
+
+ /* First check the PDU type */
+ if (*byte != (UINT8)BSSGP_PDU_PAGING_PS) {
+ DBG_ERROR("PDU not paging-ps msg, type %s!",
+ bssgp_util_get_pdu_type_str((BSSGP_PDU_TYPE)*byte));
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ /* Clean up an API msg so we have it handy */
+ memset(&api_msg,0,sizeof(api_msg));
+ api_msg.magic = BSSGP_MAGIC;
+ api_msg.msg_type = BSSGP_API_MSG_PAGING_PS;
+ paging_msg = (BSSGP_PAGING_PS_MSG*)&api_msg.msg.paging_ps;
+
+
+
+
+ paging_msg->imsi.ie_present = FALSE;
+ paging_msg->location_area.ie_present = FALSE;
+ paging_msg->routing_area.ie_present = FALSE;
+ paging_msg->drx_params.ie_present = FALSE;
+ paging_msg->qos_profile.ie_present = FALSE;
+ paging_msg->tmsi.ie_present = FALSE;
+ paging_msg->bvci.ie_present = FALSE;
+ paging_msg->bss_area.ie_present = FALSE;
+
+ /* Decode the individual IE indicators */
+ DBG_TRACE("Decoding Packet-Switched Paging message");
+
+ while (index < *msg_len) {
+ byte = (UINT8*)&msg[index];
+ switch (*byte) {
+
+ case BSSGP_IEI_IMSI: {
+ if (bssgp_ie_decode_imsi(&paging_msg->imsi,&msg[index],&index)) {
+ paging_msg->imsi.ie_present = TRUE;
+ }
+ else {
+ /* TODO : Report error to peer BSSGP here */
+ }
+ }
+ break;
+
+ case BSSGP_IEI_BVCI: {
+ if (bssgp_ie_decode_bvci(&paging_msg->bvci,&msg[index],&index)) {
+ }
+ else {
+ /* TODO : Report error to peer BSSGP here */
+ }
+ }
+ break;
+
+ case BSSGP_IEI_LOCATION_AREA:{
+ if (bssgp_ie_decode_location_area(&paging_msg->location_area,&msg[index],&index)) {
+ paging_msg->location_area.ie_present = TRUE;
+ }
+ else {
+ /* TODO : Report error to peer BSSGP here */
+ }
+ }
+ break;
+
+ case BSSGP_IEI_ROUTING_AREA:{
+ if(bssgp_ie_decode_routing_area(&paging_msg->routing_area,&msg[index],&index)) {
+ paging_msg->routing_area.ie_present = TRUE;
+ }
+ else {
+ /* TODO : Report error to peer BSSGP here */
+ }
+ }
+ break;
+
+ case BSSGP_IEI_BSS_AREA_IND:{
+ if(bssgp_ie_decode_bss_area_ind(&paging_msg->bss_area,&msg[index],&index)) {
+ paging_msg->bss_area.ie_present = TRUE;
+ }
+ else {
+ /* TODO : Report error to peer BSSGP here */
+ }
+ }
+ break;
+
+ case BSSGP_IEI_DRX_PARAMS:{
+ if(bssgp_ie_decode_drx_params(&paging_msg->drx_params,&msg[index],&index)) {
+ paging_msg->drx_params.ie_present = TRUE;
+ }
+ else {
+ /* TODO : Report error to peer BSSGP here */
+ }
+ }
+ break;
+
+ case BSSGP_IEI_QOS_PROFILE:{
+ if(bssgp_ie_decode_qos_profile(&paging_msg->qos_profile,&msg[index],&index, BSSGP_FORMAT_TLV)) {
+ paging_msg->qos_profile.ie_present = TRUE;
+ }
+ else {
+ /* TODO : Report error to peer BSSGP here */
+ }
+ }
+ break;
+
+ case BSSGP_IEI_TMSI:{
+ if (bssgp_ie_decode_tmsi(&paging_msg->tmsi,&msg[index],&index)) {
+ paging_msg->tmsi.ie_present = TRUE;
+ }
+ else {
+ /* TODO : Report error to peer BSSGP here */
+ }
+ }
+ break;
+
+ default: {
+ DBG_ERROR("BSSGP: Invalid IEI found in PAGING-PS decode %#x\n", *byte);
+ DBG_LEAVE();
+ return (FALSE);
+ /* TO DO : need to report error to peer BSSGP */
+ }
+ break;
+
+ } /* end of switch */
+ } /* End of while loop */
+
+ *msg_len -= index;
+ DBG_TRACE("Paging-PS message %d bytes length",index);
+
+#if defined(MNET_GP10)
+ if (!rm_bssgp_msg_callback(api_msg)) {
+ DBG_ERROR("GRR reports error on Packet-Switched paging msg");
+ }
+ else {
+ DBG_TRACE("Posted packet-switched paging msg to GRR successfully");
+ }
+
+#elif defined(MNET_GS)
+ DBG_ERROR("BSSGP: Unexpected PAGING PS message\n");
+ DBG_LEAVE();
+ return (FALSE);
+#endif
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+
+
+/*
+ * bssgp_decode_radio_status
+ *
+ * Radio Status PDU defined in 08.18:-
+ *
+ * |--------------|
+ * | PDU type |
+ * | TLLI |
+ * | TMSI |
+ * | IMSI |
+ * | Radio Cause |
+ * |--------------|
+ *
+ * From GP-10 to GS
+ */
+BOOL
+bssgp_decode_radio_status(UINT8 *msg,UINT16 *msg_len, BOOL incoming)
+{
+ DBG_FUNC("bssgp_decode_radio_status",BSSGP_LAYER);
+ DBG_ENTER();
+ UINT8 *byte;
+ UINT16 index = 0;
+ BSSGP_API_MSG api_msg;
+ BSSGP_RADIO_STATUS_MSG *radio_status_msg;
+
+ byte = (UINT8*)&msg[index];
+ index++;
+
+ /* Check the PDU type */
+ if (*byte != (UINT8)BSSGP_PDU_RADIO_STATUS) {
+ DBG_ERROR("PDU not Radio Status msg, type %s!",
+ bssgp_util_get_pdu_type_str((BSSGP_PDU_TYPE)*byte));
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+
+ /* Clean up an API msg so we have it handy */
+ memset(&api_msg,0,sizeof(api_msg));
+ api_msg.magic = BSSGP_MAGIC;
+ api_msg.msg_type = BSSGP_API_MSG_RADIO_STATUS;
+ radio_status_msg = (BSSGP_RADIO_STATUS_MSG*)&api_msg.msg.radio_status;
+
+
+
+
+ /* Decode the individual IE indicators */
+ DBG_TRACE("Decoding Radio Status message");
+
+ /* tlli */
+ if (msg[index] == BSSGP_IEI_TLLI)
+ {
+ if (!bssgp_ie_decode_tlli(&radio_status_msg->tlli,&msg[index],&index, BSSGP_FORMAT_TLV)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+ }
+ /* tmsi */
+ if (msg[index] == BSSGP_IEI_TMSI)
+ {
+ if (bssgp_ie_decode_tmsi(&radio_status_msg->tmsi,&msg[index],&index)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+ }
+
+ /* imsi */
+ if (msg[index] == BSSGP_IEI_IMSI)
+ {
+ if (bssgp_ie_decode_imsi(&radio_status_msg->imsi,&msg[index],&index)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+ }
+
+ /* cause */
+ if (bssgp_ie_decode_radio_cause(&radio_status_msg->cause,&msg[index],&index)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+
+ DBG_TRACE("Radio Status message %d bytes length",index);
+
+
+ *msg_len -= index;
+
+#if defined(MNET_GP10)
+ DBG_ERROR("BSSGP: Unexpected RADIO STATUS message\n");
+ DBG_LEAVE();
+ return (FALSE);
+#elif defined(MNET_GS)
+ if (!gmm_bssgp_msg_callback(api_msg)) {
+ DBG_ERROR("GMM reports error on Radio Status msg");
+ }
+ else {
+ DBG_TRACE("Posted Radio Status msg to GMM successfully");
+ }
+#endif
+
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+/*
+ * bssgp_decode_suspend
+ *
+ * Suspend PDU defined in 08.18:-
+ *
+ * |-------------------------|
+ * | PDU Type |
+ * | TLLI |
+ * | Routing Area |
+ * |-------------------------|
+ *
+ * From GP-10 to GS
+ */
+BOOL
+bssgp_decode_suspend(UINT8 *msg,UINT16 *msg_len, BOOL incoming)
+{
+ DBG_FUNC("bssgp_decode_suspend",BSSGP_LAYER);
+ DBG_ENTER();
+ UINT8 *byte;
+ UINT16 index = 0;
+ BSSGP_API_MSG api_msg;
+ BSSGP_SUSPEND_MSG *suspend_msg;
+
+ byte = (UINT8*)&msg[index];
+ index++;
+
+ /* Check the PDU type */
+ if (*byte != BSSGP_PDU_SUSPEND) {
+ DBG_ERROR("PDU not Suspend msg, type %s!",
+ bssgp_util_get_pdu_type_str((BSSGP_PDU_TYPE)*byte));
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ /* Clean up an API msg so we have it handy */
+ memset(&api_msg,0,sizeof(api_msg));
+ api_msg.magic = BSSGP_MAGIC;
+ api_msg.msg_type = BSSGP_API_MSG_SUSPEND;
+ suspend_msg = (BSSGP_SUSPEND_MSG*)&api_msg.msg.suspend;
+
+
+ /* Decode the individual IE indicators */
+ DBG_TRACE("Decoding Suspend message");
+
+ /* tlli */
+ if (!bssgp_ie_decode_tlli(&suspend_msg->tlli,&msg[index],&index, BSSGP_FORMAT_TLV)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+
+ /* routing area */
+ if (!bssgp_ie_decode_routing_area(&suspend_msg->routing_area,&msg[index],&index)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+
+ DBG_TRACE("Suspend message %d bytes length",index);
+
+ *msg_len -= index;
+
+#if defined(MNET_GP10)
+ DBG_ERROR("BSSGP: Unexpected SUSPEND message\n");
+ DBG_LEAVE();
+ return (FALSE);
+#elif defined(MNET_GS)
+ if (!gmm_bssgp_msg_callback(api_msg)) {
+ DBG_ERROR("GMM reports error on Suspend msg");
+ }
+ else {
+ DBG_TRACE("Posted Suspend msg to GMM successfully");
+ }
+#endif
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+/*
+ * bssgp_decode_suspend_ack
+ *
+ * Suspend Ack PDU defined in 08.18:-
+ *
+ * |-------------------------|
+ * | PDU Type |
+ * | TLLI |
+ * | Routing Area |
+ * | Suspend Ref Num. |
+ * | BVCI (prop. ext.) |
+ * |-------------------------|
+ *
+ * From GS --> GP-10
+ */
+BOOL
+bssgp_decode_suspend_ack(UINT8 *msg,UINT16 *msg_len, BOOL incoming)
+{
+ DBG_FUNC("bssgp_decode_suspend_ack",BSSGP_LAYER);
+ DBG_ENTER();
+ UINT8 *byte;
+ UINT16 index = 0;
+ BSSGP_API_MSG api_msg;
+ BSSGP_SUSPEND_ACK_MSG *suspend_ack_msg;
+
+ byte = (UINT8*)&msg[index];
+ index++;
+
+ /* Set the PDU type */
+ if (*byte != (UINT8)BSSGP_PDU_SUSPEND_ACK) {
+ DBG_ERROR("PDU not Suspend-Ack msg, type %s!",
+ bssgp_util_get_pdu_type_str((BSSGP_PDU_TYPE)*byte));
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ /* Clean up an API msg so we have it handy */
+ memset(&api_msg,0,sizeof(api_msg));
+ api_msg.magic = BSSGP_MAGIC;
+ api_msg.msg_type = BSSGP_API_MSG_SUSPEND_ACK;
+ suspend_ack_msg = (BSSGP_SUSPEND_ACK_MSG*)&api_msg.msg.suspend_ack;
+
+ /* Decode the individual IE indicators */
+ DBG_TRACE("Decoding Suspend-Ack message");
+
+ /* tlli */
+ if (!bssgp_ie_decode_tlli(&suspend_ack_msg->tlli,&msg[index],&index, BSSGP_FORMAT_TLV)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+ /* routing area */
+ if (!bssgp_ie_decode_routing_area(&suspend_ack_msg->routing_area,&msg[index],&index)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+ /* suspend ref num */
+ if (!bssgp_ie_decode_suspend_ref_num((UINT8*)&suspend_ack_msg->suspend_ref_num,&msg[index],&index)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+
+ *msg_len -= index;
+ DBG_TRACE("Suspend-Ack message %d bytes length",index);
+
+#if defined(MNET_GP10)
+ if (!gmm_bssgp_msg_callback(api_msg)) {
+ DBG_ERROR("GMM reports error on Suspend-Ack msg");
+ }
+ else {
+ DBG_TRACE("Posted Suspend-Ack msg to GMM successfully");
+ }
+#elif defined(MNET_GS)
+ DBG_ERROR("BSSGP: Unexpected SUSPEND ACK message\n");
+ DBG_LEAVE();
+ return (FALSE);
+#endif
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+/*
+ * bssgp_decode_suspend_nack
+ *
+ * Suspend NAck PDU defined in 08.18:-
+ *
+ * |-------------------------|
+ * | PDU Type |
+ * | TLLI |
+ * | Routing Area |
+ * | Exception cause |
+ * | BVCI (prop. ext.) |
+ * |-------------------------|
+ *
+ * From GS --> GP-10
+ */
+BOOL
+bssgp_decode_suspend_nack(UINT8 *msg,UINT16 *msg_len, BOOL incoming)
+{
+ DBG_FUNC("bssgp_decode_suspend_nack",BSSGP_LAYER);
+ DBG_ENTER();
+ UINT8 *byte;
+ UINT16 index = 0;
+ BSSGP_API_MSG api_msg;
+ BSSGP_SUSPEND_NACK_MSG *suspend_nack_msg;
+
+ byte = (UINT8*)&msg[index];
+ index++;
+
+ /* Check the PDU type */
+ if (*byte != (UINT8)BSSGP_PDU_SUSPEND_NACK) {
+ DBG_ERROR("PDU not Suspend-Nack msg, type %s!",
+ bssgp_util_get_pdu_type_str((BSSGP_PDU_TYPE)*byte));
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ /* Clean up an API msg so we have it handy */
+ memset(&api_msg,0,sizeof(api_msg));
+ api_msg.magic = BSSGP_MAGIC;
+ api_msg.msg_type = BSSGP_API_MSG_SUSPEND_NACK;
+ suspend_nack_msg = (BSSGP_SUSPEND_NACK_MSG*)&api_msg.msg.suspend_nack;
+
+ /* Decode the individual IE indicators */
+ DBG_TRACE("Decoding Suspend-Nack message");
+
+ /* tlli */
+ if (!bssgp_ie_decode_tlli(&suspend_nack_msg->tlli,&msg[index],&index, BSSGP_FORMAT_TLV)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+
+ /* routing area */
+ if (!bssgp_ie_decode_routing_area(&suspend_nack_msg->routing_area,&msg[index],&index)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+
+ /* exception cause */
+ if (msg[index] == BSSGP_IEI_CAUSE)
+ {
+ if (!bssgp_ie_decode_exception_cause(&suspend_nack_msg->exception_cause,&msg[index],&index)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+ }
+
+ *msg_len -= index;
+ DBG_TRACE("Suspend-NAck message %d bytes length",index);
+
+#if defined(MNET_GP10)
+ if (!gmm_bssgp_msg_callback(api_msg)) {
+ DBG_ERROR("GMM reports error on Suspend-Nack msg");
+ }
+ else {
+ DBG_TRACE("Posted Suspend-Nack msg to GMM successfully");
+ }
+#elif defined(MNET_GS)
+ DBG_ERROR("BSSGP: Unexpected SUSPEND-NACK message\n");
+ DBG_LEAVE();
+ return (FALSE);
+#endif
+
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+
+
+/*
+ * bssgp_decode_resume
+ *
+ * Resume PDU defined in 08.18:-
+ *
+ * |-------------------------|
+ * | PDU Type |
+ * | TLLI |
+ * | Routing Area |
+ * | Suspend ref num. |
+ * |-------------------------|
+ *
+ * From GP-10 to GS
+ */
+BOOL
+bssgp_decode_resume(UINT8 *msg,UINT16 *msg_len, BOOL incoming)
+{
+ DBG_FUNC("bssgp_decode_resume",BSSGP_LAYER);
+ DBG_ENTER();
+ UINT8 *byte;
+ UINT16 index = 0;
+ BSSGP_API_MSG api_msg;
+ BSSGP_RESUME_MSG *resume_msg;
+
+
+ byte = (UINT8*)&msg[index];
+ index++;
+
+ /* Check the PDU type */
+ if (*byte != BSSGP_PDU_RESUME) {
+ DBG_ERROR("PDU not Resume msg, type %s!",
+ bssgp_util_get_pdu_type_str((BSSGP_PDU_TYPE)*byte));
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+
+ /* Clean up an API msg so we have it handy */
+ memset(&api_msg,0,sizeof(api_msg));
+ api_msg.magic = BSSGP_MAGIC;
+ api_msg.msg_type = BSSGP_API_MSG_RESUME;
+ resume_msg = (BSSGP_RESUME_MSG*)&api_msg.msg.resume;
+
+ DBG_TRACE("Decoding Resume message");
+
+ /* Decode the individual IE indicators */
+ /* tlli */
+ if (!bssgp_ie_decode_tlli(&resume_msg->tlli,&msg[index],&index, BSSGP_FORMAT_TLV)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+
+ /* routing area */
+ if (!bssgp_ie_decode_routing_area(&resume_msg->routing_area,&msg[index],&index)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+
+ /* suspend ref num */
+ if (!bssgp_ie_decode_suspend_ref_num((UINT8*)&resume_msg->suspend_ref_num,&msg[index],&index)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+
+
+ *msg_len -= index;
+ DBG_TRACE("Resume message %d bytes length",index);
+
+#if defined(MNET_GP10)
+ DBG_ERROR("BSSGP: Unexpected RESUME message\n");
+ DBG_LEAVE();
+ return (FALSE);
+#elif defined(MNET_GS)
+ if (!gmm_bssgp_msg_callback(api_msg)) {
+ DBG_ERROR("GMM reports error on Resume msg");
+ }
+ else {
+ DBG_TRACE("Posted Resume msg to GMM successfully");
+ }
+#endif
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+/*
+ * bssgp_decode_resume_ack
+ *
+ * Resume-Ack PDU defined in 08.18:-
+ *
+ * |-------------------------|
+ * | PDU Type |
+ * | TLLI |
+ * | Routing Area |
+ * | BVCI (prop. ext.) |
+ * |-------------------------|
+ *
+ * From GS --> GP-10
+ */
+BOOL
+bssgp_decode_resume_ack(UINT8 *msg,UINT16 *msg_len, BOOL incoming)
+{
+ DBG_FUNC("bssgp_decode_resume_ack",BSSGP_LAYER);
+ DBG_ENTER();
+ UINT8 *byte;
+ UINT16 index = 0;
+ BSSGP_API_MSG api_msg;
+ BSSGP_RESUME_ACK_MSG *resume_ack_msg;
+
+ byte = (UINT8*)&msg[index];
+ index++;
+
+ /* Check the PDU type */
+ if (*byte != BSSGP_PDU_RESUME_ACK) {
+ DBG_ERROR("PDU not Resume msg, type %s!",
+ bssgp_util_get_pdu_type_str((BSSGP_PDU_TYPE)*byte));
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ /* Clean up an API msg so we have it handy */
+ memset(&api_msg,0,sizeof(api_msg));
+ api_msg.magic = BSSGP_MAGIC;
+ api_msg.msg_type = BSSGP_API_MSG_RESUME_ACK;
+ resume_ack_msg = (BSSGP_RESUME_ACK_MSG*)&api_msg.msg.resume_ack;
+
+ /* Decode the individual IE indicators */
+ DBG_TRACE("Decoding Resume-Ack message");
+
+ /* tlli */
+ if (!bssgp_ie_decode_tlli(&resume_ack_msg->tlli,&msg[index],&index, BSSGP_FORMAT_TLV)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+
+ /* routing area */
+ if (!bssgp_ie_decode_routing_area(&resume_ack_msg->routing_area,&msg[index],&index)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+
+ *msg_len -= index;
+ DBG_TRACE("Resume-Ack message %d bytes length",index);
+
+#if defined(MNET_GP10)
+ DBG_ERROR("BSSGP: Unexpected RESUME-ACK message\n");
+ DBG_LEAVE();
+ return (FALSE);
+#elif defined(MNET_GS)
+ if (!gmm_bssgp_msg_callback(api_msg)) {
+ DBG_ERROR("GMM reports error on Resume-Ack msg");
+ }
+ else {
+ DBG_TRACE("Posted Resume-Ack msg to GMM successfully");
+ }
+#endif
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+/*
+ * bssgp_decode_resume_nack
+ *
+ * Resume-NAck PDU defined in 08.18:-
+ *
+ * |-------------------------|
+ * | PDU Type |
+ * | TLLI |
+ * | Routing Area |
+ * | Exception cause |
+ * |-------------------------|
+ *
+ * From GS --> GP-10
+ */
+BOOL
+bssgp_decode_resume_nack(UINT8 *msg,UINT16 *msg_len, BOOL incoming)
+{
+ DBG_FUNC("bssgp_decode_resume_nack",BSSGP_LAYER);
+ DBG_ENTER();
+ UINT8 *byte;
+ UINT16 index = 0;
+ BSSGP_API_MSG api_msg;
+ BSSGP_RESUME_NACK_MSG *resume_nack_msg;
+
+
+ byte = (UINT8*)&msg[index];
+ index++;
+
+ /* Check the PDU type */
+ if (*byte != BSSGP_PDU_RESUME_NACK) {
+ DBG_ERROR("PDU not Resume msg, type %s!",
+ bssgp_util_get_pdu_type_str((BSSGP_PDU_TYPE)*byte));
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ /* Clean up an API msg so we have it handy */
+ memset(&api_msg,0,sizeof(api_msg));
+ api_msg.magic = BSSGP_MAGIC;
+ api_msg.msg_type = BSSGP_API_MSG_RESUME_NACK;
+ resume_nack_msg = (BSSGP_RESUME_NACK_MSG*)&api_msg.msg.resume_nack;
+
+ /* Decode the individual IE indicators */
+ DBG_TRACE("Decoding Resume-NAck message");
+
+ /* tlli */
+ if (!bssgp_ie_decode_tlli(&resume_nack_msg->tlli,&msg[index],&index, BSSGP_FORMAT_TLV)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+
+ /* routing area */
+ if (!bssgp_ie_decode_routing_area(&resume_nack_msg->routing_area,&msg[index],&index)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+
+ /* exception cause */
+ if (msg[index] == BSSGP_IEI_CAUSE)
+ {
+ if (!bssgp_ie_decode_exception_cause(&resume_nack_msg->exception_cause,&msg[index],&index)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+ }
+
+ *msg_len -= index;
+ DBG_TRACE("Resume-NAck message %d bytes length",index);
+
+#if defined(MNET_GP10)
+ DBG_ERROR("BSSGP: Unexpected RESUME NACK message\n");
+ DBG_LEAVE();
+ return (FALSE);
+#elif defined(MNET_GS)
+ if (!gmm_bssgp_msg_callback(api_msg)) {
+ DBG_ERROR("GMM reports error on Resume-Nack msg");
+ }
+ else {
+ DBG_TRACE("Posted Resume-Nack msg to GMM successfully");
+ }
+#endif
+
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+
+
+/*
+ * bssgp_decode_location_update
+ *
+ * Location-Update PDU defined by
+ * Cisco-EWTBU (proprietary)
+ *
+ * |-------------------------|
+ * | PDU Type |
+ * | IMSI |
+ * | BVCI |
+ * | Location Area |
+ * | Routing Area |
+ * |-------------------------|
+ *
+ * From GS --> GP-10
+ */
+BOOL
+bssgp_decode_location_update(UINT8 *msg,UINT16 *msg_len, BOOL incoming)
+{
+ DBG_FUNC("bssgp_decode_location_update",BSSGP_LAYER);
+ DBG_ENTER();
+ UINT8 *byte;
+ UINT16 index = 0;
+ BSSGP_API_MSG api_msg;
+ BSSGP_LOCATION_UPDATE_MSG *location_update_msg;
+
+ byte = (UINT8*)&msg[index];
+ index++;
+
+ /* Check the PDU type */
+ if (*byte != BSSGP_PDU_LOCATION_UPDATE) {
+ DBG_ERROR("PDU not Location-Update msg, type %s!",
+ bssgp_util_get_pdu_type_str((BSSGP_PDU_TYPE)*byte));
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ /* Clean up an API msg so we have it handy */
+ memset(&api_msg,0,sizeof(api_msg));
+ api_msg.magic = BSSGP_MAGIC;
+ api_msg.msg_type = BSSGP_API_MSG_LOCATION_UPDATE;
+ location_update_msg = (BSSGP_LOCATION_UPDATE_MSG*)&api_msg.msg.location_update;
+
+ /* Encode the individual IE indicators */
+ DBG_TRACE("Decoding Location-Update message");
+
+ /* imsi */
+ if (!bssgp_ie_decode_imsi(&location_update_msg->imsi,&msg[index],&index)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+
+ /* bvci */
+ if (!bssgp_ie_decode_bvci(&location_update_msg->bvci,&msg[index],&index)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+
+ /* location area */
+ if (!bssgp_ie_decode_location_area(&location_update_msg->location_area,&msg[index],&index)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+
+
+ /* routing area */
+ if (!bssgp_ie_decode_routing_area(&location_update_msg->routing_area,&msg[index],&index)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+
+ *msg_len -= index;
+ DBG_TRACE("Location-Update message %d bytes length",index);
+
+#if defined(MNET_GP10)
+ if (!gmm_bssgp_msg_callback(api_msg)) {
+ DBG_ERROR("GMM reports error on Location Update msg");
+ }
+ else {
+ DBG_TRACE("Posted Location Update msg to GMM successfully");
+ }
+#elif defined(MNET_GS)
+ DBG_ERROR("BSSGP: Unexpected LOCATION UPDATE message\n");
+ DBG_LEAVE();
+ return (FALSE);
+#endif
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+
+/*
+ * bssgp_decode_location_update_ack
+ *
+ * Location-Update-Ack PDU defined by
+ * Cisco-EWTBU (proprietary)
+ *
+ * |-------------------------|
+ * | PDU Type |
+ * | IMSI |
+ * | Location Area |
+ * |-------------------------|
+ *
+ * From GP-10 to GS
+ */
+BOOL
+bssgp_decode_location_update_ack(UINT8 *msg,UINT16 *msg_len, BOOL incoming)
+{
+ DBG_FUNC("bssgp_decode_location_update_ack",BSSGP_LAYER);
+ DBG_ENTER();
+ UINT8 *byte;
+ UINT16 index = 0;
+ BSSGP_API_MSG api_msg;
+ BSSGP_LOCATION_UPDATE_ACK_MSG *location_update_ack;
+
+ byte = (UINT8*)&msg[index];
+ index++;
+
+ /* Check the PDU type */
+ if (*byte != BSSGP_PDU_LOCATION_UPDATE_ACK) {
+ DBG_ERROR("PDU not Location-Update-Ack msg, type %s!",
+ bssgp_util_get_pdu_type_str((BSSGP_PDU_TYPE)*byte));
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ /* Clean up an API msg so we have it handy */
+ memset(&api_msg,0,sizeof(api_msg));
+ api_msg.magic = BSSGP_MAGIC;
+ api_msg.msg_type = BSSGP_API_MSG_LOCATION_UPDATE_ACK;
+ location_update_ack = (BSSGP_LOCATION_UPDATE_ACK_MSG*)&api_msg.msg.location_update_ack;
+
+ /* Encode the individual IE indicators */
+ DBG_TRACE("Decoding Location-Update-Ack message");
+
+
+ /* imsi */
+ if (!bssgp_ie_decode_imsi(&location_update_ack->imsi,&msg[index],&index)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+
+ /* location area */
+ if (!bssgp_ie_decode_location_area(&location_update_ack->location_area,&msg[index],&index)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+
+ *msg_len -= index;
+ DBG_TRACE("Location-Update-Ack message %d bytes length",index);
+
+#if defined(MNET_GP10)
+ DBG_ERROR("BSSGP: Unexpected LOCATION UPDATE ACK message\n");
+ DBG_LEAVE();
+ return (FALSE);
+#elif defined(MNET_GS)
+ if (!gmm_bssgp_msg_callback(api_msg)) {
+ DBG_ERROR("GMM reports error on Location-Update-Ack msg");
+ }
+ else {
+ DBG_TRACE("Posted Location-Update-Ack msg to GMM successfully");
+ }
+#endif
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+
+/*
+ * bssgp_decode_location_update_nack
+ *
+ * Location-Update-NAck PDU defined by
+ * Cisco-EWTBU (proprietary)
+ *
+ * |-------------------------|
+ * | PDU Type |
+ * | IMSI |
+ * | Location Area |
+ * | Reject cause |
+ * |-------------------------|
+ *
+ * From GP-10 to GS
+ */
+BOOL
+bssgp_decode_location_update_nack(UINT8 *msg,UINT16 *msg_len, BOOL incoming)
+{
+ DBG_FUNC("bssgp_decode_location_update_nack",BSSGP_LAYER);
+ DBG_ENTER();
+ UINT8 *byte;
+ UINT16 index = 0;
+ BSSGP_API_MSG api_msg;
+ BSSGP_LOCATION_UPDATE_NACK_MSG *location_update_nack;
+
+ byte = (UINT8*)&msg[index];
+ index++;
+
+ /* Check the PDU type */
+ if (*byte != BSSGP_PDU_LOCATION_UPDATE_NACK) {
+ DBG_ERROR("PDU not Location-Update-NAck msg, type %s!",
+ bssgp_util_get_pdu_type_str((BSSGP_PDU_TYPE)*byte));
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ /* Clean up an API msg so we have it handy */
+ memset(&api_msg,0,sizeof(api_msg));
+ api_msg.magic = BSSGP_MAGIC;
+ api_msg.msg_type = BSSGP_API_MSG_LOCATION_UPDATE_NACK;
+ location_update_nack= (BSSGP_LOCATION_UPDATE_NACK_MSG*)&api_msg.msg.location_update_nack;
+
+
+ /* Decode the individual IE indicators */
+ DBG_TRACE("Decoding Location-Update-NAck message");
+
+
+ /* imsi */
+ if (!bssgp_ie_decode_imsi(&location_update_nack->imsi,&msg[index],&index)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+
+ /* location area */
+ if (!bssgp_ie_decode_location_area(&location_update_nack->location_area,&msg[index],&index)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+
+
+ /* reject cause */
+ if (!bssgp_ie_decode_reject_cause(&location_update_nack->reject_cause,&msg[index],&index)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+
+
+ *msg_len -= index;
+ DBG_TRACE("Location-Update-NAck message %d bytes length",index);
+
+#if defined(MNET_GP10)
+ DBG_ERROR("BSSGP: Unexpected LOCATION UPDATE NACK message\n");
+ DBG_LEAVE();
+ return (FALSE);
+#elif defined(MNET_GS)
+ if (!gmm_bssgp_msg_callback(api_msg)) {
+ DBG_ERROR("GMM reports error on Location-Update-Nack msg");
+ }
+ else {
+ DBG_TRACE("Posted Location-Update-Nack msg to GMM successfully");
+ }
+#endif
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+
+
+/*
+ * bssgp_decode_radio_cap
+ *
+ * Radio-Access-Capability PDU defined in
+ * 08.18
+ *
+ * |-------------------------|
+ * | PDU Type |
+ * | TLLI |
+ * | MS Radio Access Cap |
+ * | BVCI (prop. ext.) |
+ * |-------------------------|
+ *
+ * From GS to GP-10
+ */
+BOOL
+bssgp_decode_radio_cap(UINT8 *msg,UINT16 *msg_len, BOOL incoming)
+{
+ DBG_FUNC("bssgp_decode_radio_cap",BSSGP_LAYER);
+ DBG_ENTER();
+ UINT8 *byte;
+ UINT16 index = 0;
+ BSSGP_API_MSG api_msg;
+ BSSGP_RADIO_CAP_MSG *radio_cap;
+
+ byte = (UINT8*)&msg[index];
+ index++;
+
+ /* Check the PDU type */
+ if (*byte != BSSGP_PDU_RA_CAP) {
+ DBG_ERROR("PDU not RA-Cap msg, type %s!",
+ bssgp_util_get_pdu_type_str((BSSGP_PDU_TYPE)*byte));
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ /* Clean up an API msg so we have it handy */
+ memset(&api_msg,0,sizeof(api_msg));
+ api_msg.magic = BSSGP_MAGIC;
+ api_msg.msg_type = BSSGP_API_MSG_RADIO_CAP;
+ radio_cap = (BSSGP_RADIO_CAP_MSG*)&api_msg.msg.radio_cap;
+
+ /* Decode the individual IE indicators */
+ DBG_TRACE("Decoding Radio-Access-Capability message");
+
+
+ /* tlli */
+ if (!bssgp_ie_decode_tlli(&radio_cap->tlli,&msg[index],&index, BSSGP_FORMAT_TLV)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+
+ /* ra-cap */
+ if (!bssgp_ie_decode_ms_ra_cap(&radio_cap->ra_cap,&msg[index],&index)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+
+ *msg_len -= index;
+ DBG_TRACE("Radio-Access-Capability message %d bytes length",index);
+
+#if defined(MNET_GP10)
+ if (!gmm_bssgp_msg_callback(api_msg)) {
+ DBG_ERROR("GMM reports error on Radio-Access-Capability msg");
+ }
+ else {
+ DBG_TRACE("Posted Radio-Access-Capability msg to GMM successfully");
+ }
+#elif defined(MNET_GS)
+ DBG_ERROR("BSSGP: Unexpected RA-CAPABILITY message\n");
+ DBG_LEAVE();
+ return (FALSE);
+#endif
+
+ DBG_LEAVE();
+ return(TRUE);
+}
+
+
+/*
+ * bssgp_decode_radio_cap_update
+ *
+ * Radio-Access-Capability-Update PDU defined in
+ * 08.18
+ *
+ * |-------------------------|
+ * | PDU Type |
+ * | TLLI |
+ * | Tag |
+ * |-------------------------|
+ *
+ * From GP-10 to GS
+ */
+BOOL
+bssgp_decode_radio_cap_update(UINT8 *msg,UINT16 *msg_len, BOOL incoming)
+{
+ DBG_FUNC("bssgp_decode_radio_cap_update",BSSGP_LAYER);
+ DBG_ENTER();
+ UINT8 *byte;
+ UINT16 index = 0;
+ BSSGP_API_MSG api_msg;
+ BSSGP_RADIO_CAP_UPDATE_MSG *radio_cap_update;
+
+ byte = (UINT8*)&msg[index];
+ index++;
+
+ /* Check the PDU type */
+ if (*byte != BSSGP_PDU_RA_CAP_UPDATE) {
+ DBG_ERROR("PDU not RA-Cap-Update msg, type %s!",
+ bssgp_util_get_pdu_type_str((BSSGP_PDU_TYPE)*byte));
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ /* Clean up an API msg so we have it handy */
+ memset(&api_msg,0,sizeof(api_msg));
+ api_msg.magic = BSSGP_MAGIC;
+ api_msg.msg_type = BSSGP_API_MSG_RADIO_CAP_UPDATE;
+ radio_cap_update = (BSSGP_RADIO_CAP_UPDATE_MSG*)&api_msg.msg.radio_cap_update;
+
+ /* Decode the individual IE indicators */
+ DBG_TRACE("Decoding Radio-Access-Capability-Update message");
+
+ /* tlli */
+ if (!bssgp_ie_decode_tlli(&radio_cap_update->tlli,&msg[index],&index, BSSGP_FORMAT_TLV)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+
+ /* tag */
+ if (!bssgp_ie_decode_tag(&radio_cap_update->tag,&msg[index],&index)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+
+ *msg_len -= index;
+ DBG_TRACE("Radio-Access-Capability-Update message %d bytes length",index);
+
+#if defined(MNET_GP10)
+ DBG_ERROR("BSSGP: Unexpected RA-CAPABILITY-UPDATE message\n");
+ DBG_LEAVE();
+ return (FALSE);
+#elif defined(MNET_GS)
+ if (!gmm_bssgp_msg_callback(api_msg)) {
+ DBG_ERROR("GMM reports error on Radio-Access-Capability-Update msg");
+ }
+ else {
+ DBG_TRACE("Posted Radio-Access-Capability-Update msg to GMM successfully");
+ }
+#endif
+
+ DBG_LEAVE();
+ return(TRUE);
+}
+
+
+/*
+ * bssgp_decode_radio_cap_update_ack
+ *
+ * Radio-Access-Capability-Update-ACK PDU defined in
+ * 08.18
+ *
+ * |-------------------------|
+ * | PDU Type |
+ * | TLLI |
+ * | Tag |
+ * | IMSI |
+ * | RA-Cap-Upd-Cause |
+ * | MS Radio Access Cap |
+ * | BVCI (prop. ext.) |
+ * |-------------------------|
+ *
+ * From GP-10 to GS
+ */
+BOOL
+bssgp_decode_radio_cap_update_ack(UINT8 *msg,UINT16 *msg_len, BOOL incoming)
+{
+ DBG_FUNC("bssgp_decode_radio_cap_update_ack",BSSGP_LAYER);
+ DBG_ENTER();
+ UINT8 *byte;
+ UINT16 index = 0;
+ BSSGP_API_MSG api_msg;
+ BSSGP_RADIO_CAP_UPDATE_ACK_MSG *radio_cap_update_ack;
+
+ byte = (UINT8*)&msg[index];
+
+ /* Check the PDU type */
+ if (*byte != BSSGP_PDU_RA_CAP_UPDATE_ACK) {
+ DBG_ERROR("PDU not RA-Cap-Update-Ack msg, type %s!",
+ bssgp_util_get_pdu_type_str((BSSGP_PDU_TYPE)*byte));
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+
+ /* Clean up an API msg so we have it handy */
+ memset(&api_msg,0,sizeof(api_msg));
+ api_msg.magic = BSSGP_MAGIC;
+ api_msg.msg_type = BSSGP_API_MSG_RADIO_CAP_UPDATE_ACK;
+ radio_cap_update_ack= (BSSGP_RADIO_CAP_UPDATE_ACK_MSG*)&api_msg.msg.radio_cap_update_ack;
+
+ /* Decode the individual IE indicators */
+ DBG_TRACE("Decoding Radio-Access-Capability-Update-Ack message");
+
+ /* tlli */
+ if (!bssgp_ie_decode_tlli(&radio_cap_update_ack->tlli,&msg[index],&index, BSSGP_FORMAT_TLV)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+
+ /* tag */
+ if (!bssgp_ie_decode_tag(&radio_cap_update_ack->tag,&msg[index],&index)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+
+
+ /* imsi */
+ if (msg[index] == BSSGP_IEI_IMSI)
+ {
+ if (!bssgp_ie_decode_imsi(&radio_cap_update_ack->imsi,&msg[index],&index)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+ }
+
+ /* RA-Cap-UPD-CAUSE */
+ if (!bssgp_ie_decode_ra_cap_update_cause(&radio_cap_update_ack->cause,&msg[index],&index)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+
+ if ((index < *msg_len) && (msg[index] == BSSGP_IEI_MS_RADIO_ACCESS_CAP))
+ {
+ if (!bssgp_ie_decode_ms_ra_cap(&radio_cap_update_ack->ra_cap,&msg[index],&index)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+ }
+
+ *msg_len -= index;
+ DBG_TRACE("Radio-Access-Capability-Update-Ack message %d bytes length",index);
+
+#if defined(MNET_GP10)
+ DBG_ERROR("BSSGP: Unexpected RA-CAPABILITY-UPDATE-ACK message\n");
+ DBG_LEAVE();
+ return (FALSE);
+#elif defined(MNET_GS)
+ if (!gmm_bssgp_msg_callback(api_msg)) {
+ DBG_ERROR("GMM reports error on Radio-Access-Capability-Update-Ack msg");
+ }
+ else {
+ DBG_TRACE("Posted Radio-Access-Capability-Update-Ack msg to GMM successfully");
+ }
+#endif
+
+ DBG_LEAVE();
+ return(TRUE);
+}
+
+
+
+
+/*
+ * bssgp_decode_flow_control_ms
+ */
+BOOL
+bssgp_decode_flow_control_ms(UINT8 *msg,UINT16 *msg_len, BOOL incoming)
+{
+ DBG_FUNC("bssgp_decode_flow_control_ms",BSSGP_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 index = 0;
+ BSSGP_API_MSG api_msg;
+ BSSGP_FLOW_CONTROL_MS_MSG *flow_control_msg;
+
+ byte = (UINT8*)&msg[index];
+ index++;
+
+ /* Check the PDU type */
+ if (*byte != BSSGP_PDU_FLOW_CONTROL_MS) {
+ DBG_ERROR("PDU not Flow control MS msg, type %s!",
+ bssgp_util_get_pdu_type_str((BSSGP_PDU_TYPE)*byte));
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ /* Clean up an API msg so we have it handy */
+ memset(&api_msg,0,sizeof(api_msg));
+ api_msg.magic = BSSGP_MAGIC;
+ api_msg.msg_type = BSSGP_API_MSG_FLOW_CONTROL_MS;
+ flow_control_msg = (BSSGP_FLOW_CONTROL_MS_MSG*)&api_msg.msg.flow_control_ms;
+
+
+ /* Decode the individual IE indicators */
+ DBG_TRACE("Decoding Flow control MS message");
+
+ /* tlli */
+ if (!bssgp_ie_decode_tlli(&flow_control_msg->tlli,&msg[index],&index, BSSGP_FORMAT_TLV)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+
+ /* tag */
+ if (!bssgp_ie_decode_tag(&flow_control_msg->tag,&msg[index],&index)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+
+ /* MS bucket size */
+ if (!bssgp_ie_decode_ms_bucket_size(&flow_control_msg->ms_bucket_size,&msg[index],&index)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+
+ /* Bucket leak rate */
+ if (!bssgp_ie_decode_bucket_leak_rate(&flow_control_msg->bucket_leak_rate,&msg[index],&index)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+
+ DBG_TRACE("Flow control MS message %d bytes length",index);
+
+ *msg_len -= index;
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+/*
+ * bssgp_decode_flow_control_ms_ack
+ */
+BOOL
+bssgp_decode_flow_control_ms_ack(UINT8 *msg,UINT16 *msg_len, BOOL incoming)
+{
+ DBG_FUNC("bssgp_decode_flow_control_ms_ack",BSSGP_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 index = 0;
+ BSSGP_API_MSG api_msg;
+ BSSGP_FLOW_CONTROL_MS_ACK_MSG *flow_control_ack_msg;
+
+ byte = (UINT8*)&msg[index];
+ index++;
+
+ /* Check the PDU type */
+ if (*byte != BSSGP_PDU_FLOW_CONTROL_MS_ACK) {
+ DBG_ERROR("PDU not Flow control MS msg, type %s!",
+ bssgp_util_get_pdu_type_str((BSSGP_PDU_TYPE)*byte));
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ /* Clean up an API msg so we have it handy */
+ memset(&api_msg,0,sizeof(api_msg));
+ api_msg.magic = BSSGP_MAGIC;
+ api_msg.msg_type = BSSGP_API_MSG_FLOW_CONTROL_MS_ACK;
+ flow_control_ack_msg = (BSSGP_FLOW_CONTROL_MS_ACK_MSG*)&api_msg.msg.flow_control_ms_ack;
+
+
+ /* Decode the individual IE indicators */
+ DBG_TRACE("Decoding Flow control MS Ack message");
+
+ /* tlli */
+ if (!bssgp_ie_decode_tlli(&flow_control_ack_msg->tlli,&msg[index],&index, BSSGP_FORMAT_TLV)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+
+ /* tag */
+ if (!bssgp_ie_decode_tag(&flow_control_ack_msg->tag,&msg[index],&index)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+
+ DBG_TRACE("Flow control MS Ack message %d bytes length",index);
+
+ *msg_len -= index;
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+/*
+ * bssgp_decode_flush_ll
+ */
+BOOL
+bssgp_decode_flush_ll(UINT8 *msg,UINT16 *msg_len, BOOL incoming)
+{
+ DBG_FUNC("bssgp_decode_flush_ll",BSSGP_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 index = 0;
+ BSSGP_API_MSG api_msg;
+ BSSGP_FLUSH_LL_MSG *flush_msg;
+
+ byte = (UINT8*)&msg[index];
+ index++;
+
+ /* Check the PDU type */
+ if (*byte != BSSGP_PDU_FLUSH_LL) {
+ DBG_ERROR("PDU not Flush LL msg, type %s!",
+ bssgp_util_get_pdu_type_str((BSSGP_PDU_TYPE)*byte));
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ /* Clean up an API msg so we have it handy */
+ memset(&api_msg,0,sizeof(api_msg));
+ api_msg.magic = BSSGP_MAGIC;
+ api_msg.msg_type = BSSGP_API_MSG_FLUSH_LL;
+ flush_msg = (BSSGP_FLUSH_LL_MSG*)&api_msg.msg.flush_ll;
+
+
+ /* Decode the individual IE indicators */
+ DBG_TRACE("Decoding Flush LL message");
+
+ /* tlli */
+ if (!bssgp_ie_decode_tlli(&flush_msg->tlli,&msg[index],&index, BSSGP_FORMAT_TLV)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+
+ /* bvci old */
+ if (!bssgp_ie_decode_bvci(&flush_msg->bvci_old,&msg[index],&index)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+
+ /* bvci new */
+ if (msg[index] == BSSGP_IEI_BVCI)
+ {
+ if (!bssgp_ie_decode_bvci(&flush_msg->bvci_new,&msg[index],&index)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+ }
+
+ DBG_TRACE("Flush LL message %d bytes length",index);
+
+ *msg_len -= index;
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+/*
+ * bssgp_decode_flush_ll_ack
+ */
+BOOL
+bssgp_decode_flush_ll_ack(UINT8 *msg,UINT16 *msg_len, BOOL incoming)
+{
+ DBG_FUNC("bssgp_decode_flush_ll_ack",BSSGP_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 index = 0;
+ BSSGP_API_MSG api_msg;
+ BSSGP_FLUSH_LL_ACK_MSG *flush_ack_msg;
+
+ byte = (UINT8*)&msg[index];
+ index++;
+
+ /* Check the PDU type */
+ if (*byte != BSSGP_PDU_FLUSH_LL_ACK) {
+ DBG_ERROR("PDU not Flush LL Ack msg, type %s!",
+ bssgp_util_get_pdu_type_str((BSSGP_PDU_TYPE)*byte));
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ /* Clean up an API msg so we have it handy */
+ memset(&api_msg,0,sizeof(api_msg));
+ api_msg.magic = BSSGP_MAGIC;
+ api_msg.msg_type = BSSGP_API_MSG_FLUSH_LL_ACK;
+ flush_ack_msg = (BSSGP_FLUSH_LL_ACK_MSG*)&api_msg.msg.flush_ll_ack;
+
+
+ /* Decode the individual IE indicators */
+ DBG_TRACE("Decoding Flush LL Ack message");
+
+ /* tlli */
+ if (!bssgp_ie_decode_tlli(&flush_ack_msg->tlli,&msg[index],&index, BSSGP_FORMAT_TLV)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+
+ /* Flush action */
+ if (!bssgp_ie_decode_flush_action(&flush_ack_msg->flush_action,&msg[index],&index)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+
+ /* bvci new */
+ if (msg[index] == BSSGP_IEI_BVCI)
+ {
+ if (!bssgp_ie_decode_bvci(&flush_ack_msg->bvci_new,&msg[index],&index)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+ }
+
+ /* Number of octets affected */
+ if (!bssgp_ie_decode_num_octets_affected(&flush_ack_msg->num_octets,&msg[index],&index)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+
+ DBG_TRACE("Flush LL Ack message %d bytes length",index);
+
+ *msg_len -= index;
+
+ DBG_LEAVE();
+ return (TRUE);
+
+}
+
+
+/*
+ * bssgp_decode_llc_discarded
+ */
+BOOL
+bssgp_decode_llc_discarded(UINT8 *msg,UINT16 *msg_len, BOOL incoming)
+{
+ DBG_FUNC("bssgp_decode_llc_discarded",BSSGP_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 index = 0;
+ BSSGP_API_MSG api_msg;
+ BSSGP_LLC_DISCARDED_MSG *llc_discarded_msg;
+
+ byte = (UINT8*)&msg[index];
+ index++;
+
+ /* Check the PDU type */
+ if (*byte != BSSGP_PDU_FLUSH_LL) {
+ DBG_ERROR("PDU not Flush LL msg, type %s!",
+ bssgp_util_get_pdu_type_str((BSSGP_PDU_TYPE)*byte));
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ /* Clean up an API msg so we have it handy */
+ memset(&api_msg,0,sizeof(api_msg));
+ api_msg.magic = BSSGP_MAGIC;
+ api_msg.msg_type = BSSGP_API_MSG_LLC_DISCARDED;
+ llc_discarded_msg = (BSSGP_LLC_DISCARDED_MSG*)&api_msg.msg.llc_discarded;
+
+
+ /* Decode the individual IE indicators */
+ DBG_TRACE("Decoding LLC Discarded message");
+
+ /* tlli */
+ if (!bssgp_ie_decode_tlli(&llc_discarded_msg->tlli,&msg[index],&index, BSSGP_FORMAT_TLV)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+
+ /* LLC Frames Discarded */
+ if (!bssgp_ie_decode_llc_frames_discarded(&llc_discarded_msg->num_frames,&msg[index],&index)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+
+ /* bvci */
+ if (!bssgp_ie_decode_bvci(&llc_discarded_msg->bvci,&msg[index],&index)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+
+ /* Number of octets affected */
+ if (!bssgp_ie_decode_num_octets_affected(&llc_discarded_msg->num_octets,&msg[index],&index)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+
+ DBG_TRACE("LLC Discarded message %d bytes length",index);
+
+ *msg_len -= index;
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+/*
+ * bssgp_decode_flow_control_bvc
+ */
+BOOL
+bssgp_decode_flow_control_bvc(UINT8 *msg,UINT16 *msg_len, BOOL incoming)
+{
+ DBG_FUNC("bssgp_decode_flow_control_bvc",BSSGP_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 index = 0;
+ BSSGP_API_MSG api_msg;
+ BSSGP_FLOW_CONTROL_BVC_MSG *flow_control_msg;
+
+ byte = (UINT8*)&msg[index];
+ index++;
+
+ /* Check the PDU type */
+ if (*byte != BSSGP_PDU_FLOW_CONTROL_BVC) {
+ DBG_ERROR("PDU not Flow control BVC msg, type %s!",
+ bssgp_util_get_pdu_type_str((BSSGP_PDU_TYPE)*byte));
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ /* Clean up an API msg so we have it handy */
+ memset(&api_msg,0,sizeof(api_msg));
+ api_msg.magic = BSSGP_MAGIC;
+ api_msg.msg_type = BSSGP_API_MSG_FLOW_CONTROL_BVC;
+ flow_control_msg = (BSSGP_FLOW_CONTROL_BVC_MSG*)&api_msg.msg.flow_control_bvc;
+
+
+ /* Decode the individual IE indicators */
+ DBG_TRACE("Decoding Flow control BVC message");
+
+ /* tag */
+ if (!bssgp_ie_decode_tag(&flow_control_msg->tag,&msg[index],&index)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+
+ /* BVC bucket size */
+ if (!bssgp_ie_decode_bvc_bucket_size(&flow_control_msg->bvc_bucket_size,&msg[index],&index)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+
+ /* Bucket leak rate */
+ if (!bssgp_ie_decode_bucket_leak_rate(&flow_control_msg->bucket_leak_rate,&msg[index],&index)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+
+ /* Bmax default MS */
+ if (!bssgp_ie_decode_bmax_def_ms(&flow_control_msg->bmax,&msg[index],&index)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+
+ /* R default MS */
+ if (!bssgp_ie_decode_r_def_ms(&flow_control_msg->r_default,&msg[index],&index)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+
+ /* BVC measurement */
+ if (msg[index] == BSSGP_IEI_BVC_MEASUREMENT)
+ {
+ if (!bssgp_ie_decode_bvc_measurement(&flow_control_msg->bvc_meas,&msg[index],&index)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+ }
+
+ DBG_TRACE("Flow control BVC message %d bytes length",index);
+
+ *msg_len -= index;
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+/*
+ * bssgp_decode_flow_control_bvc_ack
+ */
+BOOL
+bssgp_decode_flow_control_bvc_ack(UINT8 *msg,UINT16 *msg_len, BOOL incoming)
+{
+ DBG_FUNC("bssgp_decode_flow_control_bvc_ack",BSSGP_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 index = 0;
+ BSSGP_API_MSG api_msg;
+ BSSGP_FLOW_CONTROL_BVC_ACK_MSG *flow_control_ack_msg;
+
+ byte = (UINT8*)&msg[index];
+ index++;
+
+ /* Check the PDU type */
+ if (*byte != BSSGP_PDU_FLOW_CONTROL_BVC_ACK) {
+ DBG_ERROR("PDU not Flow control BVC Ack msg, type %s!",
+ bssgp_util_get_pdu_type_str((BSSGP_PDU_TYPE)*byte));
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ /* Clean up an API msg so we have it handy */
+ memset(&api_msg,0,sizeof(api_msg));
+ api_msg.magic = BSSGP_MAGIC;
+ api_msg.msg_type = BSSGP_API_MSG_FLOW_CONTROL_BVC_ACK;
+ flow_control_ack_msg = (BSSGP_FLOW_CONTROL_BVC_ACK_MSG*)&api_msg.msg.flow_control_bvc_ack;
+
+
+ /* Decode the individual IE indicators */
+ DBG_TRACE("Decoding Flow control BVC Ack message");
+
+ /* tag */
+ if (!bssgp_ie_decode_tag(&flow_control_ack_msg->tag,&msg[index],&index)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+
+ DBG_TRACE("Flow control BVC Ack message %d bytes length",index);
+
+ *msg_len -= index;
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+/*
+ * bssgp_decode_block
+ */
+BOOL
+bssgp_decode_block(UINT8 *msg,UINT16 *msg_len, BOOL incoming)
+{
+ DBG_FUNC("bssgp_decode_block",BSSGP_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 index = 0;
+ BSSGP_API_MSG api_msg;
+ BSSGP_BVC_BLOCK_MSG *block_msg;
+
+ byte = (UINT8*)&msg[index];
+ index++;
+
+ /* Check the PDU type */
+ if (*byte != BSSGP_PDU_BVC_BLOCK) {
+ DBG_ERROR("PDU not BVC block msg, type %s!",
+ bssgp_util_get_pdu_type_str((BSSGP_PDU_TYPE)*byte));
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ /* Clean up an API msg so we have it handy */
+ memset(&api_msg,0,sizeof(api_msg));
+ api_msg.magic = BSSGP_MAGIC;
+ api_msg.msg_type = BSSGP_API_MSG_BVC_BLOCK;
+ block_msg = (BSSGP_BVC_BLOCK_MSG*)&api_msg.msg.bvc_block;
+
+
+ /* Decode the individual IE indicators */
+ DBG_TRACE("Decoding BVC block message");
+
+ /* bvci */
+ if (!bssgp_ie_decode_bvci(&block_msg->bvci,&msg[index],&index)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+
+ /* cause */
+ if (!bssgp_ie_decode_exception_cause(&block_msg->cause,&msg[index],&index)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+
+ DBG_TRACE("BVC block message %d bytes length",index);
+
+ *msg_len -= index;
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+/*
+ * bssgp_decode_block_ack
+ */
+BOOL
+bssgp_decode_block_ack(UINT8 *msg,UINT16 *msg_len, BOOL incoming)
+{
+ DBG_FUNC("bssgp_decode_block_ack",BSSGP_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 index = 0;
+ BSSGP_API_MSG api_msg;
+ BSSGP_BVC_BLOCK_ACK_MSG *block_ack_msg;
+
+ byte = (UINT8*)&msg[index];
+ index++;
+
+ /* Check the PDU type */
+ if (*byte != BSSGP_PDU_BVC_BLOCK_ACK) {
+ DBG_ERROR("PDU not BVC block msg, type %s!",
+ bssgp_util_get_pdu_type_str((BSSGP_PDU_TYPE)*byte));
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ /* Clean up an API msg so we have it handy */
+ memset(&api_msg,0,sizeof(api_msg));
+ api_msg.magic = BSSGP_MAGIC;
+ api_msg.msg_type = BSSGP_API_MSG_BVC_BLOCK_ACK;
+ block_ack_msg = (BSSGP_BVC_BLOCK_ACK_MSG*)&api_msg.msg.bvc_block_ack;
+
+
+ /* Decode the individual IE indicators */
+ DBG_TRACE("Decoding BVC block ack message");
+
+ /* bvci */
+ if (!bssgp_ie_decode_bvci(&block_ack_msg->bvci,&msg[index],&index)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+
+ DBG_TRACE("BVC block ack message %d bytes length",index);
+
+ *msg_len -= index;
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+/*
+ * bssgp_decode_unblock
+ */
+BOOL
+bssgp_decode_unblock(UINT8 *msg,UINT16 *msg_len, BOOL incoming)
+{
+ DBG_FUNC("bssgp_decode_unblock",BSSGP_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 index = 0;
+ BSSGP_API_MSG api_msg;
+ BSSGP_BVC_UNBLOCK_MSG *unblock_msg;
+
+ byte = (UINT8*)&msg[index];
+ index++;
+
+ /* Check the PDU type */
+ if (*byte != BSSGP_PDU_UNBLOCK) {
+ DBG_ERROR("PDU not BVC unblock msg, type %s!",
+ bssgp_util_get_pdu_type_str((BSSGP_PDU_TYPE)*byte));
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ /* Clean up an API msg so we have it handy */
+ memset(&api_msg,0,sizeof(api_msg));
+ api_msg.magic = BSSGP_MAGIC;
+ api_msg.msg_type = BSSGP_API_MSG_BVC_UNBLOCK;
+ unblock_msg = (BSSGP_BVC_UNBLOCK_MSG*)&api_msg.msg.bvc_unblock;
+
+
+ /* Decode the individual IE indicators */
+ DBG_TRACE("Decoding BVC unblock message");
+
+ /* bvci */
+ if (!bssgp_ie_decode_bvci(&unblock_msg->bvci,&msg[index],&index)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+
+ DBG_TRACE("BVC unblock message %d bytes length",index);
+
+ *msg_len -= index;
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+/*
+ * bssgp_decode_unblock_ack
+ */
+BOOL
+bssgp_decode_unblock_ack(UINT8 *msg,UINT16 *msg_len, BOOL incoming)
+{
+ DBG_FUNC("bssgp_decode_unblock_ack",BSSGP_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 index = 0;
+ BSSGP_API_MSG api_msg;
+ BSSGP_BVC_UNBLOCK_ACK_MSG *unblock_ack_msg;
+
+ byte = (UINT8*)&msg[index];
+ index++;
+
+ /* Check the PDU type */
+ if (*byte != BSSGP_PDU_UNBLOCK_ACK) {
+ DBG_ERROR("PDU not BVC unblock msg, type %s!",
+ bssgp_util_get_pdu_type_str((BSSGP_PDU_TYPE)*byte));
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ /* Clean up an API msg so we have it handy */
+ memset(&api_msg,0,sizeof(api_msg));
+ api_msg.magic = BSSGP_MAGIC;
+ api_msg.msg_type = BSSGP_API_MSG_BVC_UNBLOCK_ACK;
+ unblock_ack_msg = (BSSGP_BVC_UNBLOCK_ACK_MSG*)&api_msg.msg.bvc_unblock_ack;
+
+
+ /* Decode the individual IE indicators */
+ DBG_TRACE("Decoding BVC unblock ack message");
+
+ /* bvci */
+ if (!bssgp_ie_decode_bvci(&unblock_ack_msg->bvci,&msg[index],&index)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+
+ DBG_TRACE("BVC unblock ack message %d bytes length",index);
+
+ *msg_len -= index;
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+/*
+ * bssgp_decode_reset
+ */
+BOOL
+bssgp_decode_reset(UINT8 *msg,UINT16 *msg_len, BOOL incoming)
+{
+ DBG_FUNC("bssgp_decode_reset",BSSGP_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 index = 0;
+ BSSGP_API_MSG api_msg;
+ BSSGP_BVC_RESET_MSG *reset_msg;
+
+ byte = (UINT8*)&msg[index];
+ index++;
+
+ /* Check the PDU type */
+ if (*byte != BSSGP_PDU_RESET) {
+ DBG_ERROR("PDU not BVC reset msg, type %s!",
+ bssgp_util_get_pdu_type_str((BSSGP_PDU_TYPE)*byte));
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ /* Clean up an API msg so we have it handy */
+ memset(&api_msg,0,sizeof(api_msg));
+ api_msg.magic = BSSGP_MAGIC;
+ api_msg.msg_type = BSSGP_API_MSG_BVC_RESET;
+ reset_msg = (BSSGP_BVC_RESET_MSG*)&api_msg.msg.bvc_reset;
+
+
+ /* Decode the individual IE indicators */
+ DBG_TRACE("Decoding BVC reset message");
+
+ /* bvci */
+ if (!bssgp_ie_decode_bvci(&reset_msg->bvci,&msg[index],&index)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+
+ /* cause */
+ if (!bssgp_ie_decode_exception_cause(&reset_msg->cause,&msg[index],&index)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+
+ /* Cell identifier */
+ if (msg[index] == BSSGP_IEI_CELL_ID)
+ {
+ if (!bssgp_ie_decode_cell_id(&reset_msg->cell_id,&msg[index],&index)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+ }
+
+ DBG_TRACE("BVC reset message %d bytes length",index);
+
+ *msg_len -= index;
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+/*
+ * bssgp_decode_reset_ack
+ */
+BOOL
+bssgp_decode_reset_ack(UINT8 *msg,UINT16 *msg_len, BOOL incoming)
+{
+ DBG_FUNC("bssgp_decode_reset_ack",BSSGP_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 index = 0;
+ BSSGP_API_MSG api_msg;
+ BSSGP_BVC_RESET_ACK_MSG *reset_ack_msg;
+
+ byte = (UINT8*)&msg[index];
+ index++;
+
+ /* Check the PDU type */
+ if (*byte != BSSGP_PDU_RESET_ACK) {
+ DBG_ERROR("PDU not BVC reset ack msg, type %s!",
+ bssgp_util_get_pdu_type_str((BSSGP_PDU_TYPE)*byte));
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ /* Clean up an API msg so we have it handy */
+ memset(&api_msg,0,sizeof(api_msg));
+ api_msg.magic = BSSGP_MAGIC;
+ api_msg.msg_type = BSSGP_API_MSG_BVC_RESET_ACK;
+ reset_ack_msg = (BSSGP_BVC_RESET_ACK_MSG*)&api_msg.msg.bvc_reset_ack;
+
+
+ /* Decode the individual IE indicators */
+ DBG_TRACE("Decoding BVC reset ack message");
+
+ /* bvci */
+ if (!bssgp_ie_decode_bvci(&reset_ack_msg->bvci,&msg[index],&index)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+
+ /* Cell identifier */
+ if (msg[index] == BSSGP_IEI_CELL_ID)
+ {
+ if (!bssgp_ie_decode_cell_id(&reset_ack_msg->cell_id,&msg[index],&index)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+ }
+
+ DBG_TRACE("BVC reset ack message %d bytes length",index);
+
+ *msg_len -= index;
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+/*
+ * bssgp_decode_status
+ */
+BOOL
+bssgp_decode_status(UINT8 *msg,UINT16 *msg_len, BOOL incoming)
+{
+ DBG_FUNC("bssgp_decode_status",BSSGP_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 index = 0;
+ BSSGP_API_MSG api_msg;
+ BSSGP_BVC_STATUS_MSG *status_msg;
+
+ byte = (UINT8*)&msg[index];
+ index++;
+
+ /* Check the PDU type */
+ if (*byte != BSSGP_PDU_STATUS) {
+ DBG_ERROR("PDU not BVC status msg, type %s!",
+ bssgp_util_get_pdu_type_str((BSSGP_PDU_TYPE)*byte));
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ /* Clean up an API msg so we have it handy */
+ memset(&api_msg,0,sizeof(api_msg));
+ api_msg.magic = BSSGP_MAGIC;
+ api_msg.msg_type = BSSGP_API_MSG_STATUS;
+ status_msg = (BSSGP_BVC_STATUS_MSG*)&api_msg.msg.bvc_reset_ack;
+
+
+ /* Decode the individual IE indicators */
+ DBG_TRACE("Decoding BVC status message");
+
+ /* cause */
+ if (!bssgp_ie_decode_exception_cause(&status_msg->cause,&msg[index],&index)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+
+ /* bvci */
+ if (msg[index] == BSSGP_IEI_BVCI)
+ {
+ if (!bssgp_ie_decode_bvci(&status_msg->bvci,&msg[index],&index)) {
+ /* TODO : Report error to peer BSSGP here */
+ }
+ }
+
+ DBG_TRACE("BVC status message %d bytes length",index);
+
+ *msg_len -= index;
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
diff --git a/data/mnet/Common/bssgp/src/bssgp_encoder.cpp b/data/mnet/Common/bssgp/src/bssgp_encoder.cpp
new file mode 100644
index 0000000..9138b95
--- /dev/null
+++ b/data/mnet/Common/bssgp/src/bssgp_encoder.cpp
@@ -0,0 +1,1814 @@
+/*
+ ****************************************************************************************
+ * *
+ * Copyright Cisco Systems, Inc 2000 All rights reserved *
+ * *
+ * File : bssgp_encoder.cpp *
+ * *
+ * Description : Encoding functions for the BSS-GP layer module *
+ * *
+ * Author : Dinesh Nambisan *
+ * *
+ *--------------------------- Notes ----------------------------------------------------*
+ * References are to sections numbers of the BSSGP spec. (GSM 08.18) unless otherwise *
+ * indicated *
+ *----------------------- Revision history ---------------------------------------------*
+ * Time | Date | Name | Description *
+ *--------------------------------------------------------------------------------------*
+ * 00:00 |10/10/00 | DSN | File created *
+ * | | | *
+ ****************************************************************************************
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include "bssgp/bssgp_prot.h"
+#include "bssgp/bssgp_util.h"
+#include "bssgp/bssgp_api.h"
+#include "bssgp/bssgp_encoder.h"
+#include "bssgp/bssgp_ie_encoder.h"
+
+extern BSSGP_CONFIGURATION bssgp_config;
+
+/*
+ * bssgp_encode_msg
+ *
+ */
+BOOL
+bssgp_encode_msg(BSSGP_API_MSG *api_msg,UINT8 *msg,UINT16 *msg_len,
+ BSSGP_NETWORK_QOS_LEVEL *qos_reqd, BOOL *tx_msg)
+{
+ DBG_FUNC("bssgp_encode_msg",BSSGP_LAYER);
+ DBG_ENTER();
+ BOOL status = FALSE;
+
+ switch(api_msg->msg_type) {
+ /* Downlink Unitdata */
+ case BSSGP_API_MSG_DL_UNITDATA:{
+ status = bssgp_encode_dl_unitdata(api_msg->msg.dl_unitdata,msg,msg_len,qos_reqd,
+ tx_msg);
+ }
+ break;
+ case BSSGP_API_MSG_UL_UNITDATA:{
+ status = bssgp_encode_ul_unitdata(api_msg->msg.ul_unitdata,msg,msg_len,qos_reqd,tx_msg);
+ }
+ break;
+ case BSSGP_API_MSG_PAGING_PS:{
+ status = bssgp_encode_paging_ps(api_msg->msg.paging_ps,msg,msg_len);
+ *qos_reqd = BSSGP_NETWORK_QOS_LEVEL_1;
+ *tx_msg = TRUE;
+ }
+ break;
+ case BSSGP_API_MSG_RADIO_STATUS:{
+ status = bssgp_encode_radio_status(api_msg->msg.radio_status,msg,msg_len);
+ *qos_reqd = BSSGP_NETWORK_QOS_LEVEL_1;
+ *tx_msg = TRUE;
+ }
+ break;
+ case BSSGP_API_MSG_SUSPEND:{
+ status = bssgp_encode_suspend(api_msg->msg.suspend,msg,msg_len);
+ *qos_reqd = BSSGP_NETWORK_QOS_LEVEL_1;
+ *tx_msg = TRUE;
+ }
+ break;
+ case BSSGP_API_MSG_SUSPEND_ACK:{
+ status = bssgp_encode_suspend_ack(api_msg->msg.suspend_ack,msg,msg_len);
+ *qos_reqd = BSSGP_NETWORK_QOS_LEVEL_1;
+ *tx_msg = TRUE;
+ }
+ break;
+ case BSSGP_API_MSG_SUSPEND_NACK:{
+ status = bssgp_encode_suspend_nack(api_msg->msg.suspend_nack,msg,msg_len);
+ *qos_reqd = BSSGP_NETWORK_QOS_LEVEL_1;
+ *tx_msg = TRUE;
+ }
+ break;
+ case BSSGP_API_MSG_RESUME:{
+ status = bssgp_encode_resume(api_msg->msg.resume,msg,msg_len);
+ *qos_reqd = BSSGP_NETWORK_QOS_LEVEL_1;
+ *tx_msg = TRUE;
+ }
+ break;
+ case BSSGP_API_MSG_RESUME_ACK:{
+ status = bssgp_encode_resume_ack(api_msg->msg.resume_ack,msg,msg_len);
+ *qos_reqd = BSSGP_NETWORK_QOS_LEVEL_1;
+ *tx_msg = TRUE;
+ }
+ break;
+ case BSSGP_API_MSG_RESUME_NACK:{
+ status = bssgp_encode_resume_nack(api_msg->msg.resume_nack,msg,msg_len);
+ *qos_reqd = BSSGP_NETWORK_QOS_LEVEL_1;
+ *tx_msg = TRUE;
+ }
+ break;
+ case BSSGP_API_MSG_LOCATION_UPDATE:{
+ status = bssgp_encode_location_update(api_msg->msg.location_update,msg,msg_len);
+ *qos_reqd = BSSGP_NETWORK_QOS_LEVEL_1;
+ *tx_msg = TRUE;
+ }
+ break;
+ case BSSGP_API_MSG_LOCATION_UPDATE_ACK:{
+ status = bssgp_encode_location_update_ack(api_msg->msg.location_update_ack,msg,msg_len);
+ *qos_reqd = BSSGP_NETWORK_QOS_LEVEL_1;
+ *tx_msg = TRUE;
+ }
+ break;
+ case BSSGP_API_MSG_LOCATION_UPDATE_NACK:{
+ status = bssgp_encode_location_update_nack(api_msg->msg.location_update_nack,msg,msg_len);
+ *qos_reqd = BSSGP_NETWORK_QOS_LEVEL_1;
+ *tx_msg = TRUE;
+ }
+ break;
+ case BSSGP_API_MSG_RADIO_CAP:{
+ status = bssgp_encode_radio_cap(api_msg->msg.radio_cap,msg,msg_len);
+ *qos_reqd = BSSGP_NETWORK_QOS_LEVEL_1;
+ *tx_msg = TRUE;
+ }
+ break;
+ case BSSGP_API_MSG_RADIO_CAP_UPDATE:{
+ status = bssgp_encode_radio_cap_update(api_msg->msg.radio_cap_update,msg,msg_len);
+ *qos_reqd = BSSGP_NETWORK_QOS_LEVEL_1;
+ *tx_msg = TRUE;
+ }
+ break;
+ case BSSGP_API_MSG_RADIO_CAP_UPDATE_ACK:{
+ status = bssgp_encode_radio_cap_update_ack(api_msg->msg.radio_cap_update_ack,msg,msg_len);
+ *qos_reqd = BSSGP_NETWORK_QOS_LEVEL_1;
+ *tx_msg = TRUE;
+ }
+ break;
+ case BSSGP_PDU_BVC_BLOCK:{
+ status = bssgp_encode_bvc_block(api_msg->msg.bvc_block,msg,msg_len);
+ *qos_reqd = BSSGP_NETWORK_QOS_LEVEL_1;
+ *tx_msg = TRUE;
+ }
+ break;
+ case BSSGP_PDU_BVC_BLOCK_ACK:{
+ status = bssgp_encode_bvc_block_ack(api_msg->msg.bvc_block_ack,msg,msg_len);
+ *qos_reqd = BSSGP_NETWORK_QOS_LEVEL_1;
+ *tx_msg = TRUE;
+ }
+ break;
+ case BSSGP_PDU_RESET:{
+ status = bssgp_encode_bvc_reset(api_msg->msg.bvc_reset,msg,msg_len);
+ *qos_reqd = BSSGP_NETWORK_QOS_LEVEL_1;
+ *tx_msg = TRUE;
+ }
+ break;
+ case BSSGP_PDU_RESET_ACK:{
+ status = bssgp_encode_bvc_reset_ack(api_msg->msg.bvc_reset_ack,msg,msg_len);
+ *qos_reqd = BSSGP_NETWORK_QOS_LEVEL_1;
+ *tx_msg = TRUE;
+ }
+ break;
+ case BSSGP_PDU_UNBLOCK:{
+ status = bssgp_encode_bvc_unblock(api_msg->msg.bvc_unblock,msg,msg_len);
+ *qos_reqd = BSSGP_NETWORK_QOS_LEVEL_1;
+ *tx_msg = TRUE;
+ }
+ break;
+ case BSSGP_PDU_UNBLOCK_ACK:{
+ status = bssgp_encode_bvc_unblock_ack(api_msg->msg.bvc_unblock_ack,msg,msg_len);
+ *qos_reqd = BSSGP_NETWORK_QOS_LEVEL_1;
+ *tx_msg = TRUE;
+ }
+ break;
+ case BSSGP_PDU_FLOW_CONTROL_BVC:{
+ status = bssgp_encode_flow_control_bvc(api_msg->msg.flow_control_bvc,msg,msg_len);
+ *qos_reqd = BSSGP_NETWORK_QOS_LEVEL_1;
+ *tx_msg = TRUE;
+ }
+ break;
+ case BSSGP_PDU_FLOW_CONTROL_BVC_ACK:{
+ status = bssgp_encode_flow_control_bvc_ack(api_msg->msg.flow_control_bvc_ack,msg,msg_len);
+ *qos_reqd = BSSGP_NETWORK_QOS_LEVEL_1;
+ *tx_msg = TRUE;
+ }
+ break;
+ case BSSGP_PDU_FLOW_CONTROL_MS:{
+ status = bssgp_encode_flow_control_ms(api_msg->msg.flow_control_ms,msg,msg_len);
+ *qos_reqd = BSSGP_NETWORK_QOS_LEVEL_1;
+ *tx_msg = TRUE;
+ }
+ break;
+ case BSSGP_PDU_FLOW_CONTROL_MS_ACK:{
+ status = bssgp_encode_flow_control_ms_ack(api_msg->msg.flow_control_ms_ack,msg,msg_len);
+ *qos_reqd = BSSGP_NETWORK_QOS_LEVEL_1;
+ *tx_msg = TRUE;
+ }
+ break;
+ case BSSGP_PDU_FLUSH_LL:{
+ status = bssgp_encode_flush_ll(api_msg->msg.flush_ll,msg,msg_len);
+ *qos_reqd = BSSGP_NETWORK_QOS_LEVEL_1;
+ *tx_msg = TRUE;
+ }
+ break;
+ case BSSGP_PDU_FLUSH_LL_ACK:{
+ status = bssgp_encode_flush_ll_ack(api_msg->msg.flush_ll_ack,msg,msg_len);
+ *qos_reqd = BSSGP_NETWORK_QOS_LEVEL_1;
+ *tx_msg = TRUE;
+ }
+ break;
+ case BSSGP_PDU_LLC_DISCARDED:{
+ status = bssgp_encode_llc_discarded(api_msg->msg.llc_discarded,msg,msg_len);
+ *qos_reqd = BSSGP_NETWORK_QOS_LEVEL_1;
+ *tx_msg = TRUE;
+ }
+ break;
+ case BSSGP_PDU_STATUS:{
+ status = bssgp_encode_bvc_status(api_msg->msg.bvc_status,msg,msg_len);
+ *qos_reqd = BSSGP_NETWORK_QOS_LEVEL_1;
+ *tx_msg = TRUE;
+ }
+ break;
+
+ default:{
+ DBG_WARNING("BSSGP: No encoder for msg type %#x\n",api_msg->msg_type);
+ DBG_LEAVE();
+ return (FALSE);
+ }
+ break;
+ }
+
+ DBG_LEAVE();
+ return (status);
+}
+
+
+
+
+
+/*
+ * bssgp_encode_dl_unitdata
+ */
+BOOL
+bssgp_encode_dl_unitdata(BSSGP_DL_UNITDATA_MSG dl_unitdata_msg ,UINT8 *msg,
+ UINT16 *len, BSSGP_NETWORK_QOS_LEVEL *qos_reqd, BOOL *tx_msg)
+{
+ DBG_FUNC("bssgp_encode_dl_unitdata",BSSGP_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 index = 0;
+
+ byte = (UINT8*)&msg[index];
+
+ /* Set the PDU type */
+ *byte = (UINT8)BSSGP_PDU_DL_UNITDATA;
+
+ index++;
+
+ DBG_TRACE("Encoding DL-Unitdata message");
+
+ /* Encode the individual IE indicators */
+ /* tlli */
+ if (dl_unitdata_msg.tlli.ie_present) {
+ bssgp_ie_encode_tlli(dl_unitdata_msg.tlli,&msg[index],&index, BSSGP_FORMAT_V);
+ }
+ else
+ {
+ DBG_ERROR("BSSGP: TLLI(current) is manadatory in DL-UNITDATA\n");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ if (dl_unitdata_msg.qos_profile.ie_present) {
+ bssgp_ie_encode_qos_profile(dl_unitdata_msg.qos_profile,&msg[index],&index, BSSGP_FORMAT_V);
+ }
+ else
+ {
+ DBG_ERROR("BSSGP: QOS Profile is manadatory in DL-UNITDATA\n");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ if (dl_unitdata_msg.qos_params.ie_present) {
+ bssgp_ie_encode_qos_params(dl_unitdata_msg.qos_params,&msg[index],&index);
+ }
+ else
+ {
+ DBG_ERROR("BSSGP: QOS Params is manadatory in DL-UNITDATA\n");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ if (dl_unitdata_msg.pdu_lifetime.ie_present) {
+ bssgp_ie_encode_pdu_lifetime(dl_unitdata_msg.pdu_lifetime,&msg[index],&index);
+ }
+ else
+ {
+ DBG_ERROR("BSSGP: PDU Lifetim is manadatory in DL-UNITDATA\n");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ if (dl_unitdata_msg.radio_access_cap.ie_present) {
+ bssgp_ie_encode_ms_ra_cap(dl_unitdata_msg.radio_access_cap,&msg[index],&index);
+ }
+
+ if (dl_unitdata_msg.priority.ie_present) {
+ bssgp_ie_encode_priority(dl_unitdata_msg.priority,&msg[index],&index);
+ }
+
+ if (dl_unitdata_msg.drx_params.ie_present) {
+ bssgp_ie_encode_drx_params(dl_unitdata_msg.drx_params,&msg[index],&index);
+ }
+
+ if (dl_unitdata_msg.imsi.ie_present) {
+ bssgp_ie_encode_imsi(dl_unitdata_msg.imsi,&msg[index],&index);
+ }
+
+ if (dl_unitdata_msg.tlli_old.ie_present) {
+ bssgp_ie_encode_tlli(dl_unitdata_msg.tlli_old,&msg[index],&index, BSSGP_FORMAT_TLV);
+ }
+
+ if (dl_unitdata_msg.lsa_info.ie_present) {
+ /* align on a 4 byte boundary */
+ if (index % 4)
+ {
+ bssgp_ie_encode_alignment_octets(4 - (index % 4),&msg[index],&index);
+ }
+ bssgp_ie_encode_lsa_info(dl_unitdata_msg.lsa_info,&msg[index],&index);
+ }
+
+ bssgp_ie_encode_llc_pdu((UINT8*)dl_unitdata_msg.pdu.data,dl_unitdata_msg.pdu.data_len,&msg[index],&index);
+ bssgp_util_return_rx_buff((char*)dl_unitdata_msg.pdu.data);
+
+ if (dl_unitdata_msg.qos_profile.t_bit == SDU_CONTAINS_SIGNALLING) {
+ *qos_reqd = BSSGP_NETWORK_QOS_LEVEL_1;
+ }
+ else {
+ *qos_reqd = (BSSGP_NETWORK_QOS_LEVEL)dl_unitdata_msg.qos_profile.precedence_class;
+ }
+
+ *len += index;
+
+ /* FIXME : Check here if the Qs for this TLLI is backed up, otherwise out it goes */
+ *tx_msg = TRUE;
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+/*
+ * bssgp_encode_ul_unitdata
+ */
+BOOL
+bssgp_encode_ul_unitdata(BSSGP_UL_UNITDATA_MSG ul_unitdata_msg,UINT8 *msg,UINT16 *len,
+ BSSGP_NETWORK_QOS_LEVEL *qos_reqd, BOOL *tx_msg)
+{
+ DBG_FUNC("bssgp_encode_ul_unitdata",BSSGP_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 index = 0;
+
+ byte = (UINT8*)&msg[index];
+
+ /* Set the PDU type */
+ *byte = (UINT8)BSSGP_PDU_UL_UNITDATA;
+
+ index++;
+
+ DBG_TRACE("Encoding UL-Unitdata message");
+
+ /* Encode the individual IE indicators */
+ if (ul_unitdata_msg.tlli.ie_present) {
+ bssgp_ie_encode_tlli(ul_unitdata_msg.tlli,&msg[index],&index, BSSGP_FORMAT_V);
+ }
+ else
+ {
+ DBG_ERROR("BSSGP: TLLI is manadatory in UL-UNITDATA\n");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ if (ul_unitdata_msg.qos_profile.ie_present) {
+ bssgp_ie_encode_qos_profile(ul_unitdata_msg.qos_profile,&msg[index],&index, BSSGP_FORMAT_V);
+ }
+ else
+ {
+ DBG_ERROR("BSSGP: QOS Profile is manadatory in UL-UNITDATA\n");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+#if defined(MNET_GP10)
+ ul_unitdata_msg.cell_id.cell_id = bssgp_config.cell_id;
+ ul_unitdata_msg.cell_id.routing_area = bssgp_config.routing_area_id;
+ ul_unitdata_msg.cell_id.ie_present = TRUE;
+#endif
+ if (ul_unitdata_msg.cell_id.ie_present) {
+ bssgp_ie_encode_cell_id(ul_unitdata_msg.cell_id,&msg[index],&index);
+ }
+ else
+ {
+ DBG_ERROR("BSSGP: Cell Identifier is manadatory in UL-UNITDATA\n");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ if (ul_unitdata_msg.lsa_id_list.ie_present) {
+ /* align on a 4 byte boundary */
+ if (index % 4)
+ {
+ bssgp_ie_encode_alignment_octets(4 - (index % 4),&msg[index],&index);
+ }
+ bssgp_ie_encode_lsa_identifier_list(ul_unitdata_msg.lsa_id_list,&msg[index],&index);
+ }
+
+ bssgp_ie_encode_llc_pdu((UINT8*)ul_unitdata_msg.pdu.data,ul_unitdata_msg.pdu.data_len,&msg[index],&index);
+
+ /* Indicate the QoS level */
+ *qos_reqd = (BSSGP_NETWORK_QOS_LEVEL)ul_unitdata_msg.qos_profile.precedence_class;
+
+
+ /* For Uplink we dont need to Q anything */
+ *tx_msg = TRUE;
+
+ *len += index;
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+/*
+ * bssgp_encode_paging
+ *
+ * Paging PDU defined in 08.18:-
+ *
+ * |-------------------------|
+ * | PDU Type |
+ * | IMSI |
+ * | DRX Params |
+ * | BVCI |
+ * | Location Area |
+ * | Routing Area |
+ * | BSS Area Indication |
+ * | QoS Profile |
+ * | P-TMSI |
+ * |-------------------------|
+ *
+ * From GS --> GP-10
+ */
+BOOL
+bssgp_encode_paging_ps(BSSGP_PAGING_PS_MSG paging_msg ,UINT8 *msg,UINT16 *msg_len)
+{
+ DBG_FUNC("bssgp_encode_paging_ps",BSSGP_LAYER);
+ DBG_ENTER();
+ UINT8 *byte;
+ UINT16 index = 0;
+
+ byte = (UINT8*)&msg[index];
+
+ /* Set the PDU type */
+ *byte = (UINT8)BSSGP_PDU_PAGING_PS;
+
+ index++;
+
+ DBG_TRACE("Encoding Packet-Switched Paging message");
+
+ /* Encode the individual IE indicators */
+ /* imsi */
+ if (paging_msg.imsi.ie_present) {
+ bssgp_ie_encode_imsi(paging_msg.imsi,&msg[index],&index);
+ }
+ else {
+ DBG_ERROR("Mandatory element IMSI not specified for paging-ps msg!");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ /* drx params */
+ if (paging_msg.drx_params.ie_present)
+ bssgp_ie_encode_drx_params(paging_msg.drx_params,&msg[index],&index);
+
+ /* bvci */
+ if (paging_msg.bvci.ie_present)
+ bssgp_ie_encode_bvci(paging_msg.bvci,&msg[index],&index);
+
+ /* location area */
+ if (paging_msg.location_area.ie_present)
+ bssgp_ie_encode_location_area(paging_msg.location_area,&msg[index],&index);
+
+ /* routing area */
+ if (paging_msg.routing_area.ie_present)
+ bssgp_ie_encode_routing_area(paging_msg.routing_area,&msg[index],&index);
+
+ /* bss area indication */
+ if (paging_msg.bss_area.ie_present)
+ bssgp_ie_encode_bss_area_ind(paging_msg.bss_area,&msg[index],&index);
+
+ /* qos profile */
+ if (paging_msg.qos_profile.ie_present)
+ {
+ bssgp_ie_encode_qos_profile(paging_msg.qos_profile,&msg[index],&index, BSSGP_FORMAT_TLV);
+ }
+ else
+ {
+ DBG_ERROR("BSSGP: QOS Profile is manadatory in PAGING PS\n");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ /* tmsi */
+ if (paging_msg.tmsi.ie_present)
+ bssgp_ie_encode_tmsi(paging_msg.tmsi,&msg[index],&index);
+
+
+ *msg_len += index;
+ DBG_TRACE("Paging-PS message %d bytes length",index);
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+
+
+/*
+ * bssgp_encode_radio_status
+ *
+ * Radio Status PDU defined in 08.18:-
+ *
+ * |--------------|
+ * | PDU type |
+ * | TLLI |
+ * | TMSI |
+ * | IMSI |
+ * | Radio Cause |
+ * |--------------|
+ *
+ * From GP-10 to GS
+ */
+BOOL
+bssgp_encode_radio_status(BSSGP_RADIO_STATUS_MSG radio_status_msg ,UINT8 *msg,UINT16 *msg_len)
+{
+ DBG_FUNC("bssgp_encode_radio_status",BSSGP_LAYER);
+ DBG_ENTER();
+ UINT8 *byte;
+ UINT16 index = 0;
+
+ byte = (UINT8*)&msg[index];
+
+ /* Set the PDU type */
+ *byte = (UINT8)BSSGP_PDU_RADIO_STATUS;
+
+ index++;
+
+ DBG_TRACE("Encoding Radio Status message");
+
+ /* Encode the individual IE indicators */
+ /* tlli */
+ if (radio_status_msg.tlli.ie_present)
+ bssgp_ie_encode_tlli(radio_status_msg.tlli,&msg[index],&index, BSSGP_FORMAT_TLV);
+ /* tmsi */
+ if (radio_status_msg.tmsi.ie_present)
+ bssgp_ie_encode_tmsi(radio_status_msg.tmsi,&msg[index],&index);
+ /* imsi */
+ if (radio_status_msg.imsi.ie_present)
+ bssgp_ie_encode_imsi(radio_status_msg.imsi,&msg[index],&index);
+ /* cause */
+ bssgp_ie_encode_radio_cause(radio_status_msg.cause,&msg[index],&index);
+
+ *msg_len += index;
+
+ DBG_TRACE("Radio Status message %d bytes length",index);
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+/*
+ * bssgp_encode_suspend
+ *
+ * Suspend PDU defined in 08.18:-
+ *
+ * |-------------------------|
+ * | PDU Type |
+ * | TLLI |
+ * | Routing Area |
+ * |-------------------------|
+ *
+ * From GP-10 to GS
+ */
+BOOL
+bssgp_encode_suspend(BSSGP_SUSPEND_MSG suspend_msg,UINT8 *msg,UINT16 *msg_len)
+{
+ DBG_FUNC("bssgp_encode_suspend",BSSGP_LAYER);
+ DBG_ENTER();
+ UINT8 *byte;
+ UINT16 index = 0;
+
+ byte = (UINT8*)&msg[index];
+
+ /* Set the PDU type */
+ *byte = (UINT8)BSSGP_PDU_SUSPEND;
+
+ index++;
+
+ DBG_TRACE("Encoding Suspend message");
+
+ /* Encode the individual IE indicators */
+ /* tlli */
+ bssgp_ie_encode_tlli(suspend_msg.tlli,&msg[index],&index, BSSGP_FORMAT_TLV);
+ /* routing area */
+ bssgp_ie_encode_routing_area(suspend_msg.routing_area,&msg[index],&index);
+
+ *msg_len = index;
+
+ DBG_TRACE("Suspend message %d bytes length",index);
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+/*
+ * bssgp_encode_suspend_ack
+ *
+ * Suspend Ack PDU defined in 08.18:-
+ *
+ * |-------------------------|
+ * | PDU Type |
+ * | TLLI |
+ * | Routing Area |
+ * | Suspend Ref Num. |
+ * | BVCI (prop. ext.) |
+ * |-------------------------|
+ *
+ * From GS --> GP-10
+ */
+BOOL
+bssgp_encode_suspend_ack(BSSGP_SUSPEND_ACK_MSG suspend_ack_msg ,UINT8 *msg,UINT16 *msg_len)
+{
+ DBG_FUNC("bssgp_encode_suspend_ack",BSSGP_LAYER);
+ DBG_ENTER();
+ UINT8 *byte;
+ UINT16 index = 0;
+
+ byte = (UINT8*)&msg[index];
+
+ /* Set the PDU type */
+ *byte = (UINT8)BSSGP_PDU_SUSPEND;
+
+ index++;
+
+ DBG_TRACE("Encoding Suspend-Ack message");
+
+ /* Encode the individual IE indicators */
+ /* tlli */
+ bssgp_ie_encode_tlli(suspend_ack_msg.tlli,&msg[index],&index, BSSGP_FORMAT_TLV);
+ /* routing area */
+ bssgp_ie_encode_routing_area(suspend_ack_msg.routing_area,&msg[index],&index);
+ /* suspend ref num */
+ bssgp_ie_encode_suspend_ref_num(suspend_ack_msg.suspend_ref_num,&msg[index],&index);
+
+ *msg_len += index;
+ DBG_TRACE("Suspend-Ack message %d bytes length",index);
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+/*
+ * bssgp_encode_suspend_nack
+ *
+ * Suspend NAck PDU defined in 08.18:-
+ *
+ * |-------------------------|
+ * | PDU Type |
+ * | TLLI |
+ * | Routing Area |
+ * | Exception cause |
+ * | BVCI (prop. ext.) |
+ * |-------------------------|
+ *
+ * From GS --> GP-10
+ */
+BOOL
+bssgp_encode_suspend_nack(BSSGP_SUSPEND_NACK_MSG suspend_nack_msg ,UINT8 *msg,UINT16 *msg_len)
+{
+ DBG_FUNC("bssgp_encode_suspend_nack",BSSGP_LAYER);
+ DBG_ENTER();
+ UINT8 *byte;
+ UINT16 index = 0;
+
+ byte = (UINT8*)&msg[index];
+ index++;
+
+ /* Set the PDU type */
+ *byte = (UINT8)BSSGP_PDU_SUSPEND;
+
+
+ DBG_TRACE("Encoding Suspend-Nack message");
+
+ /* Encode the individual IE indicators */
+ /* tlli */
+ bssgp_ie_encode_tlli(suspend_nack_msg.tlli,&msg[index],&index, BSSGP_FORMAT_TLV);
+ /* routing area */
+ bssgp_ie_encode_routing_area(suspend_nack_msg.routing_area,&msg[index],&index);
+ /* exception cause */
+ if (suspend_nack_msg.exception_cause.ie_present)
+ bssgp_ie_encode_exception_cause(suspend_nack_msg.exception_cause,&msg[index],&index);
+
+ *msg_len += index;
+ DBG_TRACE("Suspend-NAck message %d bytes length",index);
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+
+
+/*
+ * bssgp_encode_resume
+ *
+ * Resume PDU defined in 08.18:-
+ *
+ * |-------------------------|
+ * | PDU Type |
+ * | TLLI |
+ * | Routing Area |
+ * | Suspend ref num. |
+ * |-------------------------|
+ *
+ * From GP-10 to GS
+ */
+BOOL
+bssgp_encode_resume(BSSGP_RESUME_MSG resume_msg ,UINT8 *msg,UINT16 *msg_len)
+{
+ DBG_FUNC("bssgp_encode_resume",BSSGP_LAYER);
+ DBG_ENTER();
+ UINT8 *byte;
+ UINT16 index = 0;
+
+ byte = (UINT8*)&msg[index];
+ index++;
+
+ /* Set the PDU type */
+ *byte = (UINT8)BSSGP_PDU_RESUME;
+
+
+ DBG_TRACE("Encoding Resume message");
+
+ /* Encode the individual IE indicators */
+ /* tlli */
+ bssgp_ie_encode_tlli(resume_msg.tlli,&msg[index],&index, BSSGP_FORMAT_TLV);
+ /* routing area */
+ bssgp_ie_encode_routing_area(resume_msg.routing_area,&msg[index],&index);
+ /* suspend ref num */
+ bssgp_ie_encode_suspend_ref_num(resume_msg.suspend_ref_num,&msg[index],&index);
+
+ *msg_len += index;
+ DBG_TRACE("Resume message %d bytes length",index);
+
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+/*
+ * bssgp_encode_resume_ack
+ *
+ * Resume-Ack PDU defined in 08.18:-
+ *
+ * |-------------------------|
+ * | PDU Type |
+ * | TLLI |
+ * | Routing Area |
+ * | BVCI (prop. ext.) |
+ * |-------------------------|
+ *
+ * From GS --> GP-10
+ */
+BOOL
+bssgp_encode_resume_ack(BSSGP_RESUME_ACK_MSG resume_ack_msg ,UINT8 *msg,UINT16 *msg_len)
+{
+ DBG_FUNC("bssgp_encode_resume_ack",BSSGP_LAYER);
+ DBG_ENTER();
+ UINT8 *byte;
+ UINT16 index = 0;
+
+ byte = (UINT8*)&msg[index];
+ index++;
+
+ /* Set the PDU type */
+ *byte = (UINT8)BSSGP_PDU_RESUME_ACK;
+
+
+ DBG_TRACE("Encoding Resume-Ack message");
+
+ /* Encode the individual IE indicators */
+ /* tlli */
+ bssgp_ie_encode_tlli(resume_ack_msg.tlli,&msg[index],&index, BSSGP_FORMAT_TLV);
+ /* routing area */
+ bssgp_ie_encode_routing_area(resume_ack_msg.routing_area,&msg[index],&index);
+
+ *msg_len += index;
+ DBG_TRACE("Resume-Ack message %d bytes length",index);
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+/*
+ * bssgp_encode_resume_nack
+ *
+ * Resume-NAck PDU defined in 08.18:-
+ *
+ * |-------------------------|
+ * | PDU Type |
+ * | TLLI |
+ * | Routing Area |
+ * | Exception cause |
+ * |-------------------------|
+ *
+ * From GS --> GP-10
+ */
+BOOL
+bssgp_encode_resume_nack(BSSGP_RESUME_NACK_MSG resume_nack_msg ,UINT8 *msg,UINT16 *msg_len)
+{
+ DBG_FUNC("bssgp_encode_resume_nack",BSSGP_LAYER);
+ DBG_ENTER();
+ UINT8 *byte;
+ UINT16 index = 0;
+
+ byte = (UINT8*)&msg[index];
+ index++;
+
+ /* Set the PDU type */
+ *byte = (UINT8)BSSGP_PDU_RESUME_NACK;
+
+
+ DBG_TRACE("Encoding Resume-NAck message");
+
+ /* Encode the individual IE indicators */
+ /* tlli */
+ bssgp_ie_encode_tlli(resume_nack_msg.tlli,&msg[index],&index, BSSGP_FORMAT_TLV);
+ /* routing area */
+ bssgp_ie_encode_routing_area(resume_nack_msg.routing_area,&msg[index],&index);
+ /* exception cause */
+ if (resume_nack_msg.exception_cause.ie_present)
+ bssgp_ie_encode_exception_cause(resume_nack_msg.exception_cause,&msg[index],&index);
+
+ *msg_len += index;
+ DBG_TRACE("Resume-NAck message %d bytes length",index);
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+
+
+/*
+ * bssgp_encode_location_update
+ *
+ * Location-Update PDU defined by
+ * Cisco-EWTBU (proprietary)
+ *
+ * |-------------------------|
+ * | PDU Type |
+ * | IMSI |
+ * | BVCI |
+ * | Location Area |
+ * | Routing Area |
+ * |-------------------------|
+ *
+ * From GS --> GP-10
+ */
+BOOL
+bssgp_encode_location_update(BSSGP_LOCATION_UPDATE_MSG location_update_msg ,UINT8 *msg,UINT16 *msg_len)
+{
+ DBG_FUNC("bssgp_encode_location_update",BSSGP_LAYER);
+ DBG_ENTER();
+ UINT8 *byte;
+ UINT16 index = 0;
+
+ byte = (UINT8*)&msg[index];
+ index++;
+
+ /* Set the PDU type */
+ *byte = (UINT8)BSSGP_PDU_LOCATION_UPDATE;
+
+
+ DBG_TRACE("Encoding Location-Update message");
+
+
+ /* Encode the individual IE indicators */
+ /* imsi */
+ bssgp_ie_encode_imsi(location_update_msg.imsi,&msg[index],&index);
+
+ /* bvci */
+ bssgp_ie_encode_bvci(location_update_msg.bvci,&msg[index],&index);
+
+ /* location area */
+ bssgp_ie_encode_location_area(location_update_msg.location_area,&msg[index],&index);
+
+ /* routing area */
+ bssgp_ie_encode_routing_area(location_update_msg.routing_area,&msg[index],&index);
+
+
+ *msg_len += index;
+ DBG_TRACE("Location-Update message %d bytes length",index);
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+
+/*
+ * bssgp_encode_location_update_ack
+ *
+ * Location-Update-Ack PDU defined by
+ * Cisco-EWTBU (proprietary)
+ *
+ * |-------------------------|
+ * | PDU Type |
+ * | IMSI |
+ * | Location Area |
+ * |-------------------------|
+ *
+ * From GP-10 to GS
+ */
+BOOL
+bssgp_encode_location_update_ack(BSSGP_LOCATION_UPDATE_ACK_MSG location_update_ack ,UINT8 *msg,UINT16 *msg_len)
+{
+ DBG_FUNC("bssgp_encode_location_update_ack",BSSGP_LAYER);
+ DBG_ENTER();
+ UINT8 *byte;
+ UINT16 index = 0;
+
+ byte = (UINT8*)&msg[index];
+ index++;
+
+ /* Set the PDU type */
+ *byte = (UINT8)BSSGP_PDU_LOCATION_UPDATE_ACK;
+
+ DBG_TRACE("Encoding Location-Update-Ack message");
+
+
+ /* Encode the individual IE indicators */
+ /* imsi */
+ bssgp_ie_encode_imsi(location_update_ack.imsi,&msg[index],&index);
+
+ /* location area */
+ bssgp_ie_encode_location_area(location_update_ack.location_area,&msg[index],&index);
+
+
+ *msg_len += index;
+ DBG_TRACE("Location-Update-Ack message %d bytes length",index);
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+
+/*
+ * bssgp_encode_location_update_nack
+ *
+ * Location-Update-NAck PDU defined by
+ * Cisco-EWTBU (proprietary)
+ *
+ * |-------------------------|
+ * | PDU Type |
+ * | IMSI |
+ * | Location Area |
+ * | Reject cause |
+ * |-------------------------|
+ *
+ * From GP-10 to GS
+ */
+BOOL
+bssgp_encode_location_update_nack(BSSGP_LOCATION_UPDATE_NACK_MSG location_update_nack ,UINT8 *msg,UINT16 *msg_len)
+{
+ DBG_FUNC("bssgp_encode_location_update_nack",BSSGP_LAYER);
+ DBG_ENTER();
+ UINT8 *byte;
+ UINT16 index = 0;
+
+ byte = (UINT8*)&msg[index];
+ index++;
+
+ /* Set the PDU type */
+ *byte = (UINT8)BSSGP_PDU_LOCATION_UPDATE_NACK;
+
+ DBG_TRACE("Encoding Location-Update-NAck message");
+
+
+ /* Encode the individual IE indicators */
+ /* imsi */
+ bssgp_ie_encode_imsi(location_update_nack.imsi,&msg[index],&index);
+
+ /* location area */
+ bssgp_ie_encode_location_area(location_update_nack.location_area,&msg[index],&index);
+
+ /* reject cause */
+ bssgp_ie_encode_reject_cause(location_update_nack.reject_cause,&msg[index],&index);
+
+ *msg_len += index;
+ DBG_TRACE("Location-Update-NAck message %d bytes length",index);
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+
+
+/*
+ * bssgp_encode_radio_cap
+ *
+ * Radio-Access-Capability PDU defined in
+ * 08.18
+ *
+ * |-------------------------|
+ * | PDU Type |
+ * | TLLI |
+ * | MS Radio Access Cap |
+ * | BVCI (prop. ext.) |
+ * |-------------------------|
+ *
+ * From GS to GP-10
+ */
+BOOL
+bssgp_encode_radio_cap(BSSGP_RADIO_CAP_MSG radio_cap ,UINT8 *msg,UINT16 *msg_len)
+{
+ DBG_FUNC("bssgp_encode_radio_cap",BSSGP_LAYER);
+ DBG_ENTER();
+ UINT8 *byte;
+ UINT16 index = 0;
+
+ byte = (UINT8*)&msg[index];
+
+ /* Set the PDU type */
+ *byte = (UINT8)BSSGP_PDU_RA_CAP;
+ index++;
+
+ DBG_TRACE("Encoding Radio-Access-Capability message");
+
+
+ /* Encode the individual IE indicators */
+ /* tlli */
+ bssgp_ie_encode_tlli(radio_cap.tlli,&msg[index],&index, BSSGP_FORMAT_TLV);
+
+ /* ra-cap */
+ bssgp_ie_encode_ms_ra_cap(radio_cap.ra_cap,&msg[index],&index);
+
+ *msg_len += index;
+ DBG_TRACE("Radio-Access-Capability message %d bytes length",index);
+
+ DBG_LEAVE();
+ return(TRUE);
+}
+
+
+/*
+ * bssgp_encode_radio_cap_update
+ *
+ * Radio-Access-Capability-Update PDU defined in
+ * 08.18
+ *
+ * |-------------------------|
+ * | PDU Type |
+ * | TLLI |
+ * | bvci
+ |
+ * |-------------------------|
+ *
+ * From GP-10 to GS
+ */
+BOOL
+bssgp_encode_radio_cap_update(BSSGP_RADIO_CAP_UPDATE_MSG radio_cap_update ,UINT8 *msg,UINT16 *msg_len)
+{
+ DBG_FUNC("bssgp_encode_radio_cap_update",BSSGP_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 index = 0;
+
+ byte = (UINT8*)&msg[index];
+ index++;
+
+ /* Set the PDU type */
+ *byte = (UINT8)BSSGP_PDU_RA_CAP_UPDATE;
+
+ DBG_TRACE("Encoding Radio-Access-Capability-Update message");
+
+ /* Encode the individual IE indicators */
+ /* tlli */
+ bssgp_ie_encode_tlli(radio_cap_update.tlli,&msg[index],&index, BSSGP_FORMAT_TLV);
+
+ /* tag */
+ bssgp_ie_encode_tag(radio_cap_update.tag,&msg[index],&index);
+
+ *msg_len += index;
+ DBG_TRACE("Radio-Access-Capability-Update message %d bytes length",index);
+
+ DBG_LEAVE();
+ return(TRUE);
+}
+
+
+/*
+ * bssgp_encode_radio_cap_update_ack
+ *
+ * Radio-Access-Capability-Update-ACK PDU defined in
+ * 08.18
+ *
+ * |-------------------------|
+ * | PDU Type |
+ * | TLLI |
+ * | Tag |
+ * | IMSI |
+ * | RA-Cap-Upd-Cause |
+ * | MS Radio Access Cap |
+ * | BVCI (prop. ext.) |
+ * |-------------------------|
+ *
+ * From GP-10 to GS
+ */
+BOOL
+bssgp_encode_radio_cap_update_ack(BSSGP_RADIO_CAP_UPDATE_ACK_MSG radio_cap_update_ack ,UINT8 *msg,UINT16 *msg_len)
+{
+ DBG_FUNC("bssgp_encode_radio_cap_update_ack",BSSGP_LAYER);
+ DBG_ENTER();
+ UINT8 *byte;
+ UINT16 index = 0;
+
+ byte = (UINT8*)&msg[index];
+ index++;
+
+ /* Set the PDU type */
+ *byte = (UINT8)BSSGP_PDU_RA_CAP_UPDATE_ACK;
+
+ DBG_TRACE("Encoding Radio-Access-Capability-Update-Ack message");
+ /* Encode the individual IE indicators */
+ /* tlli */
+ bssgp_ie_encode_tlli(radio_cap_update_ack.tlli,&msg[index],&index, BSSGP_FORMAT_TLV);
+
+ /* tag */
+ bssgp_ie_encode_tag(radio_cap_update_ack.tag,&msg[index],&index);
+
+ /* imsi */
+ if (radio_cap_update_ack.imsi.ie_present)
+ bssgp_ie_encode_imsi(radio_cap_update_ack.imsi,&msg[index],&index);
+
+ /* RA-Cap-UPD-CAUSE */
+ bssgp_ie_encode_ra_cap_update_cause(radio_cap_update_ack.cause,&msg[index],&index);
+
+ /* RA-Cap */
+ if (radio_cap_update_ack.ra_cap.ie_present) {
+ bssgp_ie_encode_ms_ra_cap(radio_cap_update_ack.ra_cap,&msg[index],&index);
+ }
+ *msg_len += index;
+ DBG_TRACE("Radio-Access-Capability-Update-Ack message %d bytes length",index);
+
+ DBG_LEAVE();
+ return(TRUE);
+}
+
+
+
+
+
+
+/*
+ * bssgp_encode_flow_control_ms
+ */
+BOOL
+bssgp_encode_flow_control_ms(BSSGP_FLOW_CONTROL_MS_MSG flow_control_ms,UINT8 *msg,UINT16 *msg_len)
+{
+ DBG_FUNC("bssgp_encode_flow_control_ms",BSSGP_LAYER);
+ DBG_ENTER();
+ UINT8 *byte;
+ UINT16 index = 0;
+
+ byte = (UINT8*)&msg[index];
+ index++;
+
+ /* Set the PDU type */
+ *byte = (UINT8)BSSGP_PDU_FLOW_CONTROL_MS;
+
+ DBG_TRACE("Encoding Flow-Control-MS message");
+ /* Encode the individual IE indicators */
+ /* tlli */
+ if (flow_control_ms.tlli.ie_present)
+ {
+ bssgp_ie_encode_tlli(flow_control_ms.tlli,&msg[index],&index, BSSGP_FORMAT_TLV);
+ }
+ else {
+ DBG_ERROR("Mandatory element TLLI not specified for flow-control-ms msg!");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ /* tag */
+ bssgp_ie_encode_tag(flow_control_ms.tag,&msg[index],&index);
+
+ /* MS Bucket Size */
+ bssgp_ie_encode_ms_bucket_size(flow_control_ms.ms_bucket_size,&msg[index],&index);
+
+ /* Bucket Leak Rate */
+ bssgp_ie_encode_bucket_leak_rate(flow_control_ms.bucket_leak_rate,&msg[index],&index);
+
+ *msg_len += index;
+ DBG_TRACE("Flow-Control-MS message %d bytes length",index);
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+/*
+ * bssgp_encode_flow_control_ms_ack
+ */
+BOOL
+bssgp_encode_flow_control_ms_ack(BSSGP_FLOW_CONTROL_MS_ACK_MSG flow_control_ms_ack,UINT8 *msg,UINT16 *msg_len)
+{
+ DBG_FUNC("bssgp_encode_flow_control_ms_ack",BSSGP_LAYER);
+ DBG_ENTER();
+ UINT8 *byte;
+ UINT16 index = 0;
+
+ byte = (UINT8*)&msg[index];
+ index++;
+
+ /* Set the PDU type */
+ *byte = (UINT8)BSSGP_PDU_FLOW_CONTROL_MS_ACK;
+
+ DBG_TRACE("Encoding Flow-Control-MS-ACK message");
+ /* Encode the individual IE indicators */
+ /* tlli */
+ if (flow_control_ms_ack.tlli.ie_present)
+ {
+ bssgp_ie_encode_tlli(flow_control_ms_ack.tlli,&msg[index],&index, BSSGP_FORMAT_TLV);
+ }
+ else {
+ DBG_ERROR("Mandatory element TLLI not specified for flow-control-ms-ack msg!");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ /* tag */
+ bssgp_ie_encode_tag(flow_control_ms_ack.tag,&msg[index],&index);
+
+ *msg_len += index;
+ DBG_TRACE("Flow-Control-MS-ACK message %d bytes length",index);
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+/*
+ * bssgp_encode_flush_ll
+ */
+BOOL
+bssgp_encode_flush_ll(BSSGP_FLUSH_LL_MSG flush_ll,UINT8 *msg,UINT16 *msg_len)
+{
+ DBG_FUNC("bssgp_encode_flush_ll",BSSGP_LAYER);
+ DBG_ENTER();
+ UINT8 *byte;
+ UINT16 index = 0;
+
+ byte = (UINT8*)&msg[index];
+ index++;
+
+ /* Set the PDU type */
+ *byte = (UINT8)BSSGP_PDU_FLUSH_LL;
+
+ DBG_TRACE("Encoding Flush-LL message");
+ /* Encode the individual IE indicators */
+ /* tlli */
+ if (flush_ll.tlli.ie_present)
+ {
+ bssgp_ie_encode_tlli(flush_ll.tlli,&msg[index],&index, BSSGP_FORMAT_TLV);
+ }
+ else {
+ DBG_ERROR("Mandatory element TLLI not specified for flush-ll msg!");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ /* bvci (old) */
+ if (flush_ll.bvci_old.ie_present)
+ {
+ bssgp_ie_encode_bvci(flush_ll.bvci_old,&msg[index],&index);
+ }
+ else {
+ DBG_ERROR("Mandatory element BVCI (old) not specified for flush-ll msg!");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ /* bvci (new) */
+ if (flush_ll.bvci_new.ie_present)
+ {
+ bssgp_ie_encode_bvci(flush_ll.bvci_new,&msg[index],&index);
+ }
+
+ *msg_len += index;
+ DBG_TRACE("Encoding Flush-LL message %d bytes length",index);
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+/*
+ * bssgp_encode_flush_ll_ack
+ */
+BOOL
+bssgp_encode_flush_ll_ack(BSSGP_FLUSH_LL_ACK_MSG flush_ll_ack,UINT8 *msg,UINT16 *msg_len)
+{
+ DBG_FUNC("bssgp_encode_flush_ll_ack",BSSGP_LAYER);
+ DBG_ENTER();
+ UINT8 *byte;
+ UINT16 index = 0;
+
+ byte = (UINT8*)&msg[index];
+ index++;
+
+ /* Set the PDU type */
+ *byte = (UINT8)BSSGP_PDU_FLUSH_LL_ACK;
+
+ DBG_TRACE("Encoding Flush-LL-ACK message");
+ /* tlli */
+ if (flush_ll_ack.tlli.ie_present)
+ {
+ bssgp_ie_encode_tlli(flush_ll_ack.tlli,&msg[index],&index, BSSGP_FORMAT_TLV);
+ }
+ else {
+ DBG_ERROR("Mandatory element TLLI not specified for flush-ll-ack msg!");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ /* flush action */
+ bssgp_ie_encode_flush_action(flush_ll_ack.flush_action,&msg[index],&index);
+
+ /* bvci (new) */
+ if (flush_ll_ack.bvci_new.ie_present)
+ {
+ bssgp_ie_encode_bvci(flush_ll_ack.bvci_new,&msg[index],&index);
+ }
+
+ *msg_len += index;
+ DBG_TRACE("Flush-LL-ACK message %d bytes length",index);
+
+ DBG_LEAVE();
+ return (TRUE);
+
+}
+
+/*
+ * bssgp_encode_llc_discarded
+ */
+BOOL
+bssgp_encode_llc_discarded(BSSGP_LLC_DISCARDED_MSG llc_discarded,UINT8 *msg,UINT16 *msg_len)
+{
+ DBG_FUNC("bssgp_encode_llc_discarded",BSSGP_LAYER);
+ DBG_ENTER();
+ UINT8 *byte;
+ UINT16 index = 0;
+
+ byte = (UINT8*)&msg[index];
+ index++;
+
+ /* Set the PDU type */
+ *byte = (UINT8)BSSGP_PDU_LLC_DISCARDED;
+
+ DBG_TRACE("Encoding LLC-Discarded message");
+ /* tlli */
+ if (llc_discarded.tlli.ie_present)
+ {
+ bssgp_ie_encode_tlli(llc_discarded.tlli,&msg[index],&index, BSSGP_FORMAT_TLV);
+ }
+ else {
+ DBG_ERROR("Mandatory element TLLI not specified for llc-discarded msg!");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ /* LLC frames discarded */
+ bssgp_ie_encode_llc_frames_discarded(llc_discarded.num_frames,&msg[index],&index);
+
+ /* bvci */
+ if (llc_discarded.bvci.ie_present)
+ {
+ bssgp_ie_encode_bvci(llc_discarded.bvci,&msg[index],&index);
+ }
+ else {
+ DBG_ERROR("Mandatory element BVCI not specified for llc-discarded msg!");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ /* number of octets deleted */
+ bssgp_ie_encode_num_octets_affected(llc_discarded.num_octets,&msg[index],&index);
+
+ *msg_len += index;
+ DBG_TRACE("LLC-Discarded message %d bytes length",index);
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+/*
+ * bssgp_encode_flow_control_bvc
+ */
+BOOL
+bssgp_encode_flow_control_bvc(BSSGP_FLOW_CONTROL_BVC_MSG flow_control_bvc, UINT8 *msg,UINT16 *msg_len)
+{
+ DBG_FUNC("bssgp_encode_flow_control_bvc",BSSGP_LAYER);
+ DBG_ENTER();
+ UINT8 *byte;
+ UINT16 index = 0;
+
+ byte = (UINT8*)&msg[index];
+ index++;
+
+ /* Set the PDU type */
+ *byte = (UINT8)BSSGP_PDU_FLOW_CONTROL_BVC;
+
+ DBG_TRACE("Encoding Flow-Control-BVC message");
+
+ /* tag */
+ bssgp_ie_encode_tag(flow_control_bvc.tag,&msg[index],&index);
+
+ /* BVC Bucket Size */
+ bssgp_ie_encode_bvc_bucket_size(flow_control_bvc.bvc_bucket_size,&msg[index],&index);
+
+ /* Bucket Leak Rate */
+ bssgp_ie_encode_bucket_leak_rate(flow_control_bvc.bucket_leak_rate,&msg[index],&index);
+
+ /* Bmax default ms */
+ bssgp_ie_encode_bmax_def_ms(flow_control_bvc.bmax,&msg[index],&index);
+
+ /* R_default_MS */
+ bssgp_ie_encode_r_def_ms(flow_control_bvc.r_default,&msg[index],&index);
+
+ /* BVC measurement */
+ if (flow_control_bvc.bvc_meas.ie_present)
+ bssgp_ie_encode_bvc_measurement(flow_control_bvc.bvc_meas,&msg[index],&index);
+
+ *msg_len += index;
+ DBG_TRACE("Flow-Control-BVC message %d bytes length",index);
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+/*
+ * bssgp_encode_flow_control_bvc_ack
+ */
+BOOL
+bssgp_encode_flow_control_bvc_ack(BSSGP_FLOW_CONTROL_BVC_ACK_MSG flow_control_bvc_ack, UINT8 *msg,UINT16 *msg_len)
+{
+ DBG_FUNC("bssgp_encode_flow_control_bvc_ack",BSSGP_LAYER);
+ DBG_ENTER();
+ UINT8 *byte;
+ UINT16 index = 0;
+
+ byte = (UINT8*)&msg[index];
+ index++;
+
+ /* Set the PDU type */
+ *byte = (UINT8)BSSGP_PDU_FLOW_CONTROL_BVC_ACK;
+
+ DBG_TRACE("Encoding Flow-Control-BVC-ACK message");
+
+ /* tag */
+ bssgp_ie_encode_tag(flow_control_bvc_ack.tag,&msg[index],&index);
+
+ *msg_len += index;
+ DBG_TRACE("Flow-Control-BVC-ACK message %d bytes length",index);
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+/*
+ * bssgp_encode_bvc_block
+ */
+BOOL
+bssgp_encode_bvc_block(BSSGP_BVC_BLOCK_MSG bvc_block,UINT8 *msg,UINT16 *msg_len)
+{
+ DBG_FUNC("bssgp_encode_bvc_block",BSSGP_LAYER);
+ DBG_ENTER();
+ UINT8 *byte;
+ UINT16 index = 0;
+
+ byte = (UINT8*)&msg[index];
+ index++;
+
+ /* Set the PDU type */
+ *byte = (UINT8)BSSGP_PDU_BVC_BLOCK;
+
+ DBG_TRACE("Encoding BVC-Block message");
+
+ /* bvci */
+ if (bvc_block.bvci.ie_present)
+ {
+ bssgp_ie_encode_bvci(bvc_block.bvci,&msg[index],&index);
+ }
+ else {
+ DBG_ERROR("Mandatory element BVCI not specified for bvc-block msg!");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ /* cause */
+ if (bvc_block.cause.ie_present)
+ {
+ bssgp_ie_encode_exception_cause(bvc_block.cause,&msg[index],&index);
+ }
+ else {
+ DBG_ERROR("Mandatory element BVCI not specified for bvc-block msg!");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ *msg_len += index;
+ DBG_TRACE("BVC-Block message %d bytes length",index);
+
+ DBG_LEAVE();
+ return (TRUE);
+
+}
+
+
+/*
+ * bssgp_encode_bvc_block_ack
+ */
+BOOL
+bssgp_encode_bvc_block_ack(BSSGP_BVC_BLOCK_ACK_MSG bvc_block_ack,UINT8 *msg,UINT16 *msg_len)
+{
+ DBG_FUNC("bssgp_encode_bvc_block_ack",BSSGP_LAYER);
+ DBG_ENTER();
+ UINT8 *byte;
+ UINT16 index = 0;
+
+ byte = (UINT8*)&msg[index];
+ index++;
+
+ /* Set the PDU type */
+ *byte = (UINT8)BSSGP_PDU_BVC_BLOCK_ACK;
+
+ DBG_TRACE("Encoding BVC-Block-ACK message");
+
+ /* bvci */
+ if (bvc_block_ack.bvci.ie_present)
+ {
+ bssgp_ie_encode_bvci(bvc_block_ack.bvci,&msg[index],&index);
+ }
+ else {
+ DBG_ERROR("Mandatory element BVCI not specified for bvc-block-ack msg!");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ *msg_len += index;
+ DBG_TRACE("BVC-Block-ACK message %d bytes length",index);
+
+ DBG_LEAVE();
+ return (TRUE);
+
+}
+
+
+/*
+ * bssgp_encode_bvc_unblock
+ */
+BOOL
+bssgp_encode_bvc_unblock(BSSGP_BVC_UNBLOCK_MSG bvc_unblock,UINT8 *msg,UINT16 *msg_len)
+{
+ DBG_FUNC("bssgp_encode_bvc_unblock",BSSGP_LAYER);
+ DBG_ENTER();
+ UINT8 *byte;
+ UINT16 index = 0;
+
+ byte = (UINT8*)&msg[index];
+ index++;
+
+ /* Set the PDU type */
+ *byte = (UINT8)BSSGP_PDU_UNBLOCK;
+
+ DBG_TRACE("Encoding BVC-Unblock message");
+
+ /* bvci */
+ if (bvc_unblock.bvci.ie_present)
+ {
+ bssgp_ie_encode_bvci(bvc_unblock.bvci,&msg[index],&index);
+ }
+ else {
+ DBG_ERROR("Mandatory element BVCI not specified for bvc-unblock msg!");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ *msg_len += index;
+ DBG_TRACE("BVC-Unblock message %d bytes length",index);
+
+ DBG_LEAVE();
+ return (TRUE);
+
+}
+
+
+/*
+ * bssgp_encode_bvc_unblock_ack
+ */
+BOOL
+bssgp_encode_bvc_unblock_ack(BSSGP_BVC_UNBLOCK_ACK_MSG bvc_unblock_ack,UINT8 *msg,UINT16 *msg_len)
+{
+ DBG_FUNC("bssgp_encode_bvc_unblock_ack",BSSGP_LAYER);
+ DBG_ENTER();
+ UINT8 *byte;
+ UINT16 index = 0;
+
+ byte = (UINT8*)&msg[index];
+ index++;
+
+ /* Set the PDU type */
+ *byte = (UINT8)BSSGP_PDU_UNBLOCK_ACK;
+
+ DBG_TRACE("Encoding BVC-Unblock-ACK message");
+
+ /* bvci */
+ if (bvc_unblock_ack.bvci.ie_present)
+ {
+ bssgp_ie_encode_bvci(bvc_unblock_ack.bvci,&msg[index],&index);
+ }
+ else {
+ DBG_ERROR("Mandatory element BVCI not specified for bvc-unblock-ack msg!");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ *msg_len += index;
+ DBG_TRACE("BVC-Unblock-ACK message %d bytes length",index);
+
+ DBG_LEAVE();
+ return (TRUE);
+
+}
+
+
+/*
+ * bssgp_encode_bvc_reset
+ */
+BOOL
+bssgp_encode_bvc_reset(BSSGP_BVC_RESET_MSG bvc_reset,UINT8 *msg,UINT16 *msg_len)
+{
+ DBG_FUNC("bssgp_encode_bvc_reset",BSSGP_LAYER);
+ DBG_ENTER();
+ UINT8 *byte;
+ UINT16 index = 0;
+
+ byte = (UINT8*)&msg[index];
+ index++;
+
+ /* Set the PDU type */
+ *byte = (UINT8)BSSGP_PDU_RESET;
+
+ DBG_TRACE("Encoding BVC-Reset message");
+
+ /* bvci */
+ if (bvc_reset.bvci.ie_present)
+ {
+ bssgp_ie_encode_bvci(bvc_reset.bvci,&msg[index],&index);
+ }
+ else {
+ DBG_ERROR("Mandatory element BVCI not specified for bvc-reset msg!");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ /* cause */
+ if (bvc_reset.cause.ie_present)
+ {
+ bssgp_ie_encode_exception_cause(bvc_reset.cause,&msg[index],&index);
+ }
+ else {
+ DBG_ERROR("Mandatory element BVCI not specified for bvc-reset msg!");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ /* cell id */
+ if (bvc_reset.cell_id.ie_present) {
+ bssgp_ie_encode_cell_id(bvc_reset.cell_id,&msg[index],&index);
+ }
+
+ *msg_len += index;
+ DBG_TRACE("BVC-Reset message %d bytes length",index);
+
+ DBG_LEAVE();
+ return (TRUE);
+
+}
+
+
+/*
+ * bssgp_encode_bvc_reset_ack
+ */
+BOOL
+bssgp_encode_bvc_reset_ack(BSSGP_BVC_RESET_ACK_MSG bvc_reset_ack,UINT8 *msg,UINT16 *msg_len)
+{
+ DBG_FUNC("bssgp_encode_bvc_reset_ack",BSSGP_LAYER);
+ DBG_ENTER();
+ UINT8 *byte;
+ UINT16 index = 0;
+
+ byte = (UINT8*)&msg[index];
+ index++;
+
+ /* Set the PDU type */
+ *byte = (UINT8)BSSGP_PDU_RESET_ACK;
+
+ DBG_TRACE("Encoding BVC-Reset-Ack message");
+
+ /* bvci */
+ if (bvc_reset_ack.bvci.ie_present)
+ {
+ bssgp_ie_encode_bvci(bvc_reset_ack.bvci,&msg[index],&index);
+ }
+ else {
+ DBG_ERROR("Mandatory element BVCI not specified for bvc-reset-ack msg!");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ /* cell id */
+ if (bvc_reset_ack.cell_id.ie_present) {
+ bssgp_ie_encode_cell_id(bvc_reset_ack.cell_id,&msg[index],&index);
+ }
+
+ *msg_len += index;
+ DBG_TRACE("BVC-Reset-Ack message %d bytes length",index);
+
+ DBG_LEAVE();
+ return (TRUE);
+
+}
+
+
+/*
+ * bssgp_encode_bvc_status
+ */
+BOOL
+bssgp_encode_bvc_status(BSSGP_BVC_STATUS_MSG bvc_status,UINT8 *msg,UINT16 *msg_len)
+{
+ DBG_FUNC("bssgp_encode_bvc_status",BSSGP_LAYER);
+ DBG_ENTER();
+ UINT8 *byte;
+ UINT16 index = 0;
+
+ byte = (UINT8*)&msg[index];
+ index++;
+
+ /* Set the PDU type */
+ *byte = (UINT8)BSSGP_PDU_STATUS;
+
+ DBG_TRACE("Encoding BVC-Status message");
+
+ /* cause */
+ if (bvc_status.cause.ie_present)
+ {
+ bssgp_ie_encode_exception_cause(bvc_status.cause,&msg[index],&index);
+ }
+ else {
+ DBG_ERROR("Mandatory element BVCI not specified for bvc-status msg!");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ /* bvci */
+ if (bvc_status.bvci.ie_present)
+ {
+ bssgp_ie_encode_bvci(bvc_status.bvci,&msg[index],&index);
+ }
+ else {
+ DBG_ERROR("Mandatory element BVCI not specified for bvc-status msg!");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ *msg_len += index;
+ DBG_TRACE("BVC-Status message %d bytes length",index);
+
+ DBG_LEAVE();
+ return (TRUE);
+
+}
diff --git a/data/mnet/Common/bssgp/src/bssgp_ie_decoder.cpp b/data/mnet/Common/bssgp/src/bssgp_ie_decoder.cpp
new file mode 100644
index 0000000..a20f42a
--- /dev/null
+++ b/data/mnet/Common/bssgp/src/bssgp_ie_decoder.cpp
@@ -0,0 +1,2818 @@
+/*
+ ****************************************************************************************
+ * *
+ * Copyright Cisco Systems, Inc 2000 All rights reserved *
+ * *
+ * File : bssgp_ie_decoder.cpp *
+ * *
+ * Description : Decoding functions for the BSS-GP layer module *
+ * *
+ * Author : Dinesh Nambisan *
+ * *
+ *--------------------------- Notes ----------------------------------------------------*
+ * References are to sections numbers of the BSSGP spec. (GSM 08.18) unless otherwise *
+ * indicated *
+ *----------------------- Revision history ---------------------------------------------*
+ * Time | Date | Name | Description *
+ *--------------------------------------------------------------------------------------*
+ * 00:00 |10/10/00 | DSN | File created *
+ * | | | *
+ ****************************************************************************************
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include "bssgp/bssgp_prot.h"
+#include "bssgp/bssgp_util.h"
+#include "bssgp/bssgp_ie_decoder.h"
+
+void HexDumper(UINT8 *buffer, int length );
+
+/*
+ * bssgp_ie_decode_alignment_octets
+ *
+ *----------------------------------------------------------
+ * 11.3.1 Alignment octets
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3-4 spare octet
+ *
+ * The Alignment octets are used to align a subsequent IEI
+ * onto a 32 bit boundary.
+ *
+ *----------------------------------------------------------
+ *
+ */
+BOOL
+bssgp_ie_decode_alignment_octets(UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_decode_alignment_octets",BSSGP_DECODER_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 index = 0,iei_len;
+
+ byte = &msg[index];
+
+ if (*byte != (UINT8)BSSGP_IEI_ALIGNMENT_OCTETS) {
+ DBG_ERROR("Alignment octets IEI Invalid!");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+ index++;
+
+ iei_len = bssgp_ie_decode_iei_length(&msg[index],&index);
+ if (iei_len > 3) {
+ DBG_ERROR("Alignment octets IEI length Invalid!");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ /* Just skip by length number of bytes */
+ index += iei_len;
+
+ DBG_TRACE("Alignment octets decoded; IEI length %d bytes",index);
+
+ *len += index;
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+/*
+ * bssgp_ie_decode_bmax_def_ms
+ *
+ *----------------------------------------------------------
+ * 11.3.2 Bmax default MS
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3-4 Bmax
+ *
+ * The Bmax field is coded as in section GSM 08.18
+ * BVC Bucket Size/Bmax.
+ *
+ *----------------------------------------------------------
+ *
+ */
+BOOL
+bssgp_ie_decode_bmax_def_ms(UINT16 *bmax, UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_decode_bmax_def_ms",BSSGP_DECODER_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 index = 0,iei_len;
+
+ byte = &msg[index];
+
+ if (*byte != (UINT8)BSSGP_IEI_BMAX_DEFAULT_MS) {
+ DBG_ERROR("BMAX DEFAULT MS IEI Invalid!");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+ index++;
+
+ iei_len = bssgp_ie_decode_iei_length(&msg[index],&index);
+ if (iei_len != sizeof(UINT16)) {
+ DBG_ERROR("BMAX DEFAULT MS IEI length Invalid!");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ *bmax = (msg[index++] << 8) | msg[index++];
+
+ DBG_TRACE("BMAX DEFAULT MS %d decoded; IEI length %d bytes",*bmax,index);
+
+ *len += index;
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+
+/*
+ * bssgp_ie_decode_bss_area_ind
+ *
+ *----------------------------------------------------------
+ * 11.3.3 BSS Area Indication
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3 BSS indicator
+ *
+ * The coding of octet 2 is a binary number indicating
+ * the Length of the remaining element.
+ * The coding of octet 3 shall not be specified. The
+ * recipient shall ignore the value of this octet.
+ *----------------------------------------------------------
+ *
+ */
+BOOL
+bssgp_ie_decode_bss_area_ind(RIL3_BSS_AREA_INDICATION *bss_area, UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_decode_bss_area_ind",BSSGP_DECODER_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 index = 0,iei_len;
+
+ byte = &msg[index];
+
+ if (*byte != (UINT8)BSSGP_IEI_BSS_AREA_IND) {
+ DBG_ERROR("BSS Area Indication IEI Invalid!");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+ index++;
+
+ iei_len = bssgp_ie_decode_iei_length(&msg[index],&index);
+ if (iei_len != sizeof(UINT8)) {
+ DBG_ERROR("BSS Area Indication IEI length Invalid!");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ // Just skip the bss area ind value since it is ignored.
+ index++;
+
+ DBG_TRACE("BSS Area Indication decoded; IEI length %d bytes",index);
+
+ *len += index;
+ bss_area->ie_present = TRUE;
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+
+/*
+ * bssgp_ie_decode_bucket_leak_rate
+ *
+ *----------------------------------------------------------
+ * 11.3.4 Bucket Leak Rate (R)
+ * This information element indicates the leak rate (R)
+ * to be applied to a flow control bucket.
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3 R Value (MSB)
+ * octet 4 R Value (LSB)
+ *
+ * The R field is the binary encoding of the rate
+ * information expressed in 100 bits/sec increments,
+ * starting from 0 x 100 bits/sec until 65535 x 100
+ * bits/sec (6 Mbps).
+ *----------------------------------------------------------
+ *
+ */
+BOOL
+bssgp_ie_decode_bucket_leak_rate(UINT16 *r_value, UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_decode_bucket_leak_rate",BSSGP_DECODER_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 index = 0,iei_len;
+
+ byte = &msg[index];
+
+ if (*byte != (UINT8)BSSGP_IEI_BUCKET_LEAK_RATE) {
+ DBG_ERROR("Bucket Leak Rate IEI Invalid!");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+ index++;
+
+ iei_len = bssgp_ie_decode_iei_length(&msg[index],&index);
+ if (iei_len != sizeof(UINT16)) {
+ DBG_ERROR("Bucket Leak Rate IEI length Invalid!");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ *r_value = (msg[index++] << 8) | msg[index++];
+
+ DBG_TRACE("Bucket Leak Rate %d decoded; IEI length %d bytes",*r_value,index);
+
+ *len += index;
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+
+
+/*
+ * bssgp_ie_decode_bvc_bucket_size
+ *
+ *----------------------------------------------------------
+ * 11.3.5 BVC Bucket Size
+ * This information element indicates the maximum bucket
+ * size (Bmax) in octets for a BVC.
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3 Bmax (MSB)
+ * octet 4 Bmax (LSB)
+ *
+ * The Bmax field is the binary encoding of the bucket
+ * size information expressed in 100 octet increments,
+ * starting from 0 x 100 octets until 65535 x 100 octets
+ * (6 Mbytes).
+ *----------------------------------------------------------
+ *
+ */
+BOOL
+bssgp_ie_decode_bvc_bucket_size(UINT16 *bmax, UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_decode_bvc_bucket_size",BSSGP_DECODER_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 index = 0,iei_len;
+
+ byte = &msg[index];
+
+ if (*byte != (UINT8)BSSGP_IEI_BVC_BUCKET_SIZE) {
+ DBG_ERROR("BVC Bucket Size IEI Invalid!");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+ index++;
+
+ iei_len = bssgp_ie_decode_iei_length(&msg[index],&index);
+ if (iei_len != sizeof(UINT16)) {
+ DBG_ERROR("BVC Bucket Size IEI length Invalid!");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ *bmax = (msg[index++] << 8) | msg[index++];
+
+ DBG_TRACE("BVC Bucket Size %d decoded; IEI length %d bytes",*bmax,index);
+
+ *len += index;
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+
+/*
+ * bssgp_ie_decode_bvci
+ *
+ *----------------------------------------------------------
+ * 11.3.6 BVCI (BSSGP Virtual Connection Identifier)
+ * The BVCI identifies a BVC. The element coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3-4 Unstructured value
+ *
+ *----------------------------------------------------------
+ *
+ */
+BOOL
+bssgp_ie_decode_bvci(RIL3_BVCI *bvci,UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_decode_bvci",BSSGP_DECODER_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 *shorty;
+ UINT16 index = 0,iei_len;
+
+ byte = &msg[index];
+
+ if (*byte != (UINT8)BSSGP_IEI_BVCI) {
+ DBG_ERROR("BVCI IEI Invalid!");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+ index++;
+
+ iei_len = bssgp_ie_decode_iei_length(&msg[index],&index);
+ if (iei_len != sizeof(UINT16)) {
+ DBG_ERROR("BVCI IEI length Invalid!");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ shorty = (UINT16*)&msg[index];
+ /* now we get bvci */
+ bvci->bvci = ntohs(*shorty);
+
+ index += sizeof(UINT16);
+
+ DBG_TRACE("BVCI %d decoded; IEI length %d bytes",bvci->bvci,index);
+
+ *len += index;
+
+ bvci->ie_present = TRUE;
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+/*
+ * bssgp_ie_decode_bvc_measurement
+ *
+ *----------------------------------------------------------
+ * 11.3.7 BVC Measurement
+ * This information element describes average queuing
+ * delay for a BVC. The element coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3,4 Delay Value (in centi-seconds)
+ *
+ * The Delay Value field is coded as a 16-bit integer
+ * value in units of centi-seconds (one hundredth of a
+ * second). This coding provides a range of over 10 minutes
+ * in increments of 10 msec. As a special case, the
+ * hexadecimal value 0xFFFF (decimal 65535) shall be
+ * interpreted as "infinite delay".
+ *----------------------------------------------------------
+ *
+ */
+BOOL
+bssgp_ie_decode_bvc_measurement(RIL3_BVC_MEASUREMENT *delay_val, UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_decode_bvc_measurement",BSSGP_DECODER_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 index = 0,iei_len;
+
+ byte = &msg[index];
+
+ if (*byte != (UINT8)BSSGP_IEI_BVC_MEASUREMENT) {
+ DBG_ERROR("BVC Measurement IEI Invalid!");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+ index++;
+
+ iei_len = bssgp_ie_decode_iei_length(&msg[index],&index);
+ if (iei_len != sizeof(UINT16)) {
+ DBG_ERROR("BVC Measurement IEI length Invalid!");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ delay_val->bvc_meas = (msg[index++] << 8) | msg[index++];
+
+ DBG_TRACE("BVC Measurement %d decoded; IEI length %d bytes",delay_val->bvc_meas,index);
+
+ *len += index;
+ delay_val->ie_present = TRUE;
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+/*
+ * bssgp_ie_decode_exception_cause
+ *
+ *----------------------------------------------------------
+ * 11.3.8 Cause
+ * The Cause information element indicates the reason for
+ * an exception condition. The element coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3 Cause value
+ *
+ *----------------------------------------------------------
+ *
+ */
+BOOL
+bssgp_ie_decode_exception_cause(RIL3_BSSGP_CAUSE *cause,UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_decode_exception_cause",BSSGP_DECODER_LAYER);
+ DBG_ENTER();
+ UINT8 *byte;
+ UINT16 index = 0,iei_len;
+
+ byte = &msg[index];
+
+ if (*byte != (UINT8)BSSGP_IEI_CAUSE) {
+ DBG_ERROR("Exception cause IEI Invalid!");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ index++;
+
+ iei_len = bssgp_ie_decode_iei_length(&msg[index],&index);
+ if (iei_len != sizeof(UINT8)) {
+ DBG_ERROR("Exception cause IEI length Invalid!");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ byte = &msg[index];
+ cause->cause = (BSSGP_EXCEPTION_CAUSE)*byte;
+ index++;
+
+ DBG_TRACE("Cause value %s decoded; IEI length %d bytes",
+ bssgp_util_get_exception_cause_str((BSSGP_EXCEPTION_CAUSE)cause->cause),
+ index);
+
+ *len += index;
+ cause->ie_present = TRUE;
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+/*
+ * bssgp_ie_decode_cell_id
+ *
+ *----------------------------------------------------------
+ * 11.3.9 Cell Identifier
+ * This information element uniquely identifies one cell.
+ * The element coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octets 3-8 Octets 3 to 8 contain the value part
+ * (starting with octet 2) of the Routing Area
+ * Identification IE defined in GSM 04.08
+ * [11], not including GSM 04.08 IEI
+ * octets 9-10 Octets 9 and 10 contain the value part
+ * (starting with octet 2) of the Cell
+ * Identity IE defined in GSM 04.08 [11],
+ * not including GSM 04.08 IEI
+ *
+ *----------------------------------------------------------
+ *
+ */
+BOOL
+bssgp_ie_decode_cell_id(RIL3_IE_CELL_IDENTIFIER *cell_id,UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_decode_cell_id",BSSGP_DECODER_LAYER);
+ DBG_ENTER();
+ UINT8 *byte;
+ UINT16 index = 0,iei_len, *shorty, lac;
+
+ byte = &msg[index];
+ index++;
+
+ if (*byte != BSSGP_IEI_CELL_ID) {
+ DBG_ERROR("Invalid Cell Identifier IEI, %d value",*byte);
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ iei_len = bssgp_ie_decode_iei_length(&msg[index],&index);
+ if (iei_len != 8) {
+ DBG_ERROR("Cell Identifier IEI length Invalid!");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ /*
+ * From 04.08:
+ *
+ * The routing area identification information element is
+ * coded as shown in figure 10.5.130/GSM 04.08 and
+ * table 10.5.148/GSM 04.08.
+ * 8 7 6 5 4 3 2 1
+ * ------------------------------
+ * * MCC digit 2 * MCC digit 1 * octet 2
+ * ------------------------------
+ * * MNC digit 3 * MCC digit 3 * octet 3
+ * ------------------------------
+ * * MNC digit 2 * MNC digit 1 * octet 4
+ * ------------------------------
+ * * LAC * octet 5
+ * ------------------------------
+ * * LAC cont'd * octet 6
+ * ------------------------------
+ * * RAC * octet 7
+ * ------------------------------
+ *
+ *
+ */
+ cell_id->routing_area.mcc[0] = msg[index] & 0x0f;
+ cell_id->routing_area.mcc[1] = (msg[index] & 0xf0) >> 4;
+ index++;
+
+ cell_id->routing_area.mcc[2] = msg[index] & 0x0f;
+ cell_id->routing_area.mnc[2] = (msg[index] & 0xf0) >> 4;
+ index++;
+
+ cell_id->routing_area.mnc[0] = msg[index] & 0x0f;
+ cell_id->routing_area.mnc[1] = (msg[index] & 0xf0) >> 4;
+ index++;
+
+
+ memcpy(&lac,&msg[index],sizeof(UINT16));
+ cell_id->routing_area.lac = ntohs(lac);
+ index += sizeof(UINT16);
+
+ cell_id->routing_area.rac = msg[index];
+ index++;
+
+ shorty = (UINT16*)&msg[index];
+ cell_id->cell_id.value = ntohs(*shorty);
+ index += sizeof(UINT16);
+
+ DBG_TRACE("Cell Identifier IE length %d bytes",index);
+
+ DBG_TRACE("Cell Identifier :- MCC : %d%d%d ; MNC : %d%d(%x) ; LAC : %d ; RAC : %d\n"
+ "\tCell Identity : %d",
+ cell_id->routing_area.mcc[0], cell_id->routing_area.mcc[1], cell_id->routing_area.mcc[2],
+ cell_id->routing_area.mnc[0], cell_id->routing_area.mnc[1], cell_id->routing_area.mnc[2],
+ cell_id->routing_area.lac,
+ cell_id->routing_area.rac,
+ cell_id->cell_id.value);
+
+ cell_id->ie_present = TRUE;
+
+ *len += index;
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+/*
+ * bssgp_ie_decode_channel_needed
+ *
+ *----------------------------------------------------------
+ * 11.3.10 Channel needed
+ * This information element is coded as defined in
+ * GSM 09.18. It is relevant to circuit-switched paging
+ * requests. The element coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3 Rest of element coded as the value part of
+ * the Channel Needed PDU defined in GSM 09.18,
+ * not including GSM 09.18 IEI and GSM 09.18
+ * length indicator
+ *
+ *----------------------------------------------------------
+ *
+ */
+BOOL
+bssgp_ie_decode_channel_needed(UINT8 *val, UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_decode_channel_needed",BSSGP_DECODER_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 index = 0,iei_len;
+
+ byte = &msg[index];
+
+ if (*byte != (UINT8)BSSGP_IEI_CHAN_NEEDED) {
+ DBG_ERROR("Channel Needed IEI Invalid!");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+ index++;
+
+ iei_len = bssgp_ie_decode_iei_length(&msg[index],&index);
+ if (iei_len != sizeof(UINT8)) {
+ DBG_ERROR("Channel Needed IEI length Invalid!");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ *val = msg[index++];
+
+ DBG_TRACE("Channel Needed %d decoded; IEI length %d bytes",*val,index);
+
+ *len += index;
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+/*
+ * bssgp_ie_decode_drx_params
+ *
+ *----------------------------------------------------------
+ * 11.3.11 DRX Parameters
+ * This information element contains MS specific DRX
+ * information. The element coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3-n Rest of element coded as the value part
+ * defined in GSM 04.08, not including GSM
+ * 04.08 IEI and GSM 04.08 octet length
+ * indicator
+ *
+ *----------------------------------------------------------
+ *
+ */
+BOOL
+bssgp_ie_decode_drx_params(T_CNI_RIL3_IE_DRX_PARAMETER *drx_params,UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_decode_drx_params",BSSGP_DECODER_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 index = 0,iei_len;
+
+ byte = &msg[index];
+
+ if (*byte != (UINT8)BSSGP_IEI_DRX_PARAMS) {
+ DBG_ERROR("DRX Parameters IEI Invalid!");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+ index++;
+
+ iei_len = bssgp_ie_decode_iei_length(&msg[index],&index);
+ if (iei_len != (sizeof(UINT8)*2)) {
+ DBG_ERROR("DRX Parameters IEI length Invalid!");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ /*
+ *
+ * The value part of a DRX parameter information element
+ * is coded as shown in table 10.5.139/GSM 04.08.
+ * ------------------------------
+ * 8 7 6 5 | 4 | 3 2 1
+ * ------------------------------
+ * SPLIT PG CYCLE CODE octet 2
+ * ------------------------------
+ * 0 0 0 0 | SPL| non-DRXtimer octet 3
+ * ------------------------------
+ *
+ */
+
+ byte = &msg[index];
+ drx_params->split_pg_cycle_code = *byte;
+ index++;
+
+ byte = &msg[index];
+ if (*byte & 0x80) {
+ drx_params->split_on_CCCH = TRUE;
+ drx_params->non_drx_timer = (T_CNI_RIL3_IE_NON_DRX_TIMER_VALUE)(*byte & 0x7f);
+ DBG_TRACE("Decoded DRX params :- Split PG cycle code %d ; Split on CCCH ; Non-DRX timer %d",
+ drx_params->split_pg_cycle_code,drx_params->non_drx_timer);
+ }
+ else {
+ drx_params->non_drx_timer = (T_CNI_RIL3_IE_NON_DRX_TIMER_VALUE)*byte;
+ DBG_TRACE("Decoded DRX params :- Split PG cycle code %d ; Non-DRX timer %d",
+ drx_params->split_pg_cycle_code,drx_params->non_drx_timer);
+ }
+
+ index++;
+
+ *len += index;
+ drx_params->ie_present = TRUE;
+
+ DBG_TRACE("DRX Params IEI length %d bytes",index);
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+/*
+ * bssgp_ie_decode_emlpp_priority
+ *
+ *----------------------------------------------------------
+ * 11.3.12 eMLPP-Priority
+ * This element indicates the eMLPP-Priority of a PDU.
+ * The element coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3 Rest of element coded as the value part of
+ * the eMLPP-Priority IE defined in GSM 08.08,
+ * not including GSM 08.08 IEI and GSM 08.08
+ * length indicator
+ *
+ *----------------------------------------------------------
+ *
+ */
+BOOL
+bssgp_ie_decode_emlpp_priority(UINT8 *val, UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_decode_emlpp_priority",BSSGP_DECODER_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 index = 0,iei_len;
+
+ byte = &msg[index];
+
+ if (*byte != (UINT8)BSSGP_IEI_EMLPP_PRIORITY) {
+ DBG_ERROR("eMLPP-Priority IEI Invalid!");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+ index++;
+
+ iei_len = bssgp_ie_decode_iei_length(&msg[index],&index);
+ if (iei_len != sizeof(UINT8)) {
+ DBG_ERROR("eMLPP-Priority IEI length Invalid!");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ *val = msg[index++];
+
+ DBG_TRACE("eMLPP-Priority %d decoded; IEI length %d bytes",*val,index);
+
+ *len += index;
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+/*
+ * bssgp_ie_decode_flush_action
+ *
+ *----------------------------------------------------------
+ * 11.3.13 Flush Action
+ * The Flush action information element indicates to the
+ * SGSN the action taken by the BSS in response to the
+ * flush request. The element coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3 Action value
+ *
+ * Table 11.16: Action coding
+ * Action value semantics of coding
+ *
+ * Hexadecimal
+ *
+ * x00 LLC-PDU(s) deleted
+ * x01 LLC-PDU(s) transferred
+ *
+ * All values not explicitly shown are reserved for
+ * future use
+ *
+ *----------------------------------------------------------
+ */
+BOOL
+bssgp_ie_decode_flush_action(BSSGP_FLUSH_ACTION *action, UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_decode_flush_action",BSSGP_DECODER_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 index = 0,iei_len;
+
+ byte = &msg[index];
+
+ if (*byte != (UINT8)BSSGP_IEI_FLUSH_ACTION) {
+ DBG_ERROR("Flush Action IEI Invalid!");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+ index++;
+
+ iei_len = bssgp_ie_decode_iei_length(&msg[index],&index);
+ if (iei_len != sizeof(UINT8)) {
+ DBG_ERROR("Flush Action IEI length Invalid!");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ *action = (BSSGP_FLUSH_ACTION)msg[index++];
+
+ DBG_TRACE("Flush Action %d decoded; IEI length %d bytes",*action,index);
+
+ *len += index;
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+/*
+ * bssgp_ie_decode_imsi
+ *
+ *----------------------------------------------------------
+ * 11.3.14 IMSI
+ * This information element contains the International
+ * Mobile Subscriber Identity. The element coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator = length of remaining stuff
+ * octet 3-n Octets 3-n contain an IMSI coded as the
+ * value part (starting with octet 3) of the
+ * Mobile Identity IE defined in GSM 04.08,
+ * not including GSM 04.08 IEI and GSM 04.08
+ * length indicator
+ *
+ *----------------------------------------------------------
+ */
+BOOL
+bssgp_ie_decode_imsi(T_CNI_RIL3_IE_MOBILE_ID *imsi,UINT8 *msg,UINT16 *msg_len)
+{
+ DBG_FUNC("bssgp_ie_decode_imsi",BSSGP_DECODER_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ int count;
+ UINT16 index = 0,iei_len;
+ char disp_buff[128], temp_buff[10];
+ bool oddDigits;
+
+ byte = &msg[index];
+
+ if (*byte != BSSGP_IEI_IMSI) {
+ DBG_ERROR("Invalid IMSI IEI");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+ index++;
+
+ iei_len = bssgp_ie_decode_iei_length(&msg[index],&index);
+
+ /*
+ * Refer to GSM 04.08; the IEI has the following
+ * structure; but this octet would be the first
+ * for us
+ * +-----------------------------------------------*
+ * * *odd/ * *
+ * * Identity digit 1 *even * Type of identity* octet 3
+ * * *indic* *
+ * +-----------------------+-----------------------*
+ */
+
+ byte = &msg[index];
+
+ if ((*byte & 0x07) != CNI_RIL3_IMSI) {
+ DBG_ERROR("Invalid IMSI IEI; mobile ID type %d",(*byte & 0x07));
+ DBG_LEAVE();
+ return (FALSE);
+ }
+ oddDigits = ((*byte & 0x08) >> 3);
+ imsi->ie_present = 1;
+ imsi->mobileIdType = CNI_RIL3_IMSI;
+
+ /* Now decode the first digit */
+ imsi->digits[0] = (*byte & 0xf0)>> 4;
+ imsi->numDigits = 1;
+
+ index++;
+ memset(disp_buff,0,128);
+ memset(temp_buff,0,10);
+ sprintf(disp_buff,"%d",imsi->digits[0]);
+
+ for(count=1;count<=(iei_len*2)-(2+oddDigits);count+=2) {
+ byte = &msg[index];
+ imsi->digits[count] = *byte & 0x0f;
+ imsi->digits[count+1] = ((*byte & 0xf0) >> 4);
+ index++;
+ imsi->numDigits += 2;
+ memset(temp_buff,0,10);
+ sprintf(temp_buff,"%d%d",imsi->digits[count],imsi->digits[count+1]);
+ strcat(disp_buff,temp_buff);
+ }
+ if (oddDigits == 0) {
+ /* one digit left over */
+ byte = &msg[index];
+ imsi->digits[count] = *byte & 0x0f;
+ imsi->numDigits++;
+ memset(temp_buff,0,10);
+ sprintf(temp_buff,"%d",imsi->digits[count]);
+ strcat(disp_buff,temp_buff);
+ index++;
+ }
+
+ *msg_len += index;
+ imsi->ie_present = TRUE;
+
+ DBG_TRACE("Decoded IMSI : %s; IEI length %d bytes",disp_buff,index);
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+/*
+ * bssgp_ie_decode_llc_pdu
+ *
+ *----------------------------------------------------------
+ * 11.3.15 LLC-PDU
+ * This information element contains an LLC-PDU. The
+ * element coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3 LLC-PDU (first part)
+ * octet n LLC-PDU (last part)
+ *
+ *----------------------------------------------------------
+ *
+ */
+BOOL
+bssgp_ie_decode_llc_pdu(BSSGP_DL_UNITDATA_MSG *dl_unitdata,UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_decode_llc_pdu",BSSGP_DECODER_LAYER);
+ DBG_ENTER();
+ UINT8 *byte;
+ UINT16 index = 0,iei_len;
+
+ byte = &msg[index];
+ index++;
+
+ if (*byte != BSSGP_IEI_LLC_PDU) {
+ DBG_ERROR("IEI not LLC PDU, %d type !!",*byte);
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+
+ iei_len = bssgp_ie_decode_iei_length(&msg[index],&index);
+
+ dl_unitdata->pdu.data_len = iei_len;
+
+ DBG_TRACE("Decoding LLC PDU of size %d",iei_len);
+
+ byte = &msg[index];
+
+ dl_unitdata->pdu.data = (UINT8*)bssgp_util_get_rx_buff(iei_len);
+
+ memcpy(dl_unitdata->pdu.data,byte,iei_len);
+
+ index += iei_len;
+
+ *len += index;
+
+ DBG_TRACE("Decoded LLC PDU - IEI length %d bytes",iei_len);
+ HexDumper(dl_unitdata->pdu.data, iei_len);
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+
+/*
+ * bssgp_ie_decode_llc_pdu_ext
+ */
+UINT8 *
+bssgp_ie_decode_llc_pdu_ext(UINT16 *pdu_len,UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_decode_llc_pdu_ext",BSSGP_DECODER_LAYER);
+ DBG_ENTER();
+ UINT8 *byte;
+ UINT16 index = 0,iei_len;
+
+ byte = &msg[index];
+ index++;
+
+ if (*byte != BSSGP_IEI_LLC_PDU) {
+ DBG_ERROR("IEI not LLC PDU, %d type !!",*byte);
+ DBG_LEAVE();
+ return (NULL);
+ }
+
+
+ iei_len = bssgp_ie_decode_iei_length(&msg[index],&index);
+
+ *pdu_len = iei_len;
+
+ DBG_TRACE("Decoding LLC PDU of size %d",iei_len);
+
+ byte = &msg[index];
+
+ index += *pdu_len;
+
+ *len += index;
+
+ DBG_LEAVE();
+ return (byte);
+}
+
+
+
+
+
+/*
+ * bssgp_ie_decode_llc_frames_discarded
+ *
+ *----------------------------------------------------------
+ * 11.3.16 LLC Frames Discarded
+ * This element describes the number of LLC frames that
+ * have been discarded inside a BSS. The element coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3 Number of frames discarded (in hex)
+ *
+ *----------------------------------------------------------
+ *
+ */
+BOOL
+bssgp_ie_decode_llc_frames_discarded(UINT8 *frames, UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_decode_llc_frames_discarded",BSSGP_DECODER_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 index = 0,iei_len;
+
+ byte = &msg[index];
+
+ if (*byte != (UINT8)BSSGP_IEI_BSS_AREA_IND) {
+ DBG_ERROR("LLC Frames Discarded IEI Invalid!");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+ index++;
+
+ iei_len = bssgp_ie_decode_iei_length(&msg[index],&index);
+ if (iei_len != sizeof(UINT8)) {
+ DBG_ERROR("LLC Frames Discarded IEI length Invalid!");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ *frames = msg[index++];
+
+ DBG_TRACE("LLC Frames Discarded %d decoded; IEI length %d bytes",*frames,index);
+
+ *len += index;
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+
+/*
+ * bssgp_ie_decode_location_area
+ *
+ *----------------------------------------------------------
+ * 11.3.17 Location Area
+ * This element uniquely identifies one Location Area.
+ * The element coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octets 3-7 Octets 3 to 7 contain the value part
+ * (starting with octet 2) of the Location Area
+ * Identification IE defined in GSM 04.08 [11],
+ * not including GSM 04.08 IEI
+ *
+ * The coding of octet 2 is a binary number indicating the
+ * Length of the remaining element.
+ *----------------------------------------------------------
+ *
+ */
+BOOL
+bssgp_ie_decode_location_area(T_CNI_RIL3_IE_LOCATION_AREA_ID *location_area,UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_decode_location_area",BSSGP_DECODER_LAYER);
+ DBG_ENTER();
+ UINT8 *byte;
+ UINT16 lac, index = 0, iei_len;
+
+ byte = &msg[index];
+
+ if (*byte != (UINT8)BSSGP_IEI_LOCATION_AREA) {
+ DBG_ERROR("Invalid location area IEI");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ index++;
+
+
+ iei_len = bssgp_ie_decode_iei_length(&msg[index],&index);
+
+ /*
+ * From 04.08:
+ * The Location Area Identification is a type 3 information element
+ * ith 6 octets length.
+ * 8 7 6 5 4 3 2 1
+ * +-----------------------------------------------*
+ * * * *
+ * * MCC digit 2 * MCC digit 1 * octet 2
+ * +-----------------------+-----------------------*
+ * * * *
+ * * MNC digit 3 * MCC digit 3 * octet 3
+ * +-----------------------+-----------------------*
+ * * * *
+ * * MNC digit 2 * MNC digit 1 * octet 4
+ * +-----------------------------------------------*
+ * * *
+ * * LAC * octet 5
+ * +-----------------------------------------------*
+ * * *
+ * * LAC (continued) * octet 6
+ * +-----------------------------------------------+
+ *
+ */
+ location_area->mcc[0] = msg[index] & 0x0f;
+ location_area->mcc[1] = (msg[index] & 0xf0) >> 4;
+ index++;
+
+ location_area->mcc[2] = msg[index] & 0x0f;
+ location_area->mnc[2] = (msg[index] & 0xf0) >> 4;
+ index++;
+
+ location_area->mnc[0] = msg[index] & 0x0f;
+ location_area->mnc[1] = (msg[index] & 0xf0) >> 4;
+ index++;
+
+ memcpy(&lac,&msg[index],sizeof(UINT16));
+ index += sizeof(UINT16);
+ location_area->lac = htons(lac);
+ location_area->ie_present = TRUE;
+
+ DBG_TRACE("Location Area :- MCC : %d%d%d ; MNC : %d%d(%x) ; LAC : %d",
+ location_area->mcc[0],location_area->mcc[1],location_area->mcc[2],
+ location_area->mnc[0],location_area->mnc[1],location_area->mnc[2],
+ location_area->lac);
+
+ *len += index;
+ DBG_TRACE("Location area IEI length %d bytes",index);
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+
+/*
+ * bssgp_ie_decode_lsa_identifier_list
+ *
+ *----------------------------------------------------------
+ * 11.3.18 LSA Identifier List
+ * This information element uniquely identifies LSAs. The
+ * element coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3-? Rest of element coded as in GSM 08.08, not
+ * including GSM 08.08 IEI and GSM 08.08 length
+ * indicator
+ *
+ *----------------------------------------------------------
+ *
+ */
+BOOL
+bssgp_ie_decode_lsa_identifier_list(RIL3_IE_LSA_IDENTIFIER_LIST *lsa_id_list,
+ UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_decode_lsa_identifier_list",BSSGP_DECODER_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 index = 0,iei_len;
+ INT16 num_lsa_ids;
+
+ byte = &msg[index];
+
+ if (*byte != (UINT8)BSSGP_IEI_LSA_ID_LIST) {
+ DBG_ERROR("LSA Identifier List IEI Invalid!");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+ index++;
+
+ iei_len = bssgp_ie_decode_iei_length(&msg[index],&index);
+
+ num_lsa_ids = (iei_len - 1) / 3;
+
+ lsa_id_list->num_lsa_ids = num_lsa_ids;
+
+ lsa_id_list->ep = msg[index++] & 0x1;
+
+ while (num_lsa_ids)
+ {
+ lsa_id_list->lsa_id[lsa_id_list->num_lsa_ids - num_lsa_ids] =
+ (msg[index++] << 16) | (msg[index++] << 8) | msg[index++];
+ num_lsa_ids--;
+ }
+
+ DBG_TRACE("LSA Identifier List; IEI length %d bytes",index);
+
+ *len += index;
+ lsa_id_list->ie_present = TRUE;
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+
+/*
+ * bssgp_ie_decode_lsa_info
+ *
+ *----------------------------------------------------------
+ * 11.3.19 LSA Information
+ * This information element uniquely identifies LSAs, the
+ * priority of each LSA and the access right outside these
+ * LSAs. The element coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3-? Rest of element coded as in GSM 08.08, not
+ * including GSM 08.08 IEI and GSM 08.08
+ * length indicator
+ *
+ *
+ *----------------------------------------------------------
+ *
+ */
+BOOL
+bssgp_ie_decode_lsa_info(RIL3_IE_LSA_INFORMATION *lsa_info, UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_decode_lsa_info",BSSGP_DECODER_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 index = 0,iei_len;
+ INT16 num_lsas;
+
+ byte = &msg[index];
+
+ if (*byte != (UINT8)BSSGP_IEI_ALIGNMENT_OCTETS) {
+ DBG_ERROR("LSA Information IEI Invalid!");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+ index++;
+
+ iei_len = bssgp_ie_decode_iei_length(&msg[index],&index);
+
+ num_lsas = (iei_len - 1) / 4;
+
+ lsa_info->num_lsas = num_lsas;
+
+ lsa_info->lsa_only = msg[index++] & 0x1;
+
+ while (num_lsas)
+ {
+ lsa_info->lsa_ids[lsa_info->num_lsas - num_lsas].act = msg[index] & 0x20;
+ lsa_info->lsa_ids[lsa_info->num_lsas - num_lsas].pref = msg[index] & 0x10;
+ lsa_info->lsa_ids[lsa_info->num_lsas - num_lsas].priority = msg[index++] & 0x0f;
+ lsa_info->lsa_ids[lsa_info->num_lsas - num_lsas].lsa_id = (msg[index++] << 16) | (msg[index++] << 8) | msg[index++];
+ lsa_info->lsa_ids[lsa_info->num_lsas - num_lsas].present = TRUE;
+ num_lsas--;
+ }
+
+ DBG_TRACE("LSA Information; IEI length %d bytes",index);
+
+ *len += index;
+ lsa_info->ie_present = TRUE;
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+
+
+/*
+ * bssgp_ie_decode_mobile_id
+ *
+ *----------------------------------------------------------
+ * 11.3.20 Mobile Id
+ * The element coding is:
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3-n Octets 3-n contain either the IMSI, IMEISV
+ * or IMEI coded as the value part (starting
+ * with octet 3) of the Mobile Identity IE
+ * defined in GSM 04.08, not including GSM
+ * 04.08 IEI and GSM 04.08 length indcator
+ *
+ *----------------------------------------------------------
+ *
+ */
+BOOL
+bssgp_ie_decode_mobile_id(UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_decode_mobile_id",BSSGP_DECODER_LAYER);
+ DBG_ENTER();
+ /* FIXME */
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+/*
+ * bssgp_ie_decode_ms_bucket_size
+ *
+ *----------------------------------------------------------
+ * 11.3.21 MS Bucket Size
+ * This information element indicates an MS's bucket size
+ * (Bmax). The element coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3-4 Bmax
+ *
+ * The Bmax field is coded as in section GSM 08.18 BVC Bucket
+ * Size/Bmax.
+ *----------------------------------------------------------
+ *
+ */
+BOOL
+bssgp_ie_decode_ms_bucket_size(UINT16 *bmax, UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_decode_ms_bucket_size",BSSGP_DECODER_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 index = 0,iei_len;
+
+ byte = &msg[index];
+
+ if (*byte != (UINT8)BSSGP_IEI_MS_BUCKET_SIZE) {
+ DBG_ERROR("MS Bucket Size IEI Invalid!");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+ index++;
+
+ iei_len = bssgp_ie_decode_iei_length(&msg[index],&index);
+ if (iei_len != sizeof(UINT16)) {
+ DBG_ERROR("MS Bucket Size IEI length Invalid!");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ *bmax = (msg[index++] << 8) | msg[index++];
+
+ DBG_TRACE("MS Bucket Size %d decoded; IEI length %d bytes",*bmax,index);
+
+ *len += index;
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+/*
+ * bssgp_ie_decode_ms_ra_cap
+ *
+ *----------------------------------------------------------
+ * 11.3.22 MS Radio Access Capability
+ * This information element contains the capabilities of
+ * the ME. The element coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3-14 Rest of element coded as the value part
+ * defined in GSM 04.08, not including GSM
+ * 04.08 IEI and GSM 04.08 octet length
+ * indicator.
+ *
+ *----------------------------------------------------------
+ *
+ */
+BOOL
+bssgp_ie_decode_ms_ra_cap(T_CNI_RIL3_IE_MS_RADIO_ACCESS_CAPABILITY *ra_cap,UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_decode_ms_ra_cap",BSSGP_DECODER_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 index = 0,count, iei_len;
+
+ byte = &msg[index];
+ index++;
+
+ if (*byte != BSSGP_IEI_MS_RADIO_ACCESS_CAP) {
+ DBG_ERROR("Invalid MS-Radio-Access-Capabilities IEI");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+
+ iei_len = bssgp_ie_decode_iei_length(&msg[index],&index);
+
+
+
+ /*
+ * Although the spec 04.08 is pretty clear about the IE
+ * encoding, the encoding specified is quite messy &
+ * since we would be more or less dealing with ourselves,
+ * (read proprietary..snigger..) it is well worth it to
+ * rearrange the elements to pack it nicely... DSN.
+ * So packing would be as follows:-
+ *
+ * |---------------------------------------------------------------|
+ * | Number of Radio Access Capabilities | octet 1
+ * |---------------------------------------------------------------|
+ *
+ * After this, depending on above value there would be 5 octets per
+ * radio access capability packed as follows
+ *
+ * |---------------------------------------------------------------|
+ * | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
+ * |---------------------------------------------------------------|
+ * | Access Tech Type | RF Power Capabilities | octet n
+ * |---------------------------------------------------------------|
+ * | resvd | A5 Algorithms supported from 7 to 1 | octet n+1
+ * |---------------------------------------------------------------|
+ * | reserved | es | ps | vgcs | vbs | res | octet n+2
+ * |---------------------------------------------------------------|
+ * | pres | reserved | hscd multi-slot class | octet n+3
+ * |---------------------------------------------------------------|
+ * | pres | gprs multi-slot class | ExCap | pres | octet n+4
+ * |---------------------------------------------------------------|
+ * | switch measure switch value | switch measure value | octet n+5
+ * |---------------------------------------------------------------|
+ *
+ */
+
+ byte = &msg[index];
+ index++;
+ ra_cap->number_of_ra_capabilities = *byte;
+
+ if (iei_len != ((ra_cap->number_of_ra_capabilities*6*sizeof(UINT8))+sizeof(UINT8))) {
+ DBG_ERROR("MS-Radio-Access-Capability IEI length mismatch with number of capabilities, len %d, num %d",
+ iei_len,ra_cap->number_of_ra_capabilities);
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+
+ DBG_TRACE("Decoding %d number of Radio Access Capabilities",ra_cap->number_of_ra_capabilities);
+
+ for(count=0;count<ra_cap->number_of_ra_capabilities;count++) {
+ byte = &msg[index];
+ index++;
+ ra_cap->ms_ra_capability[count].rf_power_capability = (*byte & 0x07);
+ ra_cap->ms_ra_capability[count].access_technology_type =
+ (T_CNI_RIL3_ACCESS_TECHNOLOGY_TYPE)((*byte &0xf0) >> 4);
+
+ DBG_TRACE("Access Technology Type : %d, RF Power Capability %d",
+ ra_cap->ms_ra_capability[count].access_technology_type,
+ ra_cap->ms_ra_capability[count].rf_power_capability);
+
+ byte = &msg[index];
+ index++;
+ *byte = 0;
+ if (*byte & 0x01) {
+ ra_cap->ms_ra_capability[count].a5_1_algorithm = TRUE;
+ DBG_TRACE("Supports A5.1 algorithm");
+ }
+ if (*byte & 0x02) {
+ ra_cap->ms_ra_capability[count].a5_2_algorithm = TRUE;
+ DBG_TRACE("Supports A5.2 algorithm");
+ }
+ if (*byte & 0x04) {
+ ra_cap->ms_ra_capability[count].a5_3_algorithm = TRUE;
+ DBG_TRACE("Supports A5.3 algorithm");
+ }
+ if (*byte & 0x08) {
+ ra_cap->ms_ra_capability[count].a5_4_algorithm = TRUE;
+ DBG_TRACE("Supports A5.4 algorithm");
+ }
+ if (*byte & 0x10) {
+ ra_cap->ms_ra_capability[count].a5_5_algorithm = TRUE;
+ DBG_TRACE("Supports A5.5 algorithm");
+ }
+ if (*byte & 0x20) {
+ ra_cap->ms_ra_capability[count].a5_6_algorithm = TRUE;
+ DBG_TRACE("Supports A5.6 algorithm");
+ }
+ if (*byte & 0x40) {
+ ra_cap->ms_ra_capability[count].a5_7_algorithm = TRUE;
+ DBG_TRACE("Supports A5.7 algorithm");
+ }
+
+ byte = &msg[index];
+ index++;
+ *byte = 0;
+ if (*byte & 0x10) {
+ ra_cap->ms_ra_capability[count].es_ind = TRUE;
+ DBG_TRACE("ES Indicator");
+ }
+ if (*byte & 0x08) {
+ ra_cap->ms_ra_capability[count].ps = TRUE;
+ DBG_TRACE("PS");
+ }
+ if (*byte & 0x04) {
+ ra_cap->ms_ra_capability[count].vgcs = TRUE;
+ DBG_TRACE("VGCS");
+ }
+ if (*byte & 0x02) {
+ ra_cap->ms_ra_capability[count].vbs = TRUE;
+ DBG_TRACE("VBS");
+ }
+
+ ra_cap->ms_ra_capability[count].multislot_capability.present = TRUE;
+ byte = &msg[index];
+ index++;
+ ra_cap->ms_ra_capability[count].multislot_capability.hscsd_multi_slot_class = (*byte & 0x1f);
+ ra_cap->ms_ra_capability[count].multislot_capability.hscsd_param_present = (*byte >> 7);
+ if (ra_cap->ms_ra_capability[count].multislot_capability.hscsd_param_present)
+ DBG_TRACE("HSCSD Multi slot class %d",ra_cap->ms_ra_capability[count].multislot_capability.hscsd_multi_slot_class);
+ else
+ DBG_TRACE("HSCSD Multi slot class not present");
+
+ byte = &msg[index];
+ index++;
+ ra_cap->ms_ra_capability[count].multislot_capability.gprs_multi_slot_class = ((*byte >> 2) & 0x1f);
+ ra_cap->ms_ra_capability[count].multislot_capability.gprs_dynamic_allocation_capability = ((*byte >> 1) & 0x1);
+ ra_cap->ms_ra_capability[count].multislot_capability.gprs_params_present = (*byte >> 7);
+ ra_cap->ms_ra_capability[count].multislot_capability.sms_params_present = (*byte & 0x1);
+ if (ra_cap->ms_ra_capability[count].multislot_capability.gprs_params_present)
+ {
+ DBG_TRACE("GPRS Multi slot class %d",ra_cap->ms_ra_capability[count].multislot_capability.gprs_multi_slot_class);
+ DBG_TRACE("GPRS Ext dynamic allocation cap %d",ra_cap->ms_ra_capability[count].multislot_capability.gprs_dynamic_allocation_capability);
+ }
+ else
+ DBG_TRACE("GPRS Multi slot class not present");
+
+ byte = &msg[index];
+ index++;
+ ra_cap->ms_ra_capability[count].multislot_capability.switch_measure_value = (*byte & 0x0f);
+ ra_cap->ms_ra_capability[count].multislot_capability.switch_measure_switch_value = (*byte & 0xf0) >> 4;
+ if (ra_cap->ms_ra_capability[count].multislot_capability.sms_params_present)
+ DBG_TRACE("Switch measure value %d, Switch measure switch value %d",
+ ra_cap->ms_ra_capability[count].multislot_capability.switch_measure_value,
+ ra_cap->ms_ra_capability[count].multislot_capability.switch_measure_switch_value);
+ else
+ DBG_TRACE("Switch measure not present");
+ }
+
+ ra_cap->ie_present = TRUE;
+ *len += index;
+
+ DBG_TRACE("MS-Radio-Access-Capability IEI length %d bytes",index);
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+
+/*
+ * bssgp_ie_decode_omc_id
+ *
+ *----------------------------------------------------------
+ * 11.3.23 OMC Id
+ * The element coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3-22 For the OMC identity, see TS 12.20
+ *
+ *----------------------------------------------------------
+ *
+ */
+BOOL
+bssgp_ie_decode_omc_id(UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_decode_omc_id",BSSGP_DECODER_LAYER);
+ DBG_ENTER();
+
+ /* FIXME */
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+
+/*
+ * bssgp_ie_decode_pdu_in_error
+ *
+ *----------------------------------------------------------
+ * 11.3.24 PDU In Error
+ * The element coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3-? Erroneous BSSGP PDU
+ *
+ *----------------------------------------------------------
+ *
+ */
+BOOL
+bssgp_ie_decode_pdu_in_error(UINT8 *llc_pdu,UINT16 *pdu_len,UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_decode_pdu_in_error",BSSGP_DECODER_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 index = 0,iei_len;
+
+ byte = &msg[index];
+ index++;
+
+ if (*byte != BSSGP_IEI_PDU_IN_ERROR) {
+ DBG_ERROR("IEI not LLC PDU in Error, %d type !!",*byte);
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+
+ iei_len = bssgp_ie_decode_iei_length(&msg[index],&index);
+
+ *pdu_len = iei_len;
+
+ DBG_TRACE("Decoding LLC PDU in error of size %d",iei_len);
+
+ byte = &msg[index];
+
+ memcpy(llc_pdu,byte,iei_len);
+
+ index += *pdu_len;
+
+ *len += index;
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+/*
+ * bssgp_ie_decode_pdu_lifetime
+ *
+ *----------------------------------------------------------
+ * 11.3.25 PDU Lifetime
+ * This information element describes the PDU Lifetime
+ * for a PDU inside the BSS. The element coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3-4 Delay Value
+ *
+ * The Delay Value field is coded as in section GSM 08.18
+ * BVC Measurement/Delay Value.
+ *----------------------------------------------------------
+ *
+ */
+BOOL
+bssgp_ie_decode_pdu_lifetime(RIL3_IE_PDU_LIFETIME *delay, UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_decode_pdu_lifetime",BSSGP_DECODER_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 index = 0,iei_len;
+
+ byte = &msg[index];
+
+ if (*byte != (UINT8)BSSGP_IEI_PDU_LIFETIME) {
+ DBG_ERROR("PDU Lifetime IEI Invalid!");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+ index++;
+
+ iei_len = bssgp_ie_decode_iei_length(&msg[index],&index);
+ if (iei_len != sizeof(UINT16)) {
+ DBG_ERROR("PDU Lifetime IEI length Invalid!");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ delay->pdu_lifetime = (msg[index++] << 8) | msg[index++];
+
+ DBG_TRACE("PDU Lifetime %d decoded; IEI length %d bytes",delay->pdu_lifetime,index);
+
+ *len += index;
+ delay->ie_present = TRUE;
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+
+/*
+ * bssgp_ie_decode_priority
+ *
+ *----------------------------------------------------------
+ * 11.3.27 Priority
+ * This element indicates the priority of a PDU. The
+ * element coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3 Rest of element coded as the value part of
+ * the Priority IE defined in GSM 08.08, not
+ * including GSM 08.08 IEI and GSM 08.08
+ * length indicator
+ *
+ *----------------------------------------------------------
+ *
+ */
+BOOL
+bssgp_ie_decode_priority(RIL3_IE_PRIORITY *priority, UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_decode_priority",BSSGP_DECODER_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 index = 0,iei_len;
+
+ byte = &msg[index];
+
+ if (*byte != (UINT8)BSSGP_IEI_PRIORITY) {
+ DBG_ERROR("Priority IEI Invalid!");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+ index++;
+
+ iei_len = bssgp_ie_decode_iei_length(&msg[index],&index);
+ if (iei_len != sizeof(UINT8)) {
+ DBG_ERROR("Priority IEI length Invalid!");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ priority->priority = msg[index++];
+
+ DBG_TRACE("Priority %d decoded; IEI length %d bytes",priority->priority,index);
+
+ *len += index;
+ priority->ie_present = TRUE;
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+
+
+
+
+
+/*
+ * bssgp_ie_decode_qos_params
+ *
+ *----------------------------------------------------------
+ * QoS Params (Cisco-EWTBU proprietary ext)
+ * This information element describes the QoS Params
+ * associated with a PDU. The element coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3 Delay Class
+ * octet 4 Reliability Class
+ * octet 5 Precedence Class
+ * octet 6 Peak Throughput
+ * octet 7 Mean Throughput
+ *
+ *----------------------------------------------------------
+ *
+ */
+BOOL
+bssgp_ie_decode_qos_params(T_CNI_RIL3_IE_QOS *qos_params, UINT8 *msg, UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_decode_qos_params",BSSGP_DECODER_LAYER);
+ DBG_ENTER();
+ UINT8 *byte;
+ UINT16 index = 0, iei_len;
+
+ byte = &msg[index];
+ index++;
+
+ if (*byte != BSSGP_IEI_QOS_PARAMS) {
+ DBG_ERROR("Invalid QoS Params IEI");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+
+ iei_len = bssgp_ie_decode_iei_length(&msg[index],&index);
+ if (iei_len != (sizeof(UINT8)*5)) {
+ DBG_ERROR("Invalid QoS Params IEI Length, %d",iei_len);
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ /* Delay Class */
+ byte = &msg[index];
+ qos_params->delay_class = (CNI_RIL3_QOS_DELAY_CLASS)*byte;
+ index++;
+ /* Reliability class */
+ byte = &msg[index];
+ qos_params->reliability_class = (CNI_RIL3_QOS_RELIABILITY_CLASS)*byte;
+ index++;
+ /* Precedence class */
+ byte = &msg[index];
+ qos_params->precedence_class = (CNI_RIL3_QOS_PRECEDENCE_CLASS)*byte;
+ index++;
+ /* Peak throughput */
+ byte = &msg[index];
+ qos_params->peak_throughput = (CNI_RIL3_QOS_PEAK_THROUGHPUT)*byte;
+ index++;
+ /* Mean throughput */
+ byte = &msg[index];
+ qos_params->mean_throughput = (CNI_RIL3_QOS_MEAN_THROUGHPUT)*byte;
+ index++;
+
+ qos_params->ie_present = TRUE;
+ DBG_TRACE("Decoded QoS params; Delay %d, Reliability %d, Precedence %d, Peak throughput %d & Mean throughput %d",
+ qos_params->delay_class,qos_params->reliability_class,qos_params->precedence_class,
+ qos_params->peak_throughput,qos_params->mean_throughput);
+ *len += index;
+ DBG_LEAVE();
+ return (FALSE);
+}
+
+
+/*
+ * bssgp_ie_decode_qos_profile
+ *
+ *----------------------------------------------------------
+ * 11.3.28 QoS Profile
+ * This information element describes the QoS Profile
+ * associated with a PDU. The element coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3-4 Peak bit rate provided by the network,
+ * coded as the value part in Bucket Leak
+ * Rate/R IE/ GSM 08.18 a)
+ * octet 5 SPARE C/R T A Precedence
+ *
+ *----------------------------------------------------------
+ *
+ */
+BOOL
+bssgp_ie_decode_qos_profile(T_RIL3_IE_QOS_PROFILE_ID *qos_profile,UINT8 *msg,UINT16 *len, BSSGP_IEI_FORMAT format)
+{
+ DBG_FUNC("bssgp_ie_decode_qos_profile",BSSGP_DECODER_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 index = 0;
+
+ if (format == BSSGP_FORMAT_TLV)
+ {
+ UINT16 iei_len;
+
+ byte = &msg[index];
+ if (*byte != BSSGP_IEI_QOS_PROFILE) {
+ DBG_ERROR("Invalid QoS profile IEI");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ index++;
+
+ iei_len = bssgp_ie_decode_iei_length(&msg[index],&index);
+ }
+
+ qos_profile->bucket_leak_rate[0] = msg[index];
+ index++;
+ qos_profile->bucket_leak_rate[1] = msg[index];
+ index++;
+
+
+ DBG_TRACE("Bucket Leak Rate %d:%d",qos_profile->bucket_leak_rate[0],
+ qos_profile->bucket_leak_rate[1]);
+
+ byte = &msg[index];
+ qos_profile->precedence_class = (CNI_RIL3_QOS_PRECEDENCE_CLASS)(*byte & 0x07);
+
+
+ if (*byte & 0x08) {
+ qos_profile->a_bit = RADIO_INT_USES_RLC_MAX_UDT;
+ DBG_TRACE("Radio interface uses RLC/MAC-UNITDATA functionality");
+ }
+ else {
+ qos_profile->a_bit = RADIO_INT_USES_RLC_MAC_ARQ;
+ DBG_TRACE("Radio interface uses RLC/MAC ARQ functionality");
+ }
+
+ if (*byte & 0x10) {
+ qos_profile->t_bit = SDU_CONTAINS_DATA;
+ DBG_TRACE("SDU contains Data");
+ }
+ else {
+ qos_profile->t_bit = SDU_CONTAINS_SIGNALLING;
+ DBG_TRACE("SDU contains Signalling (e.g. related to GMM)");
+ }
+
+ if (*byte & 0x20) {
+ qos_profile->cr_bit = SDU_LLC_ACK_SACK_ABSENT;
+ DBG_TRACE("SDU does NOT contain a LLC ACK or SACK command/response frame type");
+ }
+ else {
+ qos_profile->cr_bit = SDU_LLC_ACK_SACK_PRESENT;
+ DBG_TRACE("SDU contains LLC ACK or SACK command/response frame type");
+ }
+ qos_profile->ie_present = TRUE;
+ index++;
+ *len += index;
+ DBG_TRACE("QoS Profile IEI length %d bytes",index);
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+
+/*
+ * bssgp_ie_decode_radio_cause
+ *
+ *----------------------------------------------------------
+ * 11.3.29 Radio Cause
+ * This information element indicates the reason for an
+ * exception condition on the radio interface. The element
+ * coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3 Radio Cause value
+ *
+ *----------------------------------------------------------
+ *
+ */
+BOOL
+bssgp_ie_decode_radio_cause(T_RIL3_IE_RADIO_CAUSE_ID *radio_cause,UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_decode_radio_cause",BSSGP_DECODER_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 index = 0,iei_len;
+
+ byte = &msg[index];
+ index++;
+
+ if (*byte != (UINT8)BSSGP_IEI_RADIO_CAUSE) {
+ DBG_ERROR("Invalid Radio Cause IEI");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+ iei_len = bssgp_ie_decode_iei_length(&msg[index],&index);
+ if (iei_len != sizeof(UINT8)) {
+ DBG_ERROR("Invalid Radio Cause IEI length; %d",iei_len);
+ DBG_LEAVE();
+ return (FALSE);
+ }
+ byte = &msg[index];
+ *radio_cause = (T_RIL3_IE_RADIO_CAUSE_ID)*byte;
+ index++;
+
+ DBG_TRACE("Decoded Radio cause : %s",
+ bssgp_util_get_radio_cause_str(*radio_cause));
+
+
+ DBG_TRACE("Radio Cause IEI length %d bytes",index);
+ *len += index;
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+/*
+ * bssgp_ie_decode_ra_cap_update_cause
+ *
+ *----------------------------------------------------------
+ * 11.3.30 RA-Cap-UPD-Cause
+ * The RA-Cap-UPD-Cause indicates the success of the
+ * RA-CAPABILITY-UPDATE procedure or the reason of the
+ * failure. The element coding is:
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3 RA-Cap-UPD Cause value
+ *
+ *----------------------------------------------------------
+ *
+ */
+BOOL
+bssgp_ie_decode_ra_cap_update_cause(RA_CAP_UPD_CAUSE *ra_cause,UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_decode_ra_cap_update_cause",BSSGP_DECODER_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 index = 0,iei_len;
+
+ byte = &msg[index];
+ index++;
+
+ if (*byte != BSSGP_IEI_RA_CAP_UPD_CAUSE) {
+ DBG_ERROR("Error in Radio-Access-Capability-Update IEI");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ iei_len = bssgp_ie_decode_iei_length(&msg[index],&index);
+ if (iei_len != sizeof(UINT8)) {
+ DBG_ERROR("Error in Radio-Access-Capability-Update IEI length, %d",iei_len);
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ byte = &msg[index];
+ *ra_cause = (RA_CAP_UPD_CAUSE)*byte;
+ index++;
+
+ DBG_TRACE("Decoded Radio-Access-Capability-Update-Cause : %s",
+ bssgp_util_get_ra_cap_cause_str(*ra_cause));
+
+
+ DBG_TRACE("Radio-Access-Capability-Update-Cause IEI length %d bytes",index);
+ *len += index;
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+/*
+ * bssgp_ie_decode_reject_cause
+ *
+ *----------------------------------------------------------
+ * Reject Cause (Cisco-EWTBU proprietary ext)
+ * This information element describes the reject cause
+ * for a Location Update Nack
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3 Reject cause
+ *
+ *----------------------------------------------------------
+ *
+ */
+BOOL
+bssgp_ie_decode_reject_cause(T_CNI_RIL3_IE_REJECT_CAUSE *reject_cause, UINT8 *msg, UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_decode_reject_cause",BSSGP_DECODER_LAYER);
+ DBG_ENTER();
+ UINT8 *byte;
+ UINT16 index = 0, iei_len;
+
+ byte = &msg[index];
+ index++;
+
+ if (*byte != BSSGP_IEI_LA_REJECT_CAUSE) {
+ DBG_ERROR("Error in LA Reject cause IEI");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+
+ iei_len = bssgp_ie_decode_iei_length(&msg[index],&index);
+ if (iei_len != sizeof(UINT8)) {
+ DBG_ERROR("Error in LA Reject cause IEI length, %d",iei_len);
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ byte = &msg[index];
+ index++;
+
+ reject_cause->causeValue = (T_CNI_RIL3_REJECT_CAUSE_VALUE)*byte;
+ reject_cause->ie_present = TRUE;
+
+ DBG_TRACE("Decoded Location Area Reject cause %d; IEI length %d",reject_cause->causeValue,index);
+ *len += index;
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+
+/*
+ * bssgp_ie_decode_routing_area
+ *
+ *----------------------------------------------------------
+ * 11.3.31 Routeing Area
+ * This element uniquely identifies one routeing area. The
+ * element coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octets 3-8 Octets 3 to 8 contain the value part
+ * (starting with octet 2) of the Routing Area
+ * Identification IE defined in GSM 04.08 [11],
+ * not including GSM 04.08 IEI
+ *
+ * The coding of octet 2 is a binary number indicating the
+ * Length of the remaining element.
+ *----------------------------------------------------------
+ *
+ */
+BOOL
+bssgp_ie_decode_routing_area(T_CNI_RIL3_IE_ROUTING_AREA_ID *routing_area,UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_decode_routing_area",BSSGP_DECODER_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 lac, index = 0, iei_len;
+
+ byte = &msg[index];
+ index++;
+
+ if (*byte != BSSGP_IEI_ROUTING_AREA) {
+ DBG_ERROR("Error in Routing Area IEI");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ iei_len = bssgp_ie_decode_iei_length(&msg[index],&index);
+ if (iei_len != (3+2+sizeof(UINT16))) {
+ DBG_ERROR("Error in Routing Area IEI length, %d",iei_len);
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ /*
+ * From 04.08:
+ *
+ * The routing area identification information element is
+ * coded as shown in figure 10.5.130/GSM 04.08 and
+ * table 10.5.148/GSM 04.08.
+ * 8 7 6 5 4 3 2 1
+ * ------------------------------
+ * * MCC digit 2 * MCC digit 1 * octet 2
+ * ------------------------------
+ * * MNC digit 3 * MCC digit 3 * octet 3
+ * ------------------------------
+ * * MNC digit 2 * MNC digit 1 * octet 4
+ * ------------------------------
+ * * LAC * octet 5
+ * ------------------------------
+ * * LAC cont'd * octet 6
+ * ------------------------------
+ * * RAC * octet 7
+ * ------------------------------
+ *
+ *
+ */
+ routing_area->mcc[0] = msg[index] & 0x0f;
+ routing_area->mcc[1] = (msg[index] & 0xf0) >> 4;
+ index++;
+
+ routing_area->mcc[2] = msg[index] & 0x0f;
+ routing_area->mnc[2] = (msg[index] & 0xf0) >> 4;
+ index++;
+
+ routing_area->mnc[0] = msg[index] & 0x0f;
+ routing_area->mnc[1] = (msg[index] & 0xf0) >> 4;
+ index++;
+
+
+ memcpy(&lac,&msg[index],sizeof(UINT16));
+ routing_area->lac = ntohs(lac);
+ index += sizeof(UINT16);
+
+ routing_area->rac = msg[index];
+ index++;
+
+ routing_area->ie_present = TRUE;
+
+ DBG_TRACE("Routing Area :- MCC : %d%d%d ; MNC : %d%d(%x) ; LAC : %d ; RAC : %d",
+ routing_area->mcc[0],routing_area->mcc[1],routing_area->mcc[2],
+ routing_area->mnc[0],routing_area->mnc[1],routing_area->mnc[2],
+ routing_area->lac,routing_area->rac);
+
+ *len += index;
+ DBG_TRACE("Routing Area IEI length %d bytes",index);
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+
+/*
+ * bssgp_ie_decode_r_def_ms
+ *
+ *----------------------------------------------------------
+ * 11.3.32 R_default_MS
+ * This information element indicates the default bucket
+ * leak rate (R) to be applied to a flow control bucket
+ * for an MS. The element coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3-4 R_default_MS value
+ *
+ * The R_default_MS field is coded as in section GSM 08.18
+ * Bucket Leak Rate /R Value.
+ *----------------------------------------------------------
+ *
+ */
+BOOL
+bssgp_ie_decode_r_def_ms(UINT16 *r_default,UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_decode_r_def_ms",BSSGP_DECODER_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 index = 0,iei_len;
+
+ byte = &msg[index];
+
+ if (*byte != (UINT8)BSSGP_IEI_BMAX_DEFAULT_MS) {
+ DBG_ERROR("R_Default_MS IEI Invalid!");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+ index++;
+
+ iei_len = bssgp_ie_decode_iei_length(&msg[index],&index);
+ if (iei_len != sizeof(UINT16)) {
+ DBG_ERROR("R_Default_MS IEI length Invalid!");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ *r_default = (msg[index++] << 8) | msg[index++];
+
+ DBG_TRACE("R_Default_MS %d decoded; IEI length %d bytes",*r_default,index);
+
+ *len += index;
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+/*
+ * bssgp_ie_decode_suspend_ref_num
+ *
+ *----------------------------------------------------------
+ * 11.3.33 Suspend Reference Number
+ * The Suspend Reference Number information element
+ * contains an un-formatted reference number for each
+ * suspend/resume transaction. The element coding is:
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3 Suspend Reference Number
+ *
+ * The Suspend Reference Number is an un-formatted 8 bit
+ * field.
+ *----------------------------------------------------------
+ *
+ */
+BOOL
+bssgp_ie_decode_suspend_ref_num(UINT8 *suspend_ref_num,UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_decode_suspend_ref_num",BSSGP_DECODER_LAYER);
+ DBG_ENTER();
+ UINT8 *byte;
+ UINT16 index = 0,iei_len;
+
+ byte = &msg[index];
+ index++;
+
+ if (*byte != BSSGP_IEI_SUSPEND_REF_NUM) {
+ DBG_ERROR("Invalid Suspend Ref number IEI");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ iei_len = bssgp_ie_decode_iei_length(&msg[index],&index);
+ if (iei_len != sizeof(UINT8)) {
+ DBG_ERROR("Invalid Suspend Ref number IEI length");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ byte = &msg[index];
+ index++;
+
+ *suspend_ref_num = *byte;
+
+ DBG_TRACE("Decoded Suspend Reference Number as %d; IEI length %d bytes",suspend_ref_num,index);
+
+ *len += index;
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+
+/*
+ * bssgp_ie_decode_tag
+ *
+ *----------------------------------------------------------
+ * 11.3.34 Tag
+ * This information element is used to correlate request
+ * and response PDUs. The element coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3 Unstructured value
+ *
+ *----------------------------------------------------------
+ *
+ */
+BOOL
+bssgp_ie_decode_tag(UINT8 *tag,UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_decode_tag",BSSGP_DECODER_LAYER);
+ DBG_ENTER();
+ UINT8 *byte;
+ UINT16 index = 0,iei_len;
+
+ byte = &msg[index];
+ index++;
+
+ if (*byte != BSSGP_IEI_TAG) {
+ DBG_ERROR("Error in TAG IEI");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ iei_len = bssgp_ie_decode_iei_length(&msg[index],&index);
+ if (iei_len != sizeof(UINT8)) {
+ DBG_ERROR("TAG IEI length invalid; %d value",iei_len);
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ byte = &msg[index];
+ index++;
+
+ *tag = *byte;
+
+ DBG_TRACE("Decoded tag as %d; IEI length %d bytes",*tag,index);
+
+ *len += index;
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+/*
+ * bssgp_ie_decode_tlli
+ *
+ *----------------------------------------------------------
+ * 11.3.35 Temporary logical link Identity (TLLI)
+ * The element coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3-6 Rest of element coded as the value part of
+ * the TLLI information element in GSM 04.08,
+ * not including GSM 04.08 IEI.
+ *
+ *----------------------------------------------------------
+ *
+ */
+BOOL
+bssgp_ie_decode_tlli(RIL3_TLLI *tlli,UINT8 *msg,UINT16 *len, BSSGP_IEI_FORMAT format)
+{
+ DBG_FUNC("bssgp_ie_decode_tlli",BSSGP_DECODER_LAYER);
+ DBG_ENTER();
+
+ UINT16 index = 0;
+ UINT32 *shorty;
+
+ if (format == BSSGP_FORMAT_TLV)
+ {
+ UINT8 *byte;
+ UINT16 iei_len;
+
+ byte = &msg[index];
+ index++;
+
+ if (*byte != BSSGP_IEI_TLLI) {
+ DBG_ERROR("TLLI IEI invalid");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ iei_len = bssgp_ie_decode_iei_length(&msg[index],&index);
+ if (iei_len != sizeof(TLLI)) {
+ DBG_ERROR("TLLI IEI length invalid, %d",iei_len);
+ DBG_LEAVE();
+ return (FALSE);
+ }
+ }
+ shorty= (UINT32*)&msg[index];
+
+ /* now we get shorty ;-) */
+ tlli->tlli = ntohl(*shorty);
+ index += sizeof(UINT32);
+
+ *len += index;
+ tlli->ie_present = TRUE;
+
+ DBG_TRACE("Decoded TLLI %#x; IEI length %d bytes",tlli->tlli,index);
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+/*
+ * bssgp_ie_decode_tmsi
+ *
+ *----------------------------------------------------------
+ * 11.3.36 Temporary Mobile Subscriber Identity (TMSI)
+ * The element coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3-6 Rest of element coded as the value part of
+ * the TMSI/P-TMSI information element in
+ * GSM 04.08, not including GSM 04.08 IEI.
+ *
+ *----------------------------------------------------------
+ *
+ */
+BOOL
+bssgp_ie_decode_tmsi(T_CNI_RIL3_IE_MOBILE_ID *tmsi,UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_decode_tmsi",BSSGP_DECODER_LAYER);
+ DBG_ENTER();
+
+
+ UINT8 *byte;
+ unsigned long tmsi_val;
+ UINT16 index = 0,iei_len;
+
+ byte = &msg[index];
+ index++;
+
+ if (*byte != BSSGP_IEI_TMSI) {
+ DBG_ERROR("Error in TMSI IEI, invalid IEI type");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+
+ iei_len = bssgp_ie_decode_iei_length(&msg[index],&index);
+ if (iei_len != sizeof(unsigned long)) {
+ DBG_ERROR("IEI length invalid for TMSI IEI; %d",iei_len);
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ /*
+ * Refer to GSM 04.08; the IEI has the following
+ * structure
+ * 8 7 6 5 4 3 2 1
+ * +-----------------------------------------------+
+ * * TMSI/P-TMSI value * octet 2
+ * +-----------------------------------------------*
+ * * * octet 3
+ * * TMSI/P-TMSI value (contd) *
+ * +-----------------------------------------------*
+ * * * octet 4
+ * * TMSI/P-TMSI value (contd *
+ *+-----------------------------------------------*
+ * * * octet 5
+ * * TMSI/P-TMSI value (contd) *
+ * +-----------------------------------------------+
+ *
+ */
+
+ byte = &msg[index];
+ memcpy(&tmsi_val,byte,sizeof(unsigned long));
+ index += sizeof(unsigned long);
+
+ tmsi->tmsi = ntohl(tmsi_val);
+
+
+ tmsi->ie_present = TRUE;
+ tmsi->mobileIdType = CNI_RIL3_TMSI;
+
+ *len += index;
+ DBG_TRACE("Decoded TMSI : %ld; IEI length %d bytes",tmsi->tmsi,index);
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+/*
+ * bssgp_ie_decode_trace_ref
+ *
+ *----------------------------------------------------------
+ * 11.3.37 Trace Reference
+ * This element provides a trace reference number allocated
+ * by the triggering entity. The element coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3-4 Trace Reference
+ *
+ *----------------------------------------------------------
+ *
+ */
+BOOL
+bssgp_ie_decode_trace_ref(UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_decode_trace_ref",BSSGP_DECODER_LAYER);
+ DBG_ENTER();
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+/*
+ * bssgp_ie_decode_trace_type
+ *
+ *----------------------------------------------------------
+ * 11.3.38 Trace Type
+ * This element provides the type of trace information to
+ * be recorded. The element coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3 This is coded as specified in Technical
+ * Specification GSM 12.08.
+ *
+ *----------------------------------------------------------
+ *
+ */
+BOOL
+bssgp_ie_decode_trace_type(UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_decode_trace_type",BSSGP_DECODER_LAYER);
+ DBG_ENTER();
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+/*
+ * bssgp_ie_decode_txn_id
+ *
+ *----------------------------------------------------------
+ * 11.3.39 TransactionId
+ * This element indicates a particular transaction within
+ * a trace. The element coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3-4 Transaction Id
+ *
+ *----------------------------------------------------------
+ *
+ */
+BOOL
+bssgp_ie_decode_txn_id(UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("",BSSGP_DECODER_LAYER);
+ DBG_ENTER();
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+/*
+ * bssgp_ie_decode_trigger_id
+ *
+ *----------------------------------------------------------
+ * 11.3.40 Trigger Id
+ * This element provides the identity of the entity which
+ * initiated the trace. The element coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3-22 Entity Identity ( typically an OMC identity)
+ *
+ *----------------------------------------------------------
+ *
+ */
+BOOL
+bssgp_ie_decode_trigger_id(UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_decode_trigger_id",BSSGP_DECODER_LAYER);
+ DBG_ENTER();
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+/*
+ * bssgp_ie_decode_num_octets_affected
+ *
+ *----------------------------------------------------------
+ * 11.3.41 Number of octets affected
+ * This information element indicates, for an MS, the num
+ * of octets transferred or deleted by BSS. The element
+ * coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3-5 number of octets transferred or deleted
+ *
+ * The number of octets transferred or deleted by the BSS
+ * may be higher than the maximum Bmax value (6553500).
+ * SGSN shall handle any value higher than 6553500 as the
+ * value 6553500.
+ *
+ *----------------------------------------------------------
+ * */
+BOOL
+bssgp_ie_decode_num_octets_affected(UINT32 *num, UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_decode_num_octets_affected",BSSGP_DECODER_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 index = 0,iei_len;
+
+ byte = &msg[index];
+
+ if (*byte != (UINT8)BSSGP_IEI_NUM_OCTETS_AFFECTED) {
+ DBG_ERROR("Number of octets affected IEI Invalid!");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+ index++;
+
+ iei_len = bssgp_ie_decode_iei_length(&msg[index],&index);
+ if (iei_len != 3) {
+ DBG_ERROR("Number of octets affected length Invalid!");
+ DBG_LEAVE();
+ return (FALSE);
+ }
+
+ *num = (msg[index++] << 16) | (msg[index++] << 8) | msg[index++];
+
+ DBG_TRACE("Number of octets affected %d decoded; IEI length %d bytes",*num,index);
+
+ *len += index;
+
+ DBG_LEAVE();
+ return (TRUE);
+}
+
+
+
+
+/*
+ * bssgp_ie_decode_iei_length
+ *
+ *----------------------------------------------------------
+ * The length indicator shall be included in all
+ * information elements having the TLV format.
+ * Information elements may be variable in length.
+ * The length indicator is one or two octet long, the
+ * second octet may be absent. This field consists of the
+ * field extension bit, 0/1 ext, and the length of the value
+ * field which follows, expressed in octets. The field
+ * extension bit enables extension of the length indicator
+ * to two octets.
+ * Bit 8 of the first octet is reserved for the field
+ * extension bit. If the field extension bit is set to 0
+ * (zero), then the second octet of the length indicator is
+ * present. If the field extension bit is set to 1 (one),
+ * then the first octet is the final octet of the length
+ * indicator.
+ * The length of the value field of the IE occupies the rest
+ * of the bits in the length indicator.
+ *
+ * 8 7 6 5 4 3 2 1
+ * octet 2 0/1 ext length
+ * octet 2a length
+ *
+ * Figure 10/GSM 08.16: Length indicator structure
+ * The BSS or SGSN shall not consider the presence of octet
+ * 2a in a received IE as an error when the IE is short
+ * enough for the length to be coded in octet 2 only.
+ *
+ *----------------------------------------------------------
+ *
+ */
+UINT16
+bssgp_ie_decode_iei_length(UINT8 *msg,UINT16 *msg_len)
+{
+ DBG_FUNC("bssgp_ie_decode_iei_length",BSSGP_DECODER_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte = msg, lo,hi;
+ UINT16 iei_len=0;
+
+ if (*byte & 0x80) {
+ iei_len = *byte & 0x7f;
+ *msg_len += 1;
+ DBG_LEAVE();
+ return (iei_len);
+ }
+ lo = (*byte & 0x7f);
+
+ byte =(UINT8*)&msg[1];
+
+ hi = *byte;
+
+ iei_len = (hi * 128) + lo;
+
+ DBG_TRACE("IEI length octet 1 %d octet 2 %d, total %d",lo,hi,iei_len);
+ *msg_len += 2;
+
+ DBG_LEAVE();
+ return (iei_len);
+}
+
+
+void HexDumper(UINT8 *buffer, int length )
+{
+ int size;
+ int i;
+ int dwPos = 0;
+ static char line[255];
+ int pos;
+
+ DBG_FUNC("HexDumper", BSSGP_DECODER_LAYER);
+ DBG_ENTER();
+
+ while (length > 0)
+ {
+ //
+ // Take min of 16 or length
+ //
+ size = min(16, length );
+ //
+ // Build text line
+ //
+ pos = sprintf(line, " %04X ", dwPos );
+ for (i = 0; i < size; i++)
+ {
+ pos += sprintf(line+pos, "%02X ", buffer[i] );
+ }
+ //
+ // Add spaces for short lines
+ //
+ while (i < 16)
+ {
+ pos += sprintf(line+pos, " " );
+ i++;
+ }
+ //
+ // Add ASCII chars
+ //
+ for (i = 0; i < size; i++)
+ {
+ if (isprint(buffer[i]))
+ {
+ pos += sprintf(line+pos, "%c", buffer[i] );
+ } else {
+ pos += sprintf(line+pos, "." );
+ }
+ }
+
+ DBG_TRACE((line));
+
+ //
+ // Advance positions
+ //
+
+ length -= size;
+ dwPos += size;
+ buffer += size;
+ }
+ DBG_LEAVE();
+}
+
+
+
+
diff --git a/data/mnet/Common/bssgp/src/bssgp_ie_encoder.cpp b/data/mnet/Common/bssgp/src/bssgp_ie_encoder.cpp
new file mode 100644
index 0000000..b80cbdd
--- /dev/null
+++ b/data/mnet/Common/bssgp/src/bssgp_ie_encoder.cpp
@@ -0,0 +1,2295 @@
+/*
+ ****************************************************************************************
+ * *
+ * Copyright Cisco Systems, Inc 2000 All rights reserved *
+ * *
+ * File : bssgp_ie_encoder.cpp *
+ * *
+ * Description : Functions for encoding all the individual IE indicators *
+ * *
+ * Author : Dinesh Nambisan *
+ * *
+ *--------------------------- Notes ----------------------------------------------------*
+ * References are to sections numbers of the BSSGP spec. (GSM 08.18) unless otherwise *
+ * indicated *
+ *----------------------- Revision history ---------------------------------------------*
+ * Time | Date | Name | Description *
+ *--------------------------------------------------------------------------------------*
+ * 00:00 |10/10/00 | DSN | File created *
+ * | | | *
+ ****************************************************************************************
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include "bssgp/bssgp_prot.h"
+#include "bssgp/bssgp_util.h"
+#include "bssgp/bssgp_ie_encoder.h"
+
+
+/*
+ * bssgp_ie_alignment_octets
+ *
+ *----------------------------------------------------------
+ * 11.3.1 Alignment Octets
+ *
+ * The Alignment Octets are used to align a subsequent IEI
+ * onto a 32 bit boundary.
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3-5 spare octet
+ *
+ *----------------------------------------------------------
+ *
+ */
+void
+bssgp_ie_encode_alignment_octets(UINT8 count,UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_encode_alignment_octets",BSSGP_ENCODER_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 index = 0;
+
+ byte = &msg[index];
+
+ *byte = (UINT8)BSSGP_IEI_ALIGNMENT_OCTETS;
+ index++;
+ DBG_TRACE("Encoding %d Alignment Octets\n", count);
+
+ bssgp_ie_encode_iei_length(count,&msg[index],&index);
+
+ index+=count;
+
+ DBG_TRACE("Alignemnt Octets IEI length %d bytes",index);
+ *len += index;
+
+ DBG_LEAVE();
+ return;
+}
+
+
+/*
+ * bssgp_ie_encode_bmax_def_ms
+ *
+ *----------------------------------------------------------
+ * 11.3.2 Bmax default MS
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3-4 Bmax
+ *
+ * The Bmax field is coded as in section GSM 08.18
+ * BVC Bucket Size/Bmax.
+ *
+ *----------------------------------------------------------
+ *
+ */
+void
+bssgp_ie_encode_bmax_def_ms(UINT16 bmax,UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_encode_bmax_def_ms",BSSGP_ENCODER_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 index = 0;
+
+ byte = &msg[index];
+
+ *byte = (UINT8)BSSGP_IEI_BMAX_DEFAULT_MS;
+ index++;
+ DBG_TRACE("Encoding Bmax default MS IE.");
+
+ bssgp_ie_encode_iei_length(sizeof(UINT16),&msg[index],&index);
+
+ msg[index++] = (UINT8)(bmax >> 8);
+ msg[index++] = (UINT8)(bmax);
+
+ DBG_TRACE("Bmax default MS IE length %d bytes",index);
+ *len += index;
+
+ DBG_LEAVE();
+ return;
+}
+
+
+
+/*
+ * bssgp_ie_encode_bss_area_ind
+ *
+ *----------------------------------------------------------
+ * 11.3.3 BSS Area Indication
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3 BSS indicator
+ *
+ * The coding of octet 2 is a binary number indicating
+ * the Length of the remaining element.
+ * The coding of octet 3 shall not be specified. The
+ * recipient shall ignore the value of this octet.
+ *----------------------------------------------------------
+ *
+ */
+void
+bssgp_ie_encode_bss_area_ind(RIL3_BSS_AREA_INDICATION bss_area,
+ UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_encode_bss_area_ind",BSSGP_ENCODER_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 index = 0;
+
+ byte = &msg[index];
+
+ *byte = (UINT8)BSSGP_IEI_BSS_AREA_IND;
+ index++;
+ DBG_TRACE("Encoding BSS Area Indication IE.");
+
+ bssgp_ie_encode_iei_length(sizeof(UINT8),&msg[index],&index);
+
+ /* Just skip the actual value as it is ignored. */
+ index++;
+
+ DBG_TRACE("BSS Area Indication IE length %d bytes",index);
+ *len += index;
+
+ DBG_LEAVE();
+ return;
+}
+
+
+
+/*
+ * bssgp_ie_encode_bucket_leak_rate
+ *
+ *----------------------------------------------------------
+ * 11.3.4 Bucket Leak Rate (R)
+ * This information element indicates the leak rate (R)
+ * to be applied to a flow control bucket.
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3 R Value (MSB)
+ * octet 4 R Value (LSB)
+ *
+ * The R field is the binary encoding of the rate
+ * information expressed in 100 bits/sec increments,
+ * starting from 0 x 100 bits/sec until 65535 x 100
+ * bits/sec (6 Mbps).
+ *----------------------------------------------------------
+ *
+ */
+void
+bssgp_ie_encode_bucket_leak_rate(UINT16 leak_rate,UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_encode_bucket_leak_rate",BSSGP_ENCODER_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 index = 0;
+
+ byte = &msg[index];
+
+ *byte = (UINT8)BSSGP_IEI_BUCKET_LEAK_RATE;
+ index++;
+ DBG_TRACE("Encoding Bucket leak rate IE.");
+
+ bssgp_ie_encode_iei_length(sizeof(UINT16),&msg[index],&index);
+
+ msg[index++] = (UINT8)(leak_rate >> 8);
+ msg[index++] = (UINT8)(leak_rate);
+
+ DBG_TRACE("Bucket leak rate IE length %d bytes",index);
+ *len += index;
+
+ DBG_LEAVE();
+ return;
+}
+
+
+
+
+/*
+ * bssgp_ie_encode_bvc_bucket_size
+ *
+ *----------------------------------------------------------
+ * 11.3.5 BVC Bucket Size
+ * This information element indicates the maximum bucket
+ * size (Bmax) in octets for a BVC.
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3 Bmax (MSB)
+ * octet 4 Bmax (LSB)
+ *
+ * The Bmax field is the binary encoding of the bucket
+ * size information expressed in 100 octet increments,
+ * starting from 0 x 100 octets until 65535 x 100 octets
+ * (6 Mbytes).
+ *----------------------------------------------------------
+ *
+ */
+void
+bssgp_ie_encode_bvc_bucket_size(UINT16 bucket_size,UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_encode_bvc_bucket_size",BSSGP_ENCODER_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 index = 0;
+
+ byte = &msg[index];
+
+ *byte = (UINT8)BSSGP_IEI_BVC_BUCKET_SIZE;
+ index++;
+ DBG_TRACE("Encoding BVC Bucket size IE.");
+
+ bssgp_ie_encode_iei_length(sizeof(UINT16),&msg[index],&index);
+
+ msg[index++] = (UINT8)(bucket_size >> 8);
+ msg[index++] = (UINT8)(bucket_size);
+
+ DBG_TRACE("BVC Bucket size IE length %d bytes",index);
+ *len += index;
+
+ DBG_LEAVE();
+ return;
+}
+
+
+
+/*
+ * bssgp_ie_encode_bvci
+ *
+ *----------------------------------------------------------
+ * 11.3.6 BVCI (BSSGP Virtual Connection Identifier)
+ * The BVCI identifies a BVC. The element coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3-4 Unstructured value
+ *
+ *----------------------------------------------------------
+ *
+ */
+void
+bssgp_ie_encode_bvci(RIL3_BVCI bvci,UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_encode_bvci",BSSGP_ENCODER_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 *shorty;
+ UINT16 index = 0;
+
+ byte = &msg[index];
+
+ *byte = (UINT8)BSSGP_IEI_BVCI;
+ index++;
+
+ bssgp_ie_encode_iei_length(sizeof(UINT16),&msg[index],&index);
+
+ shorty = (UINT16*)&msg[index];
+ /* now we get shorty ;-) */
+ *shorty = htons(bvci.bvci);
+ memcpy(&msg[index],shorty,sizeof(UINT16));
+ index += 2;
+
+ DBG_TRACE("BVCI %d encoded; IEI length %d bytes",bvci.bvci,index);
+
+ *len += index;
+
+ DBG_LEAVE();
+ return;
+}
+
+/*
+ * bssgp_ie_encode_bvc_measurement
+ *
+ *----------------------------------------------------------
+ * 11.3.7 BVC Measurement
+ * This information element describes average queuing
+ * delay for a BVC. The element coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3,4 Delay Value (in centi-seconds)
+ *
+ * The Delay Value field is coded as a 16-bit integer
+ * value in units of centi-seconds (one hundredth of a
+ * second). This coding provides a range of over 10 minutes
+ * in increments of 10 msec. As a special case, the
+ * hexadecimal value 0xFFFF (decimal 65535) shall be
+ * interpreted as "infinite delay".
+ *----------------------------------------------------------
+ *
+ */
+void
+bssgp_ie_encode_bvc_measurement(RIL3_BVC_MEASUREMENT bvc_meas,UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_encode_bvc_measurement",BSSGP_ENCODER_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 index = 0;
+
+ byte = &msg[index];
+
+ *byte = (UINT8)BSSGP_IEI_BVC_MEASUREMENT;
+ index++;
+ DBG_TRACE("Encoding BVC measurement IE.");
+
+ bssgp_ie_encode_iei_length(sizeof(UINT16),&msg[index],&index);
+
+ msg[index++] = (UINT8)(bvc_meas.bvc_meas >> 8);
+ msg[index++] = (UINT8)(bvc_meas.bvc_meas);
+
+ DBG_TRACE("BVC measurement IE length %d bytes",index);
+ *len += index;
+
+ DBG_LEAVE();
+ return;
+}
+
+
+/*
+ * bssgp_ie_encode_cause
+ *
+ *----------------------------------------------------------
+ * 11.3.8 Cause
+ * The Cause information element indicates the reason for
+ * an exception condition. The element coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3 Cause value
+ *
+ *----------------------------------------------------------
+ *
+ */
+void
+bssgp_ie_encode_exception_cause(RIL3_BSSGP_CAUSE cause,UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_encode_cause",BSSGP_ENCODER_LAYER);
+ DBG_ENTER();
+ UINT8 *byte;
+ UINT16 index = 0;
+
+ byte = &msg[index];
+
+ *byte = (UINT8)BSSGP_IEI_CAUSE;
+ index++;
+
+ bssgp_ie_encode_iei_length(sizeof(UINT8),&msg[index],&index);
+
+ byte = &msg[index];
+ *byte = (UINT8)cause.cause;
+ index++;
+
+ DBG_TRACE("Cause value %s encoded; IEI length %d bytes",
+ bssgp_util_get_exception_cause_str((BSSGP_EXCEPTION_CAUSE)cause.cause),
+ index);
+
+ *len += index;
+
+ DBG_LEAVE();
+ return;
+}
+
+/*
+ * bssgp_ie_encode_cell_id
+ *
+ *----------------------------------------------------------
+ * 11.3.9 Cell Identifier
+ * This information element uniquely identifies one cell.
+ * The element coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octets 3-8 Octets 3 to 8 contain the value part
+ * (starting with octet 2) of the Routing Area
+ * Identification IE defined in GSM 04.08
+ * [11], not including GSM 04.08 IEI
+ * octets 9-10 Octets 9 and 10 contain the value part
+ * (starting with octet 2) of the Cell
+ * Identity IE defined in GSM 04.08 [11],
+ * not including GSM 04.08 IEI
+ *
+ *----------------------------------------------------------
+ *
+ */
+void
+bssgp_ie_encode_cell_id(RIL3_IE_CELL_IDENTIFIER cell_id,UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_encode_cell_id",BSSGP_ENCODER_LAYER);
+ DBG_ENTER();
+ UINT8 *byte;
+ UINT16 index = 0, *shorty, lac;
+
+ byte = &msg[index];
+
+ *byte = (UINT8)BSSGP_IEI_CELL_ID;
+ index++;
+
+ bssgp_ie_encode_iei_length(8,&msg[index],&index);
+
+ /*
+ * From 04.08:
+ *
+ * The routing area identification information element is
+ * coded as shown in figure 10.5.130/GSM 04.08 and
+ * table 10.5.148/GSM 04.08.
+ * 8 7 6 5 4 3 2 1
+ * ------------------------------
+ * * MCC digit 2 * MCC digit 1 * octet 2
+ * ------------------------------
+ * * MNC digit 3 * MCC digit 3 * octet 3
+ * ------------------------------
+ * * MNC digit 2 * MNC digit 1 * octet 4
+ * ------------------------------
+ * * LAC * octet 5
+ * ------------------------------
+ * * LAC cont'd * octet 6
+ * ------------------------------
+ * * RAC * octet 7
+ * ------------------------------
+ *
+ *
+ */
+
+ msg[index] = (cell_id.routing_area.mcc[1] << 4) | cell_id.routing_area.mcc[0] ;
+ index++;
+ msg[index] = (cell_id.routing_area.mnc[2] << 4) | cell_id.routing_area.mcc[2];
+ index++;
+ msg[index] = (cell_id.routing_area.mnc[1] << 4) | cell_id.routing_area.mnc[0];
+ index++;
+
+ lac = htons(cell_id.routing_area.lac);
+
+ memcpy(&msg[index],&lac,sizeof(UINT16));
+ index += sizeof(UINT16);
+
+ msg[index] = cell_id.routing_area.rac;
+ index++;
+
+ shorty = (UINT16*)&msg[index];
+ *shorty = (UINT16)htons(cell_id.cell_id.value);
+ index += sizeof(UINT16);
+
+ DBG_TRACE("Cell Identifier :- MCC : %d%d%d ; MNC : %d%d(%x) ; LAC : %d ; RAC : %d\n"
+ "\tCell Identity : %d",
+ cell_id.routing_area.mcc[0],cell_id.routing_area.mcc[1],cell_id.routing_area.mcc[2],
+ cell_id.routing_area.mnc[0],cell_id.routing_area.mnc[1],cell_id.routing_area.mnc[2],
+ cell_id.routing_area.lac,cell_id.routing_area.rac,cell_id.cell_id.value);
+
+ DBG_TRACE("Cell Identifier IE length %d bytes", index);
+
+ *len += index;
+
+
+ DBG_LEAVE();
+ return;
+}
+
+
+/*
+ * bssgp_ie_encode_channel_needed
+ *
+ *----------------------------------------------------------
+ * 11.3.10 Channel needed
+ * This information element is coded as defined in
+ * GSM 09.18. It is relevant to circuit-switched paging
+ * requests. The element coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3 Rest of element coded as the value part of
+ * the Channel Needed PDU defined in GSM 09.18,
+ * not including GSM 09.18 IEI and GSM 09.18
+ * length indicator
+ *
+ *----------------------------------------------------------
+ *
+ */
+void
+bssgp_ie_encode_channel_needed(UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_encode_channel_needed",BSSGP_ENCODER_LAYER);
+ DBG_ENTER();
+ /* FIXME */
+
+ DBG_LEAVE();
+ return;
+}
+
+/*
+ * bssgp_ie_encode_drx_params
+ *
+ *----------------------------------------------------------
+ * 11.3.11 DRX Parameters
+ * This information element contains MS specific DRX
+ * information. The element coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3-n Rest of element coded as the value part
+ * defined in GSM 04.08, not including GSM
+ * 04.08 IEI and GSM 04.08 octet length
+ * indicator
+ *
+ *----------------------------------------------------------
+ *
+ */
+void
+bssgp_ie_encode_drx_params(T_CNI_RIL3_IE_DRX_PARAMETER drx_params,UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_encode_drx_params",BSSGP_ENCODER_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 index = 0;
+
+ byte = &msg[index];
+
+ *byte = (UINT8)BSSGP_IEI_DRX_PARAMS;
+ index++;
+
+ bssgp_ie_encode_iei_length((sizeof(UINT8)*2),&msg[index],&index);
+
+ /*
+ *
+ * The value part of a DRX parameter information element
+ * is coded as shown in table 10.5.139/GSM 04.08.
+ * ------------------------------
+ * 8 7 6 5 | 4 | 3 2 1
+ * ------------------------------
+ * SPLIT PG CYCLE CODE octet 2
+ * ------------------------------
+ * 0 0 0 0 | SPL| non-DRXtimer octet 3
+ * ------------------------------
+ *
+ */
+
+ byte = &msg[index];
+ *byte = drx_params.split_pg_cycle_code;
+ index++;
+
+
+ byte = &msg[index];
+ if (drx_params.split_on_CCCH) {
+ *byte = 0x80 | drx_params.non_drx_timer;
+ DBG_TRACE("Encoding DRX params :- Split PG cycle code %d ; Split on CCCH ; Non-DRX timer %d",
+ drx_params.split_pg_cycle_code,drx_params.non_drx_timer);
+ }
+ else {
+ *byte = drx_params.non_drx_timer;
+ DBG_TRACE("Encoding DRX params :- Split PG cycle code %d ; Non-DRX timer %d",
+ drx_params.split_pg_cycle_code,drx_params.non_drx_timer);
+ }
+ index++;
+
+ *len += index;
+ DBG_TRACE("DRX Params IEI length %d bytes",index);
+ DBG_LEAVE();
+ return;
+}
+
+/*
+ * bssgp_ie_encode_emlpp_priority
+ *
+ *----------------------------------------------------------
+ * 11.3.12 eMLPP-Priority
+ * This element indicates the eMLPP-Priority of a PDU.
+ * The element coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3 Rest of element coded as the value part of
+ * the eMLPP-Priority IE defined in GSM 08.08,
+ * not including GSM 08.08 IEI and GSM 08.08
+ * length indicator
+ *
+ *----------------------------------------------------------
+ *
+ */
+void
+bssgp_ie_encode_emlpp_priority(UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_encode_emlpp_priority",BSSGP_ENCODER_LAYER);
+ DBG_ENTER();
+ /* FIXME */
+
+ DBG_LEAVE();
+ return;
+}
+
+/*
+ * bssgp_ie_encode_flush_action
+ *
+ *----------------------------------------------------------
+ * 11.3.13 Flush Action
+ * The Flush action information element indicates to the
+ * SGSN the action taken by the BSS in response to the
+ * flush request. The element coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3 Action value
+ *
+ * Table 11.16: Action coding
+ * Action value semantics of coding
+ *
+ * Hexadecimal
+ *
+ * x00 LLC-PDU(s) deleted
+ * x01 LLC-PDU(s) transferred
+ *
+ * All values not explicitly shown are reserved for
+ * future use
+ *
+ *----------------------------------------------------------
+ */
+void
+bssgp_ie_encode_flush_action(BSSGP_FLUSH_ACTION flush_action,UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_encode_flush_action",BSSGP_ENCODER_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 index = 0;
+
+ byte = &msg[index];
+
+ *byte = (UINT8)BSSGP_IEI_FLUSH_ACTION;
+ index++;
+ DBG_TRACE("Encoding Flush action IE.");
+
+ bssgp_ie_encode_iei_length(sizeof(UINT8),&msg[index],&index);
+
+ msg[index++] = (UINT8) flush_action;
+
+ DBG_TRACE("Flush action IE length %d bytes",index);
+ *len += index;
+
+ DBG_LEAVE();
+ return;
+}
+
+/*
+ * bssgp_ie_encode_imsi
+ *
+ *----------------------------------------------------------
+ * 11.3.14 IMSI
+ * This information element contains the International
+ * Mobile Subscriber Identity. The element coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator = length of remaining stuff
+ * octet 3-n Octets 3-n contain an IMSI coded as the
+ * value part (starting with octet 3) of the
+ * Mobile Identity IE defined in GSM 04.08,
+ * not including GSM 04.08 IEI and GSM 04.08
+ * length indicator
+ *
+ *----------------------------------------------------------
+ */
+void
+bssgp_ie_encode_imsi(T_CNI_RIL3_IE_MOBILE_ID imsi,UINT8 *msg,UINT16 *msg_len)
+{
+ DBG_FUNC("bssgp_ie_encode_imsi",BSSGP_ENCODER_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ div_t val;
+ int count;
+ UINT16 index = 0;
+ char disp_buff[128], temp_buff[10];
+ byte = &msg[index];
+
+ *byte = (UINT8)BSSGP_IEI_IMSI;
+ index++;
+
+ val = div(imsi.numDigits,2);
+
+ bssgp_ie_encode_iei_length((val.quot+1),&msg[index],&index);
+ /*
+ * Refer to GSM 04.08; the IEI has the following
+ * structure; but this octet would be the first
+ * for us
+ * +-----------------------------------------------*
+ * * *odd/ * *
+ * * Identity digit 1 *even * Type of identity* octet 3
+ * * *indic* *
+ * +-----------------------+-----------------------*
+ */
+
+ byte = &msg[index];
+ if (val.rem) {
+ /* Odd num of digits */
+ *byte = (0x08 | CNI_RIL3_IMSI);
+ }
+ else {
+ /* Even num of digits */
+ *byte = CNI_RIL3_IMSI;
+ }
+ memset(disp_buff,0,128);
+ sprintf(disp_buff,"%d",imsi.digits[0]);
+ /* Now encode the first digit */
+ *byte |= (imsi.digits[0] << 4) ;
+ index++;
+ for(count=1;count<=(imsi.numDigits-2);count=count+2) {
+ byte = &msg[index];
+ *byte = (imsi.digits[count]) | (imsi.digits[count+1] << 4);
+ index++;
+ memset(temp_buff,0,10);
+ sprintf(temp_buff,"%d%d",imsi.digits[count],imsi.digits[count+1]);
+ strcat(disp_buff,temp_buff);
+ }
+ if (count < imsi.numDigits) {
+ /* one digit left over */
+ byte = &msg[index];
+ *byte = imsi.digits[count];
+ memset(temp_buff,0,10);
+ sprintf(temp_buff,"%d",imsi.digits[count]);
+ strcat(disp_buff,temp_buff);
+ index++;
+ }
+
+ *msg_len += index;
+
+ DBG_TRACE("Encoded IMSI : %s; IEI length %d bytes",disp_buff,index);
+
+ DBG_LEAVE();
+ return;
+}
+
+
+/*
+ * bssgp_ie_encode_llc_pdu
+ *
+ *----------------------------------------------------------
+ * 11.3.15 LLC-PDU
+ * This information element contains an LLC-PDU. The
+ * element coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3 LLC-PDU (first part)
+ * octet n LLC-PDU (last part)
+ *
+ *----------------------------------------------------------
+ *
+ */
+void
+bssgp_ie_encode_llc_pdu(UINT8 *llc_pdu, UINT16 pdu_len, UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_encode_llc_pdu",BSSGP_ENCODER_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 index = 0;
+
+ byte = &msg[index];
+ index++;
+
+ *byte = (UINT8)BSSGP_IEI_LLC_PDU;
+
+ bssgp_ie_encode_iei_length(pdu_len,&msg[index],&index);
+
+
+ memcpy(&msg[index],llc_pdu,pdu_len);
+
+
+ index += pdu_len;
+
+ *len += index;
+
+ DBG_TRACE("Encoded LLC PDU of size %d; IEI length %d",pdu_len,index);
+
+ DBG_LEAVE();
+ return;
+}
+
+
+
+/*
+ * bssgp_ie_encode_llc_frames_discarded
+ *
+ *----------------------------------------------------------
+ * 11.3.16 LLC Frames Discarded
+ * This element describes the number of LLC frames that
+ * have been discarded inside a BSS. The element coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3 Number of frames discarded (in hex)
+ *
+ *----------------------------------------------------------
+ *
+ */
+void
+bssgp_ie_encode_llc_frames_discarded(UINT8 num_frames,UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_encode_llc_frames_discarded",BSSGP_ENCODER_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 index = 0;
+
+ byte = &msg[index];
+
+ *byte = (UINT8)BSSGP_IEI_LLC_FRAMES_DISCARDED;
+ index++;
+ DBG_TRACE("Encoding llc frames discarded IE.");
+
+ bssgp_ie_encode_iei_length(sizeof(UINT8),&msg[index],&index);
+
+ msg[index++] = num_frames;
+
+ DBG_TRACE("llc frames discarded IE length %d bytes",index);
+ *len += index;
+
+ DBG_LEAVE();
+ return;
+}
+
+
+
+/*
+ * bssgp_ie_encode_location_area
+ *
+ *----------------------------------------------------------
+ * 11.3.17 Location Area
+ * This element uniquely identifies one Location Area.
+ * The element coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octets 3-7 Octets 3 to 7 contain the value part
+ * (starting with octet 2) of the Location Area
+ * Identification IE defined in GSM 04.08 [11],
+ * not including GSM 04.08 IEI
+ *
+ * The coding of octet 2 is a binary number indicating the
+ * Length of the remaining element.
+ *----------------------------------------------------------
+ *
+ */
+void
+bssgp_ie_encode_location_area(T_CNI_RIL3_IE_LOCATION_AREA_ID location_area,UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_encode_location_area",BSSGP_ENCODER_LAYER);
+ DBG_ENTER();
+ UINT8 *byte;
+ UINT16 lac, index = 0;
+
+ byte = &msg[index];
+
+ *byte = (UINT8)BSSGP_IEI_LOCATION_AREA;
+ index++;
+
+
+ bssgp_ie_encode_iei_length((3+2+sizeof(UINT16)),&msg[index],&index);
+
+ /*
+ * From 04.08:
+ * The Location Area Identification is a type 3 information element
+ * ith 6 octets length.
+ * 8 7 6 5 4 3 2 1
+ * +-----------------------------------------------*
+ * * * *
+ * * MCC digit 2 * MCC digit 1 * octet 2
+ * +-----------------------+-----------------------*
+ * * * *
+ * * MNC digit 3 * MCC digit 3 * octet 3
+ * +-----------------------+-----------------------*
+ * * * *
+ * * MNC digit 2 * MNC digit 1 * octet 4
+ * +-----------------------------------------------*
+ * * *
+ * * LAC * octet 5
+ * +-----------------------------------------------*
+ * * *
+ * * LAC (continued) * octet 6
+ * +-----------------------------------------------+
+ *
+ */
+
+ msg[index] = (location_area.mcc[1] << 4) | location_area.mcc[0] ;
+ index++;
+ msg[index] = (location_area.mnc[2] << 4) | location_area.mcc[2];
+ index++;
+ msg[index] = (location_area.mnc[1] << 4) | location_area.mnc[0];
+ index++;
+
+ DBG_TRACE("Location Area :- MCC : %d%d%d ; MNC : %d%d(%x) ; LAC : %d",
+ location_area.mcc[0],location_area.mcc[1],location_area.mcc[2],
+ location_area.mnc[0],location_area.mnc[1],location_area.mnc[2],
+ location_area.lac);
+
+ lac = htons(location_area.lac);
+
+ memcpy(&msg[index],&lac,sizeof(UINT16));
+ index += sizeof(UINT16);
+
+ *len += index;
+ DBG_TRACE("Location area IEI length %d bytes",index);
+ DBG_LEAVE();
+ return;
+}
+
+
+
+/*
+ * bssgp_ie_encode_lsa_identifier_list
+ *
+ *----------------------------------------------------------
+ * 11.3.18 LSA Identifier List
+ * This information element uniquely identifies LSAs. The
+ * element coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3-? Rest of element coded as in GSM 08.08, not
+ * including GSM 08.08 IEI and GSM 08.08 length
+ * indicator
+ *
+ *----------------------------------------------------------
+ *
+ */
+void
+bssgp_ie_encode_lsa_identifier_list(RIL3_IE_LSA_IDENTIFIER_LIST lsa_id_list,
+ UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_encode_lsa_identifier_list",BSSGP_ENCODER_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 index = 0;
+ INT16 num_lsa_ids;
+
+ byte = &msg[index];
+
+ *byte = (UINT8)BSSGP_IEI_LSA_ID_LIST;
+ index++;
+ DBG_TRACE("Encoding LSA Identifier List IE\n");
+
+ bssgp_ie_encode_iei_length(lsa_id_list.num_lsa_ids*3 + 1,&msg[index],&index);
+
+ msg[index++] = (UINT8)(lsa_id_list.ep & 0x01);
+
+ num_lsa_ids = lsa_id_list.num_lsa_ids;
+ while (num_lsa_ids)
+ {
+ msg[index++] = (UINT8)(lsa_id_list.lsa_id[lsa_id_list.num_lsa_ids-num_lsa_ids] >> 16);
+ msg[index++] = (UINT8)(lsa_id_list.lsa_id[lsa_id_list.num_lsa_ids-num_lsa_ids] >> 8);
+ msg[index++] = (UINT8)(lsa_id_list.lsa_id[lsa_id_list.num_lsa_ids-num_lsa_ids]);
+ num_lsa_ids--;
+ }
+
+ DBG_TRACE("LSA Identifier IE length %d bytes",index);
+ *len += index;
+
+ DBG_LEAVE();
+ return;
+}
+
+
+
+/*
+ * bssgp_ie_encode_lsa_info
+ *
+ *----------------------------------------------------------
+ * 11.3.19 LSA Information
+ * This information element uniquely identifies LSAs, the
+ * priority of each LSA and the access right outside these
+ * LSAs. The element coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3-? Rest of element coded as in GSM 08.08, not
+ * including GSM 08.08 IEI and GSM 08.08
+ * length indicator
+ *
+ *
+ *----------------------------------------------------------
+ *
+ */
+void
+bssgp_ie_encode_lsa_info(RIL3_IE_LSA_INFORMATION lsa_info,UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_encode_lsa_info",BSSGP_ENCODER_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 index = 0;
+ INT16 num_lsas;
+
+ byte = &msg[index];
+
+ *byte = (UINT8)BSSGP_IEI_LSA_INFORMATION;
+ index++;
+ DBG_TRACE("Encoding LSA Information IE\n");
+
+ bssgp_ie_encode_iei_length(lsa_info.num_lsas*4 + 1,&msg[index],&index);
+
+ msg[index++] = (UINT8)(lsa_info.lsa_only & 0x01);
+
+ num_lsas = lsa_info.num_lsas;
+ while (num_lsas)
+ {
+ msg[index++] = (lsa_info.lsa_ids[lsa_info.num_lsas-num_lsas].act << 5) |
+ (lsa_info.lsa_ids[lsa_info.num_lsas-num_lsas].pref << 4) |
+ (lsa_info.lsa_ids[lsa_info.num_lsas-num_lsas].priority);
+ msg[index++] = (UINT8)(lsa_info.lsa_ids[lsa_info.num_lsas-num_lsas].lsa_id >> 16);
+ msg[index++] = (UINT8)(lsa_info.lsa_ids[lsa_info.num_lsas-num_lsas].lsa_id >> 8);
+ msg[index++] = (UINT8)(lsa_info.lsa_ids[lsa_info.num_lsas-num_lsas].lsa_id);
+ num_lsas--;
+ }
+
+ DBG_TRACE("LSA Information IE length %d bytes",index);
+ *len += index;
+
+ DBG_LEAVE();
+ return;
+}
+
+
+
+
+/*
+ * bssgp_ie_encode_mobile_id
+ *
+ *----------------------------------------------------------
+ * 11.3.20 Mobile Id
+ * The element coding is:
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3-n Octets 3-n contain either the IMSI, IMEISV
+ * or IMEI coded as the value part (starting
+ * with octet 3) of the Mobile Identity IE
+ * defined in GSM 04.08, not including GSM
+ * 04.08 IEI and GSM 04.08 length indcator
+ *
+ *----------------------------------------------------------
+ *
+ */
+void
+bssgp_ie_encode_mobile_id(UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_encode_mobile_id",BSSGP_ENCODER_LAYER);
+ DBG_ENTER();
+ /* FIXME */
+
+ DBG_LEAVE();
+ return;
+}
+
+
+/*
+ * bssgp_ie_encode_ms_bucket_size
+ *
+ *----------------------------------------------------------
+ * 11.3.21 MS Bucket Size
+ * This information element indicates an MS's bucket size
+ * (Bmax). The element coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3-4 Bmax
+ *
+ * The Bmax field is coded as in section GSM 08.18 BVC Bucket
+ * Size/Bmax.
+ *----------------------------------------------------------
+ *
+ */
+void
+bssgp_ie_encode_ms_bucket_size(UINT16 bucket_size,UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_encode_ms_bucket_size",BSSGP_ENCODER_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 index = 0;
+
+ byte = &msg[index];
+
+ *byte = (UINT8)BSSGP_IEI_MS_BUCKET_SIZE;
+ index++;
+ DBG_TRACE("Encoding MS Bucket size IE.");
+
+ bssgp_ie_encode_iei_length(sizeof(UINT16),&msg[index],&index);
+
+ msg[index++] = (UINT8)(bucket_size >> 8);
+ msg[index++] = (UINT8)(bucket_size);
+
+ DBG_TRACE("MS Bucket size IE length %d bytes",index);
+ *len += index;
+
+ DBG_LEAVE();
+ return;
+}
+
+
+/*
+ * bssgp_ie_encode_ms_ra_cap
+ *
+ *----------------------------------------------------------
+ * 11.3.22 MS Radio Access Capability
+ * This information element contains the capabilities of
+ * the ME. The element coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3-14 Rest of element coded as the value part
+ * defined in GSM 04.08, not including GSM
+ * 04.08 IEI and GSM 04.08 octet length
+ * indicator.
+ *
+ *----------------------------------------------------------
+ *
+ */
+void
+bssgp_ie_encode_ms_ra_cap(T_CNI_RIL3_IE_MS_RADIO_ACCESS_CAPABILITY ra_cap,UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_encode_ms_ra_cap",BSSGP_ENCODER_LAYER);
+ DBG_ENTER();
+ UINT8 *byte;
+ UINT16 index = 0,count;
+
+ byte = &msg[index];
+ index++;
+
+ *byte = (UINT8)BSSGP_IEI_MS_RADIO_ACCESS_CAP;
+
+
+ bssgp_ie_encode_iei_length(((ra_cap.number_of_ra_capabilities*6*sizeof(UINT8))+sizeof(UINT8)),&msg[index],&index);
+
+
+ /*
+ * Although the spec 04.08 is pretty clear about the IE
+ * encoding, the encoding specified is quite messy &
+ * since we would be more or less dealing with ourselves,
+ * (read proprietary..snigger..) it is well worth it to
+ * rearrange the elements to pack it nicely... DSN.
+ * So packing would be as follows:-
+ *
+ * |---------------------------------------------------------------|
+ * | Number of Radio Access Capabilities | octet 1
+ * |---------------------------------------------------------------|
+ *
+ * After this, depending on above value there would be 5 octets per
+ * radio access capability packed as follows
+ *
+ * |---------------------------------------------------------------|
+ * | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
+ * |---------------------------------------------------------------|
+ * | Access Tech Type | RF Power Capabilities | octet n
+ * |---------------------------------------------------------------|
+ * | resvd | A5 Algorithms supported from 7 to 1 | octet n+1
+ * |---------------------------------------------------------------|
+ * | reserved | es | ps | vgcs | vbs | res | octet n+2
+ * |---------------------------------------------------------------|
+ * | pres | reserved | hscd multi-slot class | octet n+3
+ * |---------------------------------------------------------------|
+ * | pres | gprs multi-slot class | ExCap | pres | octet n+4
+ * |---------------------------------------------------------------|
+ * | switch measure switch value | switch measure value | octet n+5
+ * |---------------------------------------------------------------|
+ *
+ */
+
+ byte = &msg[index];
+ index++;
+ *byte = ra_cap.number_of_ra_capabilities;
+
+ DBG_TRACE("Encoding %d number of Radio Access Capabilities",ra_cap.number_of_ra_capabilities);
+
+ for(count=0;count<ra_cap.number_of_ra_capabilities;count++) {
+ byte = &msg[index];
+ index++;
+ *byte = ra_cap.ms_ra_capability[count].rf_power_capability;
+ *byte |= (ra_cap.ms_ra_capability[count].access_technology_type << 4);
+ DBG_TRACE("Access Technology Type : %d, RF Power Capability %d",
+ ra_cap.ms_ra_capability[count].access_technology_type,
+ ra_cap.ms_ra_capability[count].rf_power_capability);
+
+ byte = &msg[index];
+ index++;
+ *byte = 0;
+ if (ra_cap.ms_ra_capability[count].a5_1_algorithm) {
+ *byte |= 0x01;
+ DBG_TRACE("Supports A5.1 algorithm");
+ }
+ if (ra_cap.ms_ra_capability[count].a5_2_algorithm) {
+ *byte |= 0x02;
+ DBG_TRACE("Supports A5.2 algorithm");
+ }
+ if (ra_cap.ms_ra_capability[count].a5_3_algorithm) {
+ *byte |= 0x04;
+ DBG_TRACE("Supports A5.3 algorithm");
+ }
+ if (ra_cap.ms_ra_capability[count].a5_4_algorithm) {
+ *byte |= 0x08;
+ DBG_TRACE("Supports A5.4 algorithm");
+ }
+ if (ra_cap.ms_ra_capability[count].a5_5_algorithm) {
+ *byte |= 0x10;
+ DBG_TRACE("Supports A5.5 algorithm");
+ }
+ if (ra_cap.ms_ra_capability[count].a5_6_algorithm) {
+ *byte |= 0x20;
+ DBG_TRACE("Supports A5.6 algorithm");
+ }
+ if (ra_cap.ms_ra_capability[count].a5_7_algorithm) {
+ *byte |= 0x40;
+ DBG_TRACE("Supports A5.7 algorithm");
+ }
+
+ byte = &msg[index];
+ index++;
+ *byte = 0;
+ if (ra_cap.ms_ra_capability[count].es_ind) {
+ *byte |= 0x10;
+ DBG_TRACE("ES Indicator");
+ }
+ if (ra_cap.ms_ra_capability[count].ps) {
+ *byte |= 0x08;
+ DBG_TRACE("PS");
+ }
+ if (ra_cap.ms_ra_capability[count].vgcs) {
+ *byte |= 0x04;
+ DBG_TRACE("VGCS");
+ }
+ if (ra_cap.ms_ra_capability[count].vbs) {
+ *byte |= 0x02;
+ DBG_TRACE("VBS");
+ }
+
+ byte = &msg[index];
+ index++;
+ *byte = ra_cap.ms_ra_capability[count].multislot_capability.hscsd_multi_slot_class;
+ *byte |= (ra_cap.ms_ra_capability[count].multislot_capability.hscsd_param_present << 7);
+ if (ra_cap.ms_ra_capability[count].multislot_capability.hscsd_param_present)
+ DBG_TRACE("HSCSD Multi slot class %d",ra_cap.ms_ra_capability[count].multislot_capability.hscsd_multi_slot_class);
+ else
+ DBG_TRACE("HSCSD Multi slot class not present");
+
+ byte = &msg[index];
+ index++;
+ *byte = (ra_cap.ms_ra_capability[count].multislot_capability.gprs_multi_slot_class << 2);
+ *byte |= (ra_cap.ms_ra_capability[count].multislot_capability.gprs_params_present << 7);
+ *byte |= (ra_cap.ms_ra_capability[count].multislot_capability.gprs_dynamic_allocation_capability << 1);
+ *byte |= (ra_cap.ms_ra_capability[count].multislot_capability.sms_params_present);
+ if (ra_cap.ms_ra_capability[count].multislot_capability.gprs_params_present)
+ {
+ DBG_TRACE("GPRS Multi slot class %d",ra_cap.ms_ra_capability[count].multislot_capability.gprs_multi_slot_class);
+ DBG_TRACE("GPRS Ext dynamic allocation cap %d",ra_cap.ms_ra_capability[count].multislot_capability.gprs_dynamic_allocation_capability);
+ }
+ else
+ DBG_TRACE("GPRS Multi slot class not present");
+
+ byte = &msg[index];
+ index++;
+ *byte = ra_cap.ms_ra_capability[count].multislot_capability.switch_measure_value;
+ *byte |= (ra_cap.ms_ra_capability[count].multislot_capability.switch_measure_switch_value << 4);
+ if (ra_cap.ms_ra_capability[count].multislot_capability.sms_params_present)
+ DBG_TRACE("Switch measure value %d, Switch measure switch value %d",
+ ra_cap.ms_ra_capability[count].multislot_capability.switch_measure_value,
+ ra_cap.ms_ra_capability[count].multislot_capability.switch_measure_switch_value);
+ else
+ DBG_TRACE("Switch measure not present");
+ }
+
+ *len += index;
+
+ DBG_TRACE("MS-Radio-Access-Capability IEI length %d bytes",index);
+
+ DBG_LEAVE();
+ return;
+}
+
+
+
+/*
+ * bssgp_ie_encode_omc_id
+ *
+ *----------------------------------------------------------
+ * 11.3.23 OMC Id
+ * The element coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3-22 For the OMC identity, see TS 12.20
+ *
+ *----------------------------------------------------------
+ *
+ */
+void
+bssgp_ie_encode_omc_id(UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_encode_omc_id",BSSGP_ENCODER_LAYER);
+ DBG_ENTER();
+
+ /* FIXME */
+ DBG_LEAVE();
+ return;
+}
+
+
+
+/*
+ * bssgp_ie_encode_pdu_in_error
+ *
+ *----------------------------------------------------------
+ * 11.3.24 PDU In Error
+ * The element coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3-? Erroneous BSSGP PDU
+ *
+ *----------------------------------------------------------
+ *
+ */
+void
+bssgp_ie_encode_pdu_in_error(BSSGP_PDU_TYPE pdu_type,UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_encode_pdu_in_error",BSSGP_ENCODER_LAYER);
+ DBG_ENTER();
+
+ /* FIXME : TODO */
+ DBG_LEAVE();
+ return;
+}
+
+
+/*
+ * bssgp_ie_encode_pdu_lifetime
+ *
+ *----------------------------------------------------------
+ * 11.3.25 PDU Lifetime
+ * This information element describes the PDU Lifetime
+ * for a PDU inside the BSS. The element coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3-4 Delay Value
+ *
+ * The Delay Value field is coded as in section GSM 08.18
+ * BVC Measurement/Delay Value.
+ *----------------------------------------------------------
+ *
+ */
+void
+bssgp_ie_encode_pdu_lifetime(RIL3_IE_PDU_LIFETIME pdu_lifetime, UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_encode_pdu_lifetime",BSSGP_ENCODER_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 index = 0;
+
+ byte = &msg[index];
+
+ *byte = (UINT8)BSSGP_IEI_PDU_LIFETIME;
+ index++;
+ DBG_TRACE("Encoding PDU Lifetime IE %#x\n", pdu_lifetime.pdu_lifetime);
+
+ bssgp_ie_encode_iei_length(sizeof(UINT16),&msg[index],&index);
+
+ msg[index++] = (UINT8)(pdu_lifetime.pdu_lifetime >> 8);
+ msg[index++] = (UINT8)(pdu_lifetime.pdu_lifetime);
+
+ DBG_TRACE("PDU Lifetime IEI length %d bytes",index);
+ *len += index;
+
+ DBG_LEAVE();
+ return;
+}
+
+
+
+/*
+ * bssgp_ie_encode_priority
+ *
+ *----------------------------------------------------------
+ * 11.3.27 Priority
+ * This element indicates the priority of a PDU. The
+ * element coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3 Rest of element coded as the value part of
+ * the Priority IE defined in GSM 08.08, not
+ * including GSM 08.08 IEI and GSM 08.08
+ * length indicator
+ *
+ *----------------------------------------------------------
+ *
+ */
+void
+bssgp_ie_encode_priority(RIL3_IE_PRIORITY priority,UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_encode_priority",BSSGP_ENCODER_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 index = 0;
+
+ byte = &msg[index];
+
+ *byte = (UINT8)BSSGP_IEI_PRIORITY;
+ index++;
+ DBG_TRACE("Encoding Priority IE %#x\n", priority.priority);
+
+ bssgp_ie_encode_iei_length(sizeof(UINT8),&msg[index],&index);
+
+ msg[index++] = priority.priority;
+
+ DBG_TRACE("Priority IEI length %d bytes",index);
+ *len += index;
+
+ DBG_LEAVE();
+ return;
+}
+
+
+/*
+ * bssgp_ie_encode_qos_params
+ *
+ *----------------------------------------------------------
+ * QoS Params (Cisco-EWTBU proprietary ext)
+ * This information element describes the QoS Params
+ * associated with a PDU. The element coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3 Delay Class
+ * octet 4 Reliability Class
+ * octet 5 Precedence Class
+ * octet 6 Peak Throughput
+ * octet 7 Mean Throughput
+ *
+ *----------------------------------------------------------
+ *
+ */
+void
+bssgp_ie_encode_qos_params(T_CNI_RIL3_IE_QOS qos_params, UINT8 *msg, UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_encode_qos_params",BSSGP_ENCODER_LAYER);
+ DBG_ENTER();
+ UINT8 *byte;
+ UINT16 index = 0;
+
+ byte = &msg[index];
+
+ *byte = (UINT8)BSSGP_IEI_QOS_PARAMS;
+ index++;
+
+
+ bssgp_ie_encode_iei_length((sizeof(UINT8)*5),&msg[index],&index);
+ /* Delay Class */
+ byte = &msg[index];
+ *byte = (UINT8)qos_params.delay_class;
+ index++;
+ /* Reliability class */
+ byte = &msg[index];
+ *byte = (UINT8)qos_params.reliability_class;
+ index++;
+ /* Precedence class */
+ byte = &msg[index];
+ *byte = (UINT8)qos_params.precedence_class;
+ index++;
+ /* Peak throughput */
+ byte = &msg[index];
+ *byte = (UINT8)qos_params.peak_throughput;
+ index++;
+ /* Mean throughput */
+ byte = &msg[index];
+ *byte = (UINT8)qos_params.mean_throughput;
+ index++;
+
+ DBG_TRACE("Encoded QoS params; Delay %d, Reliability %d, Precedence %d, Peak throughput %d & Mean throughput %d",
+ qos_params.delay_class,qos_params.reliability_class,qos_params.precedence_class,
+ qos_params.peak_throughput,qos_params.mean_throughput);
+ *len += index;
+ DBG_LEAVE();
+ return;
+}
+
+
+/*
+ * bssgp_ie_encode_qos_profile
+ *
+ *----------------------------------------------------------
+ * 11.3.28 QoS Profile
+ * This information element describes the QoS Profile
+ * associated with a PDU. The element coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3-4 Peak bit rate provided by the network,
+ * coded as the value part in Bucket Leak
+ * Rate/R IE/ GSM 08.18 a)
+ * octet 5 SPARE C/R T A Precedence
+ *
+ *----------------------------------------------------------
+ *
+ */
+void
+bssgp_ie_encode_qos_profile(T_RIL3_IE_QOS_PROFILE_ID qos_profile,UINT8 *msg,UINT16 *len, BSSGP_IEI_FORMAT format)
+{
+ DBG_FUNC("bssgp_ie_encode_qos_profile",BSSGP_ENCODER_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 index = 0;
+
+ byte = &msg[index];
+
+ DBG_TRACE("Encoding QoS Profile");
+
+ if (format == BSSGP_FORMAT_TLV)
+ {
+ *byte = (UINT8)BSSGP_IEI_QOS_PROFILE;
+ index++;
+
+ bssgp_ie_encode_iei_length((sizeof(UINT16)+sizeof(UINT8)),&msg[index],&index);
+ }
+
+ msg[index] = qos_profile.bucket_leak_rate[0];
+ index++;
+ msg[index] = qos_profile.bucket_leak_rate[1];
+ index++;
+
+ byte = &msg[index];
+ *byte = qos_profile.precedence_class;
+ if (qos_profile.a_bit) {
+ *byte |= 0x08;
+ DBG_TRACE("Radio interface uses RLC/MAC-UNITDATA functionality");
+ }
+ else {
+ DBG_TRACE("Radio interface uses RLC/MAC ARQ functionality");
+ }
+
+ if (qos_profile.t_bit) {
+ *byte |= 0x10;
+ DBG_TRACE("SDU contains Data");
+ }
+ else {
+ DBG_TRACE("SDU contains Signalling (e.g. related to GMM)");
+ }
+
+ if (qos_profile.cr_bit) {
+ *byte |= 0x20;
+ DBG_TRACE("SDU does NOT contain a LLC ACK or SACK command/response frame type");
+ }
+ else {
+ DBG_TRACE("SDU contains LLC ACK or SACK command/response frame type");
+ }
+ index++;
+ *len += index;
+ DBG_TRACE("QoS Profile IEI length %d bytes",index);
+ DBG_LEAVE();
+ return;
+}
+
+
+
+/*
+ * bssgp_ie_encode_radio_cause
+ *
+ *----------------------------------------------------------
+ * 11.3.29 Radio Cause
+ * This information element indicates the reason for an
+ * exception condition on the radio interface. The element
+ * coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3 Radio Cause value
+ *
+ *----------------------------------------------------------
+ *
+ */
+void
+bssgp_ie_encode_radio_cause(T_RIL3_IE_RADIO_CAUSE_ID radio_cause,UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_encode_radio_cause",BSSGP_ENCODER_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 index = 0;
+
+ byte = &msg[index];
+
+ *byte = (UINT8)BSSGP_IEI_RADIO_CAUSE;
+ index++;
+ DBG_TRACE("Encoding Radio cause : %s",
+ bssgp_util_get_radio_cause_str(radio_cause));
+
+ bssgp_ie_encode_iei_length(sizeof(UINT8),&msg[index],&index);
+
+ byte = &msg[index];
+ *byte = (UINT8)radio_cause;
+ index++;
+
+ DBG_TRACE("Radio Cause IEI length %d bytes",index);
+ *len += index;
+
+ DBG_LEAVE();
+ return;
+}
+
+
+/*
+ * bssgp_ie_encode_ra_cap_update_cause
+ *
+ *----------------------------------------------------------
+ * 11.3.30 RA-Cap-UPD-Cause
+ * The RA-Cap-UPD-Cause indicates the success of the
+ * RA-CAPABILITY-UPDATE procedure or the reason of the
+ * failure. The element coding is:
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3 RA-Cap-UPD Cause value
+ *
+ *----------------------------------------------------------
+ *
+ */
+void
+bssgp_ie_encode_ra_cap_update_cause(RA_CAP_UPD_CAUSE ra_cause,UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_encode_ra_cap_update_cause",BSSGP_ENCODER_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 index = 0;
+
+ byte = &msg[index];
+
+ *byte = (UINT8)BSSGP_IEI_RA_CAP_UPD_CAUSE;
+ index++;
+ DBG_TRACE("Encoding Radio-Access-Capability-Update-Cause : %s",
+ bssgp_util_get_ra_cap_cause_str(ra_cause));
+
+ bssgp_ie_encode_iei_length(sizeof(UINT8),&msg[index],&index);
+
+ byte = &msg[index];
+ *byte = (UINT8)ra_cause;
+ index++;
+
+ DBG_TRACE("Radio-Access-Capability-Update-Cause IEI length %d bytes",index);
+ *len += index;
+
+ DBG_LEAVE();
+ return;
+}
+
+
+
+/*
+ * bssgp_ie_encode_reject_cause
+ *
+ *----------------------------------------------------------
+ * Reject Cause (Cisco-EWTBU proprietary ext)
+ * This information element describes the reject cause
+ * for a Location Update Nack
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3 Reject cause
+ *
+ *----------------------------------------------------------
+ *
+ */
+void
+bssgp_ie_encode_reject_cause(T_CNI_RIL3_IE_REJECT_CAUSE reject_cause, UINT8 *msg, UINT16 *len)
+{
+ DBG_FUNC("",BSSGP_ENCODER_LAYER);
+ DBG_ENTER();
+ UINT8 *byte;
+ UINT16 index = 0;
+
+ byte = &msg[index];
+ index++;
+
+ *byte = (UINT8)BSSGP_IEI_LA_REJECT_CAUSE;
+
+ bssgp_ie_encode_iei_length(sizeof(UINT8),&msg[index],&index);
+
+ byte = &msg[index];
+ index++;
+
+ *byte = (UINT8) reject_cause.causeValue;
+ DBG_TRACE("Encoded Location Area Reject cause %d; IEI length %d",reject_cause.causeValue,index);
+ *len += index;
+
+ DBG_LEAVE();
+}
+
+
+
+/*
+ * bssgp_ie_encode_routing_area
+ *
+ *----------------------------------------------------------
+ * 11.3.31 Routeing Area
+ * This element uniquely identifies one routeing area. The
+ * element coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octets 3-8 Octets 3 to 8 contain the value part
+ * (starting with octet 2) of the Routing Area
+ * Identification IE defined in GSM 04.08 [11],
+ * not including GSM 04.08 IEI
+ *
+ * The coding of octet 2 is a binary number indicating the
+ * Length of the remaining element.
+ *----------------------------------------------------------
+ *
+ */
+void
+bssgp_ie_encode_routing_area(T_CNI_RIL3_IE_ROUTING_AREA_ID routing_area,UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_encode_routing_area",BSSGP_ENCODER_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 lac, index = 0;
+
+ byte = &msg[index];
+
+ *byte = (UINT8)BSSGP_IEI_ROUTING_AREA;
+ index++;
+
+ bssgp_ie_encode_iei_length((3+2+sizeof(UINT16)),&msg[index],&index);
+
+ /*
+ * From 04.08:
+ *
+ * The routing area identification information element is
+ * coded as shown in figure 10.5.130/GSM 04.08 and
+ * table 10.5.148/GSM 04.08.
+ * 8 7 6 5 4 3 2 1
+ * ------------------------------
+ * * MCC digit 2 * MCC digit 1 * octet 2
+ * ------------------------------
+ * * MNC digit 3 * MCC digit 3 * octet 3
+ * ------------------------------
+ * * MNC digit 2 * MNC digit 1 * octet 4
+ * ------------------------------
+ * * LAC * octet 5
+ * ------------------------------
+ * * LAC cont'd * octet 6
+ * ------------------------------
+ * * RAC * octet 7
+ * ------------------------------
+ *
+ *
+ */
+
+ msg[index] = (routing_area.mcc[1] << 4) | routing_area.mcc[0] ;
+ index++;
+ msg[index] = (routing_area.mnc[2] << 4) | routing_area.mcc[2];
+ index++;
+ msg[index] = (routing_area.mnc[1] << 4) | routing_area.mnc[0];
+ index++;
+
+ DBG_TRACE("Routing Area :- MCC : %d%d%d ; MNC : %d%d(%x) ; LAC : %d ; RAC : %d",
+ routing_area.mcc[0],routing_area.mcc[1],routing_area.mcc[2],
+ routing_area.mnc[0],routing_area.mnc[1],routing_area.mnc[2],
+ routing_area.lac,routing_area.rac);
+
+ lac = htons(routing_area.lac);
+
+ memcpy(&msg[index],&lac,sizeof(UINT16));
+ index += sizeof(UINT16);
+
+ msg[index] = routing_area.rac;
+ index++;
+
+ *len += index;
+ DBG_TRACE("Routing Area IEI length %d bytes",index);
+
+ DBG_LEAVE();
+ return;
+}
+
+
+
+/*
+ * bssgp_ie_encode_r_def_ms
+ *
+ *----------------------------------------------------------
+ * 11.3.32 R_default_MS
+ * This information element indicates the default bucket
+ * leak rate (R) to be applied to a flow control bucket
+ * for an MS. The element coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3-4 R_default_MS value
+ *
+ * The R_default_MS field is coded as in section GSM 08.18
+ * Bucket Leak Rate /R Value.
+ *----------------------------------------------------------
+ *
+ */
+void
+bssgp_ie_encode_r_def_ms(UINT16 r_default,UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_encode_r_def_ms",BSSGP_ENCODER_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 index = 0;
+
+ byte = &msg[index];
+
+ *byte = (UINT8)BSSGP_IEI_R_DEFAULT_MS;
+ index++;
+ DBG_TRACE("Encoding R_default_MS IE.");
+
+ bssgp_ie_encode_iei_length(sizeof(UINT16),&msg[index],&index);
+
+ msg[index++] = (UINT8)(r_default >> 8);
+ msg[index++] = (UINT8)(r_default);
+
+ DBG_TRACE("R_default_MS IE length %d bytes",index);
+ *len += index;
+
+ DBG_LEAVE();
+ return;
+}
+
+/*
+ * bssgp_ie_encode_suspend_ref_num
+ *
+ *----------------------------------------------------------
+ * 11.3.33 Suspend Reference Number
+ * The Suspend Reference Number information element
+ * contains an un-formatted reference number for each
+ * suspend/resume transaction. The element coding is:
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3 Suspend Reference Number
+ *
+ * The Suspend Reference Number is an un-formatted 8 bit
+ * field.
+ *----------------------------------------------------------
+ *
+ */
+void
+bssgp_ie_encode_suspend_ref_num(UINT8 suspend_ref_num,UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_encode_suspend_ref_num",BSSGP_ENCODER_LAYER);
+ DBG_ENTER();
+ UINT8 *byte;
+ UINT16 index = 0;
+
+ byte = &msg[index];
+
+ *byte = (UINT8)BSSGP_IEI_SUSPEND_REF_NUM;
+ index++;
+
+ bssgp_ie_encode_iei_length(sizeof(UINT8),&msg[index],&index);
+ byte = &msg[index];
+
+ *byte = suspend_ref_num;
+ index++;
+
+ DBG_TRACE("Encoded Suspend Reference Number as %d; IEI length %d bytes",suspend_ref_num,index);
+
+ *len += index;
+
+ DBG_LEAVE();
+ return;
+}
+
+
+
+/*
+ * bssgp_ie_encode_tag
+ *
+ *----------------------------------------------------------
+ * 11.3.34 Tag
+ * This information element is used to correlate request
+ * and response PDUs. The element coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3 Unstructured value
+ *
+ *----------------------------------------------------------
+ *
+ */
+void
+bssgp_ie_encode_tag(UINT8 tag,UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_encode_tag",BSSGP_ENCODER_LAYER);
+ DBG_ENTER();
+ UINT8 *byte;
+ UINT16 index = 0;
+
+ byte = &msg[index];
+
+ *byte = (UINT8)BSSGP_IEI_TAG;
+ index++;
+
+ bssgp_ie_encode_iei_length(sizeof(UINT8),&msg[index],&index);
+ byte = &msg[index];
+
+ *byte = tag;
+ index++;
+
+ DBG_TRACE("Encoded tag as %d; IEI length %d bytes",tag,index);
+
+ *len += index;
+ DBG_LEAVE();
+ return;
+}
+
+/*
+ * bssgp_ie_encode_tlli
+ *
+ *----------------------------------------------------------
+ * 11.3.35 Temporary logical link Identity (TLLI)
+ * The element coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3-6 Rest of element coded as the value part of
+ * the TLLI information element in GSM 04.08,
+ * not including GSM 04.08 IEI.
+ *
+ *----------------------------------------------------------
+ *
+ */
+void
+bssgp_ie_encode_tlli(RIL3_TLLI tlli,UINT8 *msg,UINT16 *len, BSSGP_IEI_FORMAT format)
+{
+ DBG_FUNC("bssgp_ie_encode_tlli",BSSGP_ENCODER_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 index = 0;UINT32 *shorty;
+
+ byte = &msg[index];
+
+ if (format == BSSGP_FORMAT_TLV)
+ {
+ *byte = (UINT8)BSSGP_IEI_TLLI;
+ index++;
+
+
+ bssgp_ie_encode_iei_length(sizeof(TLLI),&msg[index],&index);
+ }
+
+ shorty = (UINT32*)&msg[index];
+ /* now we get shorty ;-) */
+ *shorty = htonl(tlli.tlli);
+ index += sizeof(UINT32);
+
+ *len += index;
+ tlli.ie_present = TRUE;
+
+ DBG_TRACE("Encoded TLLI %#x IEI length %d bytes",tlli.tlli,index);
+ DBG_LEAVE();
+ return;
+}
+
+
+/*
+ * bssgp_ie_encode_tmsi
+ *
+ *----------------------------------------------------------
+ * 11.3.36 Temporary Mobile Subscriber Identity (TMSI)
+ * The element coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3-6 Rest of element coded as the value part of
+ * the TMSI/P-TMSI information element in
+ * GSM 04.08, not including GSM 04.08 IEI.
+ *
+ *----------------------------------------------------------
+ *
+ */
+void
+bssgp_ie_encode_tmsi(T_CNI_RIL3_IE_MOBILE_ID tmsi,UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_encode_tmsi",BSSGP_ENCODER_LAYER);
+ DBG_ENTER();
+
+
+ UINT8 *byte;
+ unsigned long tmsi_val;
+ UINT16 index = 0;
+
+ byte = &msg[index];
+
+ *byte = (UINT8)BSSGP_IEI_TMSI;
+ index++;
+
+
+ bssgp_ie_encode_iei_length(sizeof(unsigned long),&msg[index],&index);
+
+ /*
+ * Refer to GSM 04.08; the IEI has the following
+ * structure
+ * 8 7 6 5 4 3 2 1
+ * +-----------------------------------------------+
+ * * TMSI/P-TMSI value * octet 2
+ * +-----------------------------------------------*
+ * * * octet 3
+ * * TMSI/P-TMSI value (contd) *
+ * +-----------------------------------------------*
+ * * * octet 4
+ * * TMSI/P-TMSI value (contd *
+ *+-----------------------------------------------*
+ * * * octet 5
+ * * TMSI/P-TMSI value (contd) *
+ * +-----------------------------------------------+
+ *
+ */
+
+ byte = &msg[index];
+
+ tmsi_val = htonl(tmsi.tmsi);
+
+
+ memcpy(byte,&tmsi_val,sizeof(unsigned long));
+ index += sizeof(unsigned long);
+
+ *len += index;
+ DBG_TRACE("Encoded TMSI : %ld; IEI length %d bytes",tmsi.tmsi,index);
+
+ DBG_LEAVE();
+ return;
+}
+
+/*
+ * bssgp_ie_encode_trace_ref
+ *
+ *----------------------------------------------------------
+ * 11.3.37 Trace Reference
+ * This element provides a trace reference number allocated
+ * by the triggering entity. The element coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3-4 Trace Reference
+ *
+ *----------------------------------------------------------
+ *
+ */
+void
+bssgp_ie_encode_trace_ref(UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_encode_trace_ref",BSSGP_ENCODER_LAYER);
+ DBG_ENTER();
+
+ DBG_LEAVE();
+ return;
+}
+
+
+/*
+ * bssgp_ie_encode_trace_type
+ *
+ *----------------------------------------------------------
+ * 11.3.38 Trace Type
+ * This element provides the type of trace information to
+ * be recorded. The element coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3 This is coded as specified in Technical
+ * Specification GSM 12.08.
+ *
+ *----------------------------------------------------------
+ *
+ */
+void
+bssgp_ie_encode_trace_type(UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_encode_trace_type",BSSGP_ENCODER_LAYER);
+ DBG_ENTER();
+
+ DBG_LEAVE();
+ return;
+}
+
+/*
+ * bssgp_ie_encode_txn_id
+ *
+ *----------------------------------------------------------
+ * 11.3.39 TransactionId
+ * This element indicates a particular transaction within
+ * a trace. The element coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3-4 Transaction Id
+ *
+ *----------------------------------------------------------
+ *
+ */
+void
+bssgp_ie_encode_txn_id(UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("",BSSGP_ENCODER_LAYER);
+ DBG_ENTER();
+
+ DBG_LEAVE();
+ return;
+}
+
+
+/*
+ * bssgp_ie_encode_trigger_id
+ *
+ *----------------------------------------------------------
+ * 11.3.40 Trigger Id
+ * This element provides the identity of the entity which
+ * initiated the trace. The element coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3-22 Entity Identity ( typically an OMC identity)
+ *
+ *----------------------------------------------------------
+ *
+ */
+void
+bssgp_ie_encode_trigger_id(UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_encode_trigger_id",BSSGP_ENCODER_LAYER);
+ DBG_ENTER();
+
+ DBG_LEAVE();
+ return;
+}
+
+/*
+ * bssgp_ie_encode_num_octets_affected
+ *
+ *----------------------------------------------------------
+ * 11.3.41 Number of octets affected
+ * This information element indicates, for an MS, the num
+ * of octets transferred or deleted by BSS. The element
+ * coding is:
+ *
+ * octet 1 IEI
+ * octet 2,2a Length Indicator
+ * octet 3-5 number of octets transferred or deleted
+ *
+ * The number of octets transferred or deleted by the BSS
+ * may be higher than the maximum Bmax value (6553500).
+ * SGSN shall handle any value higher than 6553500 as the
+ * value 6553500.
+ *
+ *----------------------------------------------------------
+ * */
+void
+bssgp_ie_encode_num_octets_affected(UINT32 num_octets,UINT8 *msg,UINT16 *len)
+{
+ DBG_FUNC("bssgp_ie_encode_num_octets_affected",BSSGP_ENCODER_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte;
+ UINT16 index = 0;
+
+ byte = &msg[index];
+
+ *byte = (UINT8)BSSGP_IEI_NUM_OCTETS_AFFECTED;
+ index++;
+ DBG_TRACE("Encoding Number of octets affected IE.");
+
+ bssgp_ie_encode_iei_length(3,&msg[index],&index);
+
+ msg[index++] = (UINT8)(num_octets >> 16);
+ msg[index++] = (UINT8)(num_octets >> 8);
+ msg[index++] = (UINT8)(num_octets);
+
+ DBG_TRACE("Number of octets affected IE length %d bytes",index);
+ *len += index;
+
+ DBG_LEAVE();
+ return;
+}
+
+
+
+
+
+
+/*
+ * bssgp_ie_encode_iei_length
+ *
+ *----------------------------------------------------------
+ * The length indicator shall be included in all
+ * information elements having the TLV format.
+ * Information elements may be variable in length.
+ * The length indicator is one or two octet long, the
+ * second octet may be absent. This field consists of the
+ * field extension bit, 0/1 ext, and the length of the value
+ * field which follows, expressed in octets. The field
+ * extension bit enables extension of the length indicator
+ * to two octets.
+ * Bit 8 of the first octet is reserved for the field
+ * extension bit. If the field extension bit is set to 0
+ * (zero), then the second octet of the length indicator is
+ * present. If the field extension bit is set to 1 (one),
+ * then the first octet is the final octet of the length
+ * indicator.
+ * The length of the value field of the IE occupies the rest
+ * of the bits in the length indicator.
+ *
+ * 8 7 6 5 4 3 2 1
+ * octet 2 0/1 ext length
+ * octet 2a length
+ *
+ * Figure 10/GSM 08.16: Length indicator structure
+ * The BSS or SGSN shall not consider the presence of octet
+ * 2a in a received IE as an error when the IE is short
+ * enough for the length to be coded in octet 2 only.
+ *
+ *----------------------------------------------------------
+ *
+ */
+void
+bssgp_ie_encode_iei_length(int iei_len,UINT8 *msg,UINT16 *msg_len)
+{
+ DBG_FUNC("bssgp_ie_encode_iei_length",BSSGP_ENCODER_LAYER);
+ DBG_ENTER();
+
+ UINT8 *byte = msg, byte_len=0;
+
+ if (iei_len < 128) {
+ byte_len = iei_len;
+ *byte = (0x80 | byte_len);
+ *msg_len += 1;
+ }
+ else {
+ div_t val;
+ val = div(iei_len,128);
+ byte_len = val.rem;
+ *byte = (0x7f & byte_len);
+ *msg_len += 1;
+ byte = &msg[1];
+ *byte = val.quot;
+ *msg_len += 1;
+ }
+
+ DBG_LEAVE();
+ return;
+}
+
+
+
diff --git a/data/mnet/Common/bssgp/src/bssgp_net.cpp b/data/mnet/Common/bssgp/src/bssgp_net.cpp
new file mode 100644
index 0000000..447d63b
--- /dev/null
+++ b/data/mnet/Common/bssgp/src/bssgp_net.cpp
@@ -0,0 +1,442 @@
+/*
+ ****************************************************************************************
+ * *
+ * Copyright Cisco Systems, Inc 2000 All rights reserved *
+ * *
+ * File : bssgp_net.cpp *
+ * *
+ * Description : Network handling functions for the BSS-GP layer module *
+ * *
+ * Author : Dinesh Nambisan *
+ * *
+ *----------------------- Revision history ---------------------------------------------*
+ * Time | Date | Name | Description *
+ *--------------------------------------------------------------------------------------*
+ * 00:00 |10/10/00 | DSN | File created *
+ * | | | *
+ ****************************************************************************************
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include "bssgp/bssgp_prot.h"
+#include "bssgp/bssgp_util.h"
+#include "bssgp/bssgp_api.h"
+#include "bssgp/bssgp_net.h"
+#include "bssgp/bssgp_decoder.h"
+
+#if (defined(MNET_GS) || defined(MNET_GP10))
+#include "os/JCTask.h"
+extern JCTask *g_bssgp_net_task;
+#endif
+
+
+extern BSSGP_NET_CONFIG bssgp_net_config;
+
+
+/*
+ * bssgp_net_initialize
+ */
+BOOL
+bssgp_net_initialize()
+{
+ DBG_FUNC("bssgp_net_initialize",BSSGP_NET_LAYER);
+ DBG_ENTER();
+ BOOL status = FALSE;
+ int count, ret_status, reverse_count;
+ struct sockaddr_in local_addr;
+
+ memset(&bssgp_net_config,0,sizeof(BSSGP_NET_CONFIG));
+
+ /* We need to get this from the MIB */
+ bssgp_net_config.base_port = 24240;
+
+ for(count=0;count<BSSGP_MAX_NETWORK_QOS_LEVELS;count++) {
+ bssgp_net_config.ports[count] = bssgp_net_config.base_port + count;
+ }
+
+ for(count=0;count<BSSGP_MAX_NETWORK_QOS_LEVELS;count++) {
+ bssgp_net_config.socks[count] = socket(AF_INET,SOCK_DGRAM,0);
+ if (bssgp_net_config.socks[count] == ERROR) {
+ DBG_ERROR("Unable to create socket # %d for BSSGP; error %d\n",count,errno);
+ for(reverse_count=count-1;reverse_count>=0;reverse_count--) {
+#ifdef WIN32
+ closesocket(bssgp_net_config.socks[reverse_count]);
+#elif defined(__VXWORKS__)
+ close(bssgp_net_config.socks[reverse_count]);
+#endif
+ }
+ DBG_LEAVE();
+ return (status);
+ }
+ /* now bind it to the specified port */
+ memset(&local_addr,0,sizeof(local_addr));
+ local_addr.sin_family = AF_INET;
+ local_addr.sin_port = htons(bssgp_net_config.ports[count]);
+#ifdef WIN32
+ local_addr.sin_addr.S_un.S_addr = INADDR_ANY;
+#elif defined(__VXWORKS__)
+ local_addr.sin_addr.s_addr = INADDR_ANY;
+#endif
+ ret_status = bind(bssgp_net_config.socks[count],(struct sockaddr *)&local_addr,sizeof(local_addr));
+ if (ret_status == ERROR) {
+ DBG_ERROR("Unable to bind socket # %d=%d to port %d; error %d\n",
+ bssgp_net_config.socks[count],count,bssgp_net_config.ports[count],errno);
+ for(reverse_count=count;reverse_count>=0;reverse_count--) {
+#ifdef WIN32
+ closesocket(bssgp_net_config.socks[reverse_count]);
+#elif defined(__VXWORKS__)
+ close(bssgp_net_config.socks[reverse_count]);
+#endif
+ }
+ DBG_LEAVE();
+ return (status);
+ }
+ }
+
+ if (bssgp_net_init_bvcis()) {
+ status = TRUE;
+ DBG_TRACE("Network initialized for BSSGP successfully\n");
+ bssgp_net_config.init_magic = BSSGP_MAGIC;
+ bssgp_net_config.continue_processing = TRUE;
+ }
+ else {
+ DBG_ERROR("Unable to initialize BVCIs for BSSGP!\n");
+ for(reverse_count=BSSGP_MAX_NETWORK_QOS_LEVELS;reverse_count>=0;reverse_count--) {
+#ifdef WIN32
+ closesocket(bssgp_net_config.socks[reverse_count]);
+#elif defined(__VXWORKS__)
+ close(bssgp_net_config.socks[reverse_count]);
+#endif
+ }
+ }
+
+ DBG_LEAVE();
+ return (status);
+}
+
+
+
+/*
+ * bssgp_net_task
+ */
+void
+bssgp_net_task()
+{
+ DBG_FUNC("bssgp_net_task",BSSGP_NET_LAYER);
+ DBG_ENTER();
+ fd_set read_set,select_set;
+ int count, select_status,no_rx_counter,ret_status;
+ unsigned long rx_bytes;
+ BOOL satisfied = FALSE;
+
+ if (bssgp_net_config.init_magic != BSSGP_MAGIC) {
+ DBG_ERROR("Cannot initialize BSSGP Net task without initializing module first, value %d!!\n",
+ bssgp_net_config.init_magic);
+ DBG_LEAVE();
+ return;
+ }
+
+ FD_ZERO(&read_set);
+
+ for(count=0;count<BSSGP_MAX_NETWORK_QOS_LEVELS;count++) {
+ FD_SET(bssgp_net_config.socks[count],&read_set);
+ }
+
+#if (defined(MNET_GS) || defined(MNET_GP10))
+ g_bssgp_net_task->JCTaskEnterLoop();
+#endif
+ while(bssgp_net_config.continue_processing) {
+ memcpy(&select_set,&read_set,sizeof(read_set));
+ if ((select_status = select(FD_SETSIZE, &select_set, 0,0,NULL)) == ERROR) {
+ DBG_ERROR("Error in select; %d!!\n",errno);
+ }
+ else {
+ /*
+ * Has data arrived on any socket ?
+ * we need to check by QoS Level
+ */
+ no_rx_counter = 0;
+ count = 0;
+ satisfied = FALSE;
+ while(!satisfied) {
+ rx_bytes = 0;
+#ifdef WIN32
+ ret_status = ioctlsocket(bssgp_net_config.socks[count],FIONREAD,&rx_bytes);
+#elif defined(__VXWORKS__)
+ ret_status = ioctl(bssgp_net_config.socks[count],FIONREAD,(int)&rx_bytes);
+#endif
+ if ((ret_status != ERROR) && (rx_bytes > 0)) {
+ bssgp_net_rx_handler(count,rx_bytes);
+ count=0;
+ no_rx_counter = 0;
+ }
+ else {
+ count++;
+ no_rx_counter++;
+ }
+ if (count == BSSGP_MAX_NETWORK_QOS_LEVELS) count = 0;
+ if (no_rx_counter == BSSGP_MAX_NETWORK_QOS_LEVELS) satisfied = TRUE;
+ }
+ }
+ }
+#if (defined(MNET_GS) || defined(MNET_GP10))
+ g_bssgp_net_task->JCTaskNormExit();
+#endif
+ DBG_LEAVE();
+ return;
+}
+
+
+
+
+
+/*
+ * bssgp_net_rx_handler
+ */
+void
+bssgp_net_rx_handler(int index,int rx_bytes)
+{
+ DBG_FUNC("bssgp_net_rx_handler",BSSGP_NET_LAYER);
+ DBG_ENTER();
+ UINT16 msg_len=0;
+ UINT8 *rx_buff;
+ struct sockaddr_in remote_addr;
+ int conn_socket,addr_size,ret_status;
+ BSSGP_BVCI bvci;
+ char peer_ip_addr[INET_ADDR_LEN];
+ BOOL free_buff = TRUE;
+
+ DBG_TRACE("QoS Level %d msg received\n",index);
+
+
+ rx_buff = (UINT8*)bssgp_util_get_rx_buff(rx_bytes);
+
+ if (!rx_buff)
+ {
+ DBG_ERROR("BSSGP: No receive buffer available for %d byte packet!\n", rx_bytes);
+ DBG_LEAVE();
+ return;
+ }
+
+ conn_socket = bssgp_net_config.socks[index];
+ addr_size = sizeof(remote_addr);
+
+ memset(&remote_addr,0,addr_size);
+ memset(peer_ip_addr,0,INET_ADDR_LEN);
+
+ ret_status = recvfrom(conn_socket,(char*)rx_buff,rx_bytes,0,
+ (struct sockaddr*)&remote_addr,&addr_size);
+ if (ret_status == ERROR) {
+ /* might want to send back msg to the peer
+ * reporting error
+ */
+ DBG_ERROR("Error receiving PDU; %d!\n",errno);
+ bssgp_util_return_rx_buff((char*)rx_buff);
+ }
+ else {
+#ifdef WIN32
+ strcpy(peer_ip_addr,inet_ntoa(remote_addr.sin_addr));
+#elif defined(__VXWORKS__)
+ inet_ntoa_b(remote_addr.sin_addr,peer_ip_addr);
+#endif
+ msg_len = ret_status;
+ DBG_TRACE("Received %d bytes of data from %s\n",msg_len,peer_ip_addr);
+ bvci = bssgp_net_get_bvci_by_ip(peer_ip_addr);
+ if (bvci == BSSGP_MAX_BVCI) {
+ DBG_ERROR("Received msg of %d bytes from %s, but BVCI not up yet, so discarding msg\n",
+ msg_len,peer_ip_addr);
+ bssgp_util_return_rx_buff((char*)rx_buff);
+ DBG_LEAVE();
+ return;
+ }
+
+ if (!bssgp_decode_msg(rx_buff,msg_len,TRUE,(BSSGP_NETWORK_QOS_LEVEL)index,bvci,&free_buff)) {
+ /* might want to send back msg to the peer
+ * reporting error
+ */
+ DBG_ERROR("Error in processing received PDU from BVCI %d!\n",bvci);
+ bssgp_util_return_rx_buff((char*)rx_buff);
+ }
+ else {
+ if (free_buff) {
+ bssgp_util_return_rx_buff((char*)rx_buff);
+ }
+ }
+ }
+
+ DBG_LEAVE();
+ return;
+}
+
+
+
+/*
+ * bssgp_net_init_bvcis
+ */
+BOOL
+bssgp_net_init_bvcis()
+{
+ DBG_FUNC("bssgp_net_init_bvcis",BSSGP_NET_LAYER);
+ DBG_ENTER();
+ BOOL status = FALSE;
+
+#if defined (MNET_GS)
+
+ status = TRUE;
+#elif defined (MNET_GP10)
+ /* get the address of the GS from the MIB */
+ status = TRUE;
+#endif
+
+ DBG_LEAVE();
+ return(status);
+}
+
+#if defined(MNET_GS)
+
+/*
+ ******************************************************************
+ * Network Functions specific to the GS Platform
+ ******************************************************************
+ */
+
+
+
+
+#elif defined(MNET_GP10)
+/*
+ ******************************************************************
+ * Network Functions specific to the GP-10 Platform
+ ******************************************************************
+ */
+
+#endif
+
+
+
+
+
+/*
+ * bssgp_net_tx_msg
+ */
+BOOL
+#if defined(MNET_GS)
+bssgp_net_tx_msg(BSSGP_BVCI bvci,BSSGP_NETWORK_QOS_LEVEL qos_level,UINT8 *msg,UINT16 msg_len)
+{
+ char peer_addr[20];
+
+ strcpy(peer_addr,bssgp_net_config.bvci_list[bvci].peer_ip_addr);
+
+#elif defined(MNET_GP10)
+bssgp_net_tx_msg(BSSGP_NETWORK_QOS_LEVEL qos_level,UINT8 *msg,UINT16 msg_len)
+{
+ char peer_addr[20];
+ strcpy(peer_addr,bssgp_net_config.bvci_list[BSSGP_ROOT_BVCI].peer_ip_addr);
+
+#elif defined(WIN32)
+bssgp_net_tx_msg(BSSGP_NETWORK_QOS_LEVEL qos_level,UINT8 *msg,UINT16 msg_len)
+{
+ char peer_addr[20];
+ strcpy(peer_addr,bssgp_net_config.bvci_list[BSSGP_ROOT_BVCI].peer_ip_addr);
+
+#endif
+ DBG_FUNC("bssgp_net_tx_msg",BSSGP_NET_LAYER);
+ DBG_ENTER();
+ struct sockaddr_in remote_addr;
+ int ret_status;
+ UINT16 peer_port;
+ int conn_socket;
+
+ peer_port = qos_level + bssgp_net_config.base_port;
+ conn_socket = bssgp_net_config.socks[qos_level];
+
+ memset(&remote_addr,0,sizeof(remote_addr));
+ remote_addr.sin_family = AF_INET;
+ remote_addr.sin_port = htons(peer_port);
+ remote_addr.sin_addr.s_addr = inet_addr(peer_addr);
+
+ ret_status = sendto(conn_socket,(char*)msg,msg_len,0,(struct sockaddr*)&remote_addr,sizeof(remote_addr));
+ if (ret_status != ERROR) {
+ DBG_TRACE("Sent %d bytes of data to %s:%d on QoS level %d\n",ret_status,peer_addr,peer_port,qos_level);
+ DBG_LEAVE();
+ return (TRUE);
+ }
+ else {
+ DBG_ERROR("Error sending data to %s on port %s; error %d\n",peer_addr,peer_port,errno);
+ DBG_LEAVE();
+ return (FALSE);
+ }
+}
+
+
+
+/*
+ * This function invoked from the Shell for testing only....
+ *
+ *
+ */
+
+extern "C" { int bssgp_net_add_test_bvci(char *peer_ip_addr, UINT16 cell_id,UINT8 rac); }
+
+int
+bssgp_net_add_test_bvci(char *peer_ip_addr, UINT16 cell_id,UINT8 rac)
+{
+ unsigned short count;
+
+ for (count=0;count<BSSGP_MAX_BVCI;count++) {
+ if (bssgp_net_config.bvci_list[count].used == FALSE) {
+ bssgp_net_config.bvci_list[count].used = TRUE;
+ strncpy(bssgp_net_config.bvci_list[count].peer_ip_addr,peer_ip_addr,20);
+ bssgp_net_config.bvci_list[count].cell_id.value = cell_id;
+ bssgp_net_config.bvci_list[count].routing_area_code = rac;
+ printf("Added test-bvci %s:%d\n",peer_ip_addr,cell_id);
+ return(0);
+ }
+ }
+ printf("No more BVCIs in pool!\n");
+ return (0);
+}
+
+
+extern "C" void
+bssgp_net_display_bvci(BSSGP_BVCI bvci)
+{
+ if (bssgp_net_config.bvci_list[bvci].used) {
+ printf("BVCI : %d\n",bvci);
+ printf("Peer IP Address : %s\n",bssgp_net_config.bvci_list[bvci].peer_ip_addr);
+ if (bssgp_net_config.bvci_list[bvci].cell_id.ie_present) {
+ printf("Cell-ID : %d\n",bssgp_net_config.bvci_list[bvci].cell_id.value);
+ printf("Routing Area Code : %d\n",bssgp_net_config.bvci_list[bvci].routing_area_code);
+ }
+ }
+ else {
+ printf("BVCI %d NOT used\n",bvci);
+ }
+
+}
+
+
+extern "C"
+int bssgp_net_show_all_bvci()
+{
+#if defined(MNET_GS)
+ int bvci_count=0,count;
+ printf("***************************************************************\n");
+ for (count=0;count<BSSGP_MAX_BVCI;count++) {
+ if (bssgp_net_config.bvci_list[count].used == TRUE) {
+ bssgp_net_display_bvci((BSSGP_BVCI)count);
+ bvci_count++;
+ }
+ }
+ printf("***************************************************************\n");
+ printf("Number of BVCI : %d\n",bvci_count);
+ printf("***************************************************************\n");
+#elif defined(MNET_GP10)
+ printf("***************************************************************\n");
+ bssgp_net_display_bvci(BSSGP_ROOT_BVCI);
+ printf("***************************************************************\n");
+#endif
+ return (0);
+}
+
+
diff --git a/data/mnet/Common/bssgp/src/bssgp_util.cpp b/data/mnet/Common/bssgp/src/bssgp_util.cpp
new file mode 100644
index 0000000..61db7d5
--- /dev/null
+++ b/data/mnet/Common/bssgp/src/bssgp_util.cpp
@@ -0,0 +1,424 @@
+/****************************************************************************************
+ * *
+ * Copyright Cisco Systems, Inc 2000 All rights reserved *
+ * *
+ * File : bssgp_util.cpp *
+ * *
+ * Description : Utility functions for the BSS-GP layer/module *
+ * *
+ * Author : Dinesh Nambisan *
+ * *
+ *----------------------- Revision history ---------------------------------------------*
+ * Time | Date | Name | Description *
+ *--------------------------------------------------------------------------------------*
+ * 00:00 |10/10/00 | DSN | File created *
+ * | | | *
+ ****************************************************************************************
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "bssgp/bssgp_prot.h"
+#include "bssgp/bssgp_util.h"
+
+
+static char *unknown_str = "UNKNOWN TYPE";
+static char *resvd_str = "Reserved";
+
+/*
+ * bssgp_util_get_iei_str
+ */
+char *
+bssgp_util_get_iei_str(BSSGP_IEI_TYPE iei_type)
+{
+ static char *iei_str[] = {
+ "Alignment octets",
+ "Bmax default MS",
+ "BSS Area Indication",
+ "BVCI",
+ "BVC Bucket Size",
+ "BVC Measurement",
+ "Cause",
+ "Cell Identifier",
+ "Channel needed",
+ "DRX parameters",
+ "eMLPP Priority",
+ "Flush action",
+ "IMSI",
+ "LLC-PDU",
+ "LLC Frames discarded",
+ "Location area",
+ "Mobile Id",
+ "MS Bucket size",
+ "MS Radio Access capability",
+ "OMC Id",
+ "PDU in error",
+ "PDU Lifetime",
+ "Priority",
+ "QoS Profile",
+ "Radio Cause",
+ "RA-Cap-UPD-cause",
+ "Routing area",
+ "R_default_MS",
+ "Suspend reference number",
+ "Tag",
+ "TLLI",
+ "TMSI",
+ "Trace reference",
+ "Trace type",
+ "Transaction Id",
+ "Trigger Id",
+ "Number of octets affected",
+ "LSA Identifier list",
+ "LSA Information",
+ "QoS Parameters",
+ "Location Area Reject Cause"
+ };
+
+ if (iei_type < BSSGP_IEI_MAX_TYPES) {
+ return (iei_str[(int)iei_type]);
+ }
+ else {
+ return (unknown_str);
+ }
+}
+
+
+
+/*
+ * bssgp_util_get_pdu_type_str
+ */
+char *
+bssgp_util_get_pdu_type_str(BSSGP_PDU_TYPE pdu_type)
+{
+ static char pdu_type_str[128];
+ switch(pdu_type) {
+ case BSSGP_PDU_DL_UNITDATA:{
+ strncpy(pdu_type_str,"Downlink Unit Data",128);
+ }
+ break;
+
+ case BSSGP_PDU_UL_UNITDATA:{
+ strncpy(pdu_type_str,"Uplink Unit Data",128);
+ }
+ break;
+
+ case BSSGP_PDU_RA_CAP:{
+ strncpy(pdu_type_str,"Radio Access Capability",128);
+ }
+ break;
+
+ case BSSGP_PDU_PTM_UNITDATA:{
+ strncpy(pdu_type_str,"PTM Unit Data",128);
+ }
+ break;
+
+ case BSSGP_PDU_PAGING_PS:{
+ strncpy(pdu_type_str,"Paging PS",128);
+ }
+ break;
+
+ case BSSGP_PDU_PAGING_CS:{
+ strncpy(pdu_type_str,"Paging CS",128);
+ }
+ break;
+
+ case BSSGP_PDU_RA_CAP_UPDATE:{
+ strncpy(pdu_type_str,"Radio Access Capability Update",128);
+ }
+ break;
+
+ case BSSGP_PDU_RA_CAP_UPDATE_ACK:{
+ strncpy(pdu_type_str,"Radio Acess Capabilty Update ACK",128);
+ }
+ break;
+
+ case BSSGP_PDU_RADIO_STATUS:{
+ strncpy(pdu_type_str,"Radio Status",128);
+ }
+ break;
+
+ case BSSGP_PDU_SUSPEND:{
+ strncpy(pdu_type_str,"Suspend",128);
+ }
+ break;
+
+ case BSSGP_PDU_SUSPEND_ACK:{
+ strncpy(pdu_type_str,"Suspend ACK",128);
+ }
+ break;
+
+ case BSSGP_PDU_SUSPEND_NACK:{
+ strncpy(pdu_type_str,"Suspend NACK",128);
+ }
+ break;
+
+ case BSSGP_PDU_RESUME:{
+ strncpy(pdu_type_str,"Resume",128);
+ }
+ break;
+
+ case BSSGP_PDU_RESUME_ACK:{
+ strncpy(pdu_type_str,"Resume ACK",128);
+ }
+ break;
+
+ case BSSGP_PDU_RESUME_NACK:{
+ strncpy(pdu_type_str,"Resume NACK",128);
+ }
+ break;
+
+ case BSSGP_PDU_BVC_BLOCK:{
+ strncpy(pdu_type_str,"BVC Block",128);
+ }
+ break;
+
+ case BSSGP_PDU_BVC_BLOCK_ACK:{
+ strncpy(pdu_type_str,"BVC Block ACK",128);
+ }
+ break;
+
+ case BSSGP_PDU_RESET:{
+ strncpy(pdu_type_str,"Reset",128);
+ }
+ break;
+
+ case BSSGP_PDU_RESET_ACK:{
+ strncpy(pdu_type_str,"Reset ACK",128);
+ }
+ break;
+
+ case BSSGP_PDU_UNBLOCK:{
+ strncpy(pdu_type_str,"Unblock",128);
+ }
+ break;
+
+ case BSSGP_PDU_UNBLOCK_ACK:{
+ strncpy(pdu_type_str,"Unblock ACK",128);
+ }
+ break;
+
+ case BSSGP_PDU_FLOW_CONTROL_BVC:{
+ strncpy(pdu_type_str,"Flow Control BVC",128);
+ }
+ break;
+
+ case BSSGP_PDU_FLOW_CONTROL_BVC_ACK:{
+ strncpy(pdu_type_str,"Flow Control BVC ACK",128);
+ }
+ break;
+
+ case BSSGP_PDU_FLOW_CONTROL_MS:{
+ strncpy(pdu_type_str,"Flow Control MS",128);
+ }
+ break;
+
+ case BSSGP_PDU_FLOW_CONTROL_MS_ACK:{
+ strncpy(pdu_type_str,"Flow Control MS ACK",128);
+ }
+ break;
+
+ case BSSGP_PDU_FLUSH_LL:{
+ strncpy(pdu_type_str,"Flush LL",128);
+ }
+ break;
+
+ case BSSGP_PDU_FLUSH_LL_ACK:{
+ strncpy(pdu_type_str,"Flush LL ACK",128);
+ }
+ break;
+
+ case BSSGP_PDU_LLC_DISCARDED:{
+ strncpy(pdu_type_str,"LLC Discarded",128);
+ }
+ break;
+
+ case BSSGP_PDU_LOCATION_UPDATE:{
+ strncpy(pdu_type_str,"Location Update",128);
+ }
+ break;
+
+ case BSSGP_PDU_LOCATION_UPDATE_ACK:{
+ strncpy(pdu_type_str,"Location Update Ack",128);
+ }
+ break;
+
+ case BSSGP_PDU_LOCATION_UPDATE_NACK:{
+ strncpy(pdu_type_str,"Location Update Nack",128);
+ }
+ break;
+
+ case BSSGP_PDU_ROUTING_AREA_UPDATE:{
+ strncpy(pdu_type_str,"Routing Area Update",128);
+ }
+ break;
+
+ case BSSGP_PDU_SGSN_INVOKE_TRACE:{
+ strncpy(pdu_type_str,"Invoke Trace",128);
+ }
+ break;
+
+ case BSSGP_PDU_STATUS:{
+ strncpy(pdu_type_str,"Status",128);
+ }
+ break;
+
+ default:{
+ strncpy(pdu_type_str,"Unknown PDU Type",128);
+ }
+ break;
+ }
+ return (pdu_type_str);
+}
+
+
+
+
+
+
+/*
+ * bssgp_util_get_radio_cause_str
+ */
+char *
+bssgp_util_get_radio_cause_str(UINT8 radio_cause)
+{
+ static char radio_cause_str[128];
+ switch(radio_cause) {
+ case RADIO_CAUSE_MS_CONTACT_LOST: {
+ strncpy(radio_cause_str,"Radio contact lost with MS",128);
+ }
+ break;
+ case RADIO_CAUSE_LINK_QUALITY_INSUFFICIENT: {
+ strncpy(radio_cause_str,"Radio link quality insufficient to continue",128);
+ }
+ break;
+ case RADIO_CAUSE_CELL_RESELECTION_ORDERED: {
+ strncpy(radio_cause_str,"Cell reselection ordered",128);
+ }
+ break;
+ default: {
+ strncpy(radio_cause_str,"Unknown : Radio contact lost with MS",128);
+ }
+ break;
+ }
+ return (radio_cause_str);
+}
+
+
+/*
+ * bssgp_util_get_exception_cause_str
+ */
+char *
+bssgp_util_get_exception_cause_str(BSSGP_EXCEPTION_CAUSE cause)
+{
+ static char exception_cause_str[128];
+
+ switch(cause) {
+ case BSSGP_CAUSE_PROCESSOR_OVERLOAD: {
+ strncpy(exception_cause_str,"Processor overload",128);
+ }
+ break;
+ case BSSGP_CAUSE_EQUIPMENT_FAILURE: {
+ strncpy(exception_cause_str,"Equipment failure",128);
+ }
+ break;
+ case BSSGP_CAUSE_TRANSIT_NETWORK_FAILURE: {
+ strncpy(exception_cause_str,"Transit network failure",128);
+ }
+ break;
+ case BSSGP_CAUSE_CAPACITY_MODIFIED: {
+ strncpy(exception_cause_str,"Network service modified from 0 to greater",128);
+ }
+ break;
+ case BSSGP_CAUSE_UNKNOWN_MS: {
+ strncpy(exception_cause_str,"Unknown MS",128);
+ }
+ break;
+ case BSSGP_CAUSE_BVCI_UNKNOWN: {
+ strncpy(exception_cause_str,"BVCI unknown",128);
+ }
+ break;
+ case BSSGP_CAUSE_CELL_TRAFFIC_CONGESTION: {
+ strncpy(exception_cause_str,"Cell traffic congestion",128);
+ }
+ break;
+ case BSSGP_CAUSE_SGSN_CONGESTION: {
+ strncpy(exception_cause_str,"SGSN congestion",128);
+ }
+ break;
+ case BSSGP_CAUSE_OAM_INTERVENTION: {
+ strncpy(exception_cause_str,"O & M intervention",128);
+ }
+ break;
+ case BSSGP_CAUSE_BVCI_BLOCKED: {
+ strncpy(exception_cause_str,"BVCI blocked",128);
+ }
+ break;
+ case BSSGP_CAUSE_SEMANTICALLY_INCORRECT_PDU: {
+ strncpy(exception_cause_str,"Semantically incorrect PDU",128);
+ }
+ break;
+ case BSSGP_CAUSE_INVALID_MANDATORY_INFO: {
+ strncpy(exception_cause_str,"Invalid mandatory information",128);
+ }
+ break;
+ case BSSGP_CAUSE_MISSING_MANDATORY_IE: {
+ strncpy(exception_cause_str,"Missing mandatory IE",128);
+ }
+ break;
+ case BSSGP_CAUSE_MISSING_CONDITIONAL_IE: {
+ strncpy(exception_cause_str,"Missing conditional IE",128);
+ }
+ break;
+ case BSSGP_CAUSE_UNEXPECTED_CONDITIONAL_IE: {
+ strncpy(exception_cause_str,"Unexpected conditional IE",128);
+ }
+ break;
+ case BSSGP_CAUSE_CONDITIONAL_IE_ERROR: {
+ strncpy(exception_cause_str,"Conditional IE error",128);
+ }
+ break;
+ case BSSGP_CAUSE_PDU_NOT_COMPAT_PROTOCOL_STATE: {
+ strncpy(exception_cause_str,"PDU not compatible with protocol state",128);
+ }
+ break;
+ case BSSGP_CAUSE_PROTOCOL_ERROR_UNSPECIFIED:
+ default: {
+ strncpy(exception_cause_str,"Protocol error - unspecified",128);
+ }
+ break;
+ }
+ return (exception_cause_str);
+}
+
+
+/*
+ * bssgp_util_get_ra_cap_cause_str
+ */
+char *
+bssgp_util_get_ra_cap_cause_str(RA_CAP_UPD_CAUSE ra_cause)
+{
+ static char ra_cap_cause_str[128];
+ switch (ra_cause) {
+ case RA_CAP_UPD_CAUSE_IE_PRESENT:{
+ strncpy(ra_cap_cause_str,"OK, RA capability IE present",128);
+ }
+ break;
+ case RA_CAP_UPD_CAUSE_TLLI_UNKNOWN:{
+ strncpy(ra_cap_cause_str,"TLLI unknown in SGSN",128);
+ }
+ break;
+ case RA_CAP_UPD_CAUSE_NO_RA_CAP:{
+ strncpy(ra_cap_cause_str,"No RA capabilities available for this MS",128);
+ }
+ break;
+ default:{
+ strncpy(ra_cap_cause_str,"Unknown - TLLI unknown in SGSN",128);
+ }
+ break;
+ }
+ return (ra_cap_cause_str);
+}
+
+
+
diff --git a/data/mnet/Common/bssgp/win32test/bssgpwin32.cpp b/data/mnet/Common/bssgp/win32test/bssgpwin32.cpp
new file mode 100644
index 0000000..fcfe972
--- /dev/null
+++ b/data/mnet/Common/bssgp/win32test/bssgpwin32.cpp
@@ -0,0 +1,524 @@
+/****************************************************************************************
+ * *
+ * Copyright Cisco Systems, Inc 2000 All rights reserved *
+ * *
+ * File : bssgpwin32.cpp *
+ * *
+ * Description : Win32 test program for the BSS-GP layer/module *
+ * *
+ * Author : Dinesh Nambisan *
+ * *
+ *----------------------- Revision history ---------------------------------------------*
+ * Time | Date | Name | Description *
+ *--------------------------------------------------------------------------------------*
+ * 00:00 |10/10/00 | DSN | File created *
+ * | | | *
+ ****************************************************************************************
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <windows.h>
+#include <winsock.h>
+#include "bssgp\bssgp_prot.h"
+#include "bssgp\bssgp_util.h"
+#include "bssgp\bssgp_decoder.h"
+#include "bssgp\bssgp_encoder.h"
+
+#include "bssgp\bssgp_api.h"
+#include "bssgp\bssgp_unitdata.h"
+#include "ril3\ril3_sm_msg.h"
+
+
+/* test-tool configuration struct */
+typedef struct {
+
+ char gs_ip_addr[32];
+ SOCKET msg_socket;
+ int msg_num;
+
+} BSSGPWIN32_CONFIG;
+
+
+
+/*
+ * The Enumeration of the test messages
+ */
+typedef enum {
+
+
+ GPRS_MIN_TEST_MSG_NUM = 0,
+ GPRS_TEST_MSG_SCRAP_UL_UNITDATA = 1,
+ GPRS_TEST_ATTACH_REQ_UL_UNITDATA = 2,
+
+ GPRS_MAX_TEST_MSGS
+
+} GPRS_TEST_MSG;
+
+
+/*
+ * Global variables
+ */
+unsigned short g_debug_level=0, g_debug_device=1; /* debug flags required by dbgout.cpp */
+BSSGPWIN32_CONFIG config;
+char llc_pdu [1500];
+
+
+/*
+ * Function prototypes
+ */
+BOOL socklib_open_sock(void);
+void socklib_close_sock(void);
+void socklib_send_data(UINT8 *msg,UINT16 len);
+void socklib_recv_data(UINT8 *msg,UINT16 *len);
+BOOL socklib_initialize(void);
+void socklib_shutdown(void);
+BOOL bssgpwin32_parse_command_line_arguments(int argc, char **argv);
+void bssgpwin32_display_usage(void);
+BOOL WINAPI ctrl_brk_handler(DWORD dwCtrlType);
+void bssgpwin32_set_test_msg(BSSGP_API_MSG *api_msg);
+
+
+unsigned char LlcFrameUIAttachReq [] =
+{ 0x41, 0xC0, 0x01, 0x08, 0x01, 0x01, 0x88, 0x01, 0x10, 0x07,
+ 0x05, 0x04, 0x21, 0x43, 0x65, 0xF7, 0x00, 0x11, 0x00, 0x00,
+ 0x01, 0x01, 0x05, 0x22, 0x63, 0x00, 0x20, 0x00, 0xB4, 0x5D,
+ 0x54
+};
+
+main(int argc, char **argv)
+{
+
+ BOOL status;
+ BSSGP_API_MSG api_msg;
+ UINT16 msg_len=0;
+ BSSGP_BVCI bvci;
+ BSSGP_NETWORK_QOS_LEVEL qos_reqd;
+ BOOL tx_msg=FALSE;
+ UINT8 tx_buff[1024], rx_buff[1024];
+
+ if (!bssgpwin32_parse_command_line_arguments(argc,argv)) {
+ printf("Invalid arguments!\n");
+ bssgpwin32_display_usage();
+ return(0);
+ }
+
+ if (!(SetConsoleCtrlHandler(ctrl_brk_handler,TRUE))) {
+ printf("Cannot set ctrl-break handler,aborting\n");
+ return(0);
+ }
+
+ if (!socklib_initialize()) {
+ printf("Unable to initialize Sockets library\n");
+ return(0);
+ }
+
+ if (!socklib_open_sock()) {
+ printf("Unable to create a socket\n");
+ socklib_shutdown();
+ return(0);
+ }
+
+
+ memset(&api_msg,0,sizeof(api_msg));
+
+ bssgpwin32_set_test_msg(&api_msg);
+
+
+ status = bssgp_encode_msg(&api_msg,tx_buff,&msg_len,
+ &bvci,&qos_reqd, &tx_msg);
+
+ if (!status) {
+ printf("Error encoding BSSGP message!\n");
+ socklib_close_sock();
+ socklib_shutdown();
+ return(0);
+ }
+
+ socklib_send_data((UINT8*)tx_buff,msg_len);
+
+ msg_len = 1024;
+
+ socklib_recv_data((UINT8*)rx_buff,&msg_len);
+
+
+ return (0);
+
+}
+
+
+
+
+/*
+ * socklib_open_sock
+ */
+BOOL
+socklib_open_sock()
+{
+ SOCKET conn_socket;
+ int status;
+ struct sockaddr_in local_addr, gs_addr;
+
+ conn_socket = socket(AF_INET,SOCK_DGRAM,0);
+ if (conn_socket == INVALID_SOCKET) {
+ printf("Unable to create a UDP socket, error %d\n",WSAGetLastError());
+ return(FALSE);
+ }
+
+ memset(&local_addr,0,sizeof(local_addr));
+ local_addr.sin_addr.S_un.S_addr = INADDR_ANY;
+ local_addr.sin_port = htons(24240);
+ local_addr.sin_family = AF_INET;
+
+ status = bind(conn_socket,(struct sockaddr*)&local_addr,sizeof(local_addr));
+ if (status == SOCKET_ERROR) {
+ printf("Unable to bind UDP socket, error %d\n",WSAGetLastError());
+ closesocket(conn_socket);
+ return(FALSE);
+ }
+
+ memset(&gs_addr,0,sizeof(gs_addr));
+ gs_addr.sin_addr.S_un.S_addr = inet_addr(config.gs_ip_addr);
+ gs_addr.sin_port = htons(24240);
+ gs_addr.sin_family = AF_INET;
+
+ status = connect(conn_socket,(struct sockaddr*)&gs_addr,sizeof(gs_addr));
+ if (status == SOCKET_ERROR) {
+ printf("Unable to connect UDP socket, error %d\n",WSAGetLastError());
+ closesocket(conn_socket);
+ return(FALSE);
+ }
+ printf("Setup IP path to GS server successfully\n");
+ config.msg_socket = conn_socket;
+ return (TRUE);
+
+}
+
+
+/*
+ * socklib_close_sock
+ */
+void
+socklib_close_sock()
+{
+ closesocket(config.msg_socket);
+}
+
+
+/*
+ * socklib_send_data
+ */
+void
+socklib_send_data(UINT8 *msg,UINT16 len)
+{
+ int status;
+
+ status = send(config.msg_socket,(char*)msg,len,0);
+ if (status == SOCKET_ERROR) {
+ printf("Unable to send data on UDP socket, error %d\n",WSAGetLastError());
+ }
+ else {
+ printf("Sent %d bytes of data on UDP socket\n",len);
+ }
+ return;
+}
+
+
+
+/*
+ * socklib_recv_data
+ */
+void
+socklib_recv_data(UINT8 *msg,UINT16 *len)
+{
+ int status;
+ BOOL free_buff=TRUE;
+
+ status = recv(config.msg_socket,(char*)msg,*len,0);
+ if (status == SOCKET_ERROR) {
+ printf("Unable to recv data on UDP socket, error %d\n",WSAGetLastError());
+ }
+ else {
+ printf("Received %d bytes of data on UDP socket;running it through BSSGP decoder\n",status);
+
+ if (!bssgp_decode_msg(msg,status,TRUE,(BSSGP_NETWORK_QOS_LEVEL)0,0,&free_buff)) {
+ printf("Error decoding BSSGP msg\n");
+ }
+
+ *len = status;
+ }
+ return;
+}
+
+
+
+
+
+/*
+ * socklib_initialize
+ */
+BOOL
+socklib_initialize()
+{
+ BOOL status = FALSE;
+ WORD wVersionRequested;
+ WSADATA wsaData;
+ int ret_status;
+ wVersionRequested = MAKEWORD( 2, 2 );
+
+ ret_status = WSAStartup( wVersionRequested, &wsaData );
+ if (ret_status != 0) {
+ status = FALSE;
+ }
+ else {
+ status = TRUE;
+ }
+ return(status);
+}
+
+
+
+/*
+ * socklib_shutdown
+ */
+void
+socklib_shutdown()
+{
+ WSACleanup();
+ return;
+}
+
+
+/*
+ * bssgpwin32_parse_command_line_arguments
+ */
+BOOL
+bssgpwin32_parse_command_line_arguments(int argc, char **argv)
+{
+ BOOL satisfied=FALSE;
+ BOOL ret_status = FALSE, msg_num_specified=FALSE,gs_ip_specified=FALSE;
+ int counter=1;
+ if (argc < 2) {
+ printf("Not enough arguments\n");
+ return ret_status;
+ }
+
+ while (!satisfied) {
+ if (stricmp(argv[counter],"-gs") == 0) {
+ if (argc < (counter+2)) goto bye_bye_jose;
+ strcpy(config.gs_ip_addr,argv[counter+1]);
+ gs_ip_specified=TRUE;
+ counter+=2;
+ }
+ else if (stricmp(argv[counter],"-msg") == 0) {
+ if (argc < (counter+2)) goto bye_bye_jose;
+ config.msg_num = atoi(argv[counter+1]);
+
+ if ( (config.msg_num <= GPRS_MIN_TEST_MSG_NUM) || (config.msg_num >= GPRS_MAX_TEST_MSGS)) {
+ printf("Unknown/Invalid message template # specified\n");
+ return (FALSE);
+ }
+ counter+=2;
+ msg_num_specified=TRUE;
+ }
+ else {
+ bye_bye_jose:printf("Invalid arguments!\n");
+ memset(&config,0,sizeof(config));
+ return ret_status;
+ }
+
+ if (counter == argc) satisfied = TRUE;
+ }
+ if (!gs_ip_specified) {
+ printf("Need to specify the GS ip address\n");
+ return (ret_status);
+ }
+
+ if (!msg_num_specified) {
+ printf("Need to specify the Message template number\n");
+ return (ret_status);
+ }
+ if (satisfied) ret_status = TRUE;
+
+ return (ret_status);
+}
+
+
+
+/*
+ * bssgpwin32_display_usage
+ */
+void
+bssgpwin32_display_usage()
+{
+ printf("\n");
+ printf("|*************** BSSGPWin32 Version 1.0 (c) Cisco 2000-2001 ***************************|\n");
+ printf("|---------------------------------------------------------------------------------------|\n");
+ printf("|>bssgp -gs <a.b.c.d> -msg x |\n");
+ printf("|---------------------------------------------------------------------------------------|\n");
+ printf("| -gs <a.b.c.d> : Use a.b.c.d as the GS IP address |\n");
+ printf("| -msg x : Send pre-defined message x |\n");
+ printf("|---------------------------------------------------------------------------------------|\n");
+ printf("\n");
+}
+
+
+/*
+ * ctrl_brk_handler
+ */
+BOOL WINAPI
+ctrl_brk_handler(DWORD dwCtrlType)
+{
+ printf("Ctrl-Break keys presses, exiting application\n");
+ closesocket(config.msg_socket);
+ return(TRUE);
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/*
+ * bssgpwin32_set_test_msg
+ *
+ * This function to be modified to add new test messages...
+ *
+ *
+ *
+ */
+void
+bssgpwin32_set_test_msg(BSSGP_API_MSG *api_msg)
+{
+ unsigned frameLength;
+
+ /*
+ * Most of these values are pretty much going to be the same
+ * for most test msgs, except the GMM<->GMM signalling msgs,
+ * and the person creating those test msgs needs to contact
+ * me first : Dinesh
+ */
+ api_msg->magic = BSSGP_MAGIC;
+ api_msg->msg_type = BSSGP_API_MSG_UL_UNITDATA;
+ api_msg->msg.ul_unitdata.bvci = 0;
+ api_msg->msg.ul_unitdata.cell_id.ie_present = TRUE;
+ api_msg->msg.ul_unitdata.cell_id.value = 21; /* dunno, some random cell id */
+ api_msg->msg.ul_unitdata.qos_profile.ie_present = TRUE;
+ api_msg->msg.ul_unitdata.qos_profile.bucket_leak_rate[0] = 1;
+ api_msg->msg.ul_unitdata.qos_profile.bucket_leak_rate[1] = 1;
+ api_msg->msg.ul_unitdata.qos_profile.precedence_class = CNI_RIL3_QOS_PRECEDENCE_CLASS_HIGH_PRIORITY;
+ api_msg->msg.ul_unitdata.qos_profile.a_bit = RADIO_INT_USES_RLC_MAX_UDT;
+ api_msg->msg.ul_unitdata.qos_profile.t_bit = SDU_CONTAINS_SIGNALLING;
+ api_msg->msg.ul_unitdata.qos_profile.cr_bit = SDU_LLC_ACK_SACK_ABSENT;
+
+ api_msg->msg.ul_unitdata.tlli = 1; /* for lack of a better choice ;-) */
+
+
+
+ /*
+ * Here is the part where you actually stick in the upper layer
+ * message (handcoded or otherwise) as a byte-stream....
+ * You also need to add your message template number to the enumeration
+ * at the beginning of this file called GPRS_TEST_MSG, and add that option
+ * to the switch statement below...
+ */
+
+ switch(config.msg_num) {
+
+ case GPRS_TEST_MSG_SCRAP_UL_UNITDATA: {
+ printf("Sending pre-defined message template #1 : Scrap UL-Unitdata\n");
+ memset(llc_pdu,'A',256);
+ api_msg->msg.ul_unitdata.pdu.data = (UINT8*)llc_pdu;
+ api_msg->msg.ul_unitdata.pdu.data_len = 256;
+
+ }
+ break;
+
+ case GPRS_TEST_ATTACH_REQ_UL_UNITDATA:
+
+ memset (llc_pdu, 0, 1500);
+ frameLength = (sizeof(LlcFrameUIAttachReq)/sizeof(LlcFrameUIAttachReq[0]));
+
+ printf ("Sending pre-defined message template #2: Attach Request (Frame length %d)\n",
+ frameLength);
+
+ memcpy (llc_pdu, LlcFrameUIAttachReq, frameLength);
+
+ api_msg->msg.ul_unitdata.pdu.data = (UINT8*)llc_pdu;
+ api_msg->msg.ul_unitdata.pdu.data_len = frameLength;
+
+ DbgHexDump ((unsigned char*)api_msg->msg.ul_unitdata.pdu.data, api_msg->msg.ul_unitdata.pdu.data_len);
+
+ break;
+
+ default: {
+ printf("Unknown message template # specified !!\n");
+ socklib_close_sock();
+ socklib_shutdown();
+ exit(0);
+ }
+ } /* End of switch */
+}
+
+
+
+/*
+ * bssgp_api_send_ul_unitdata
+ */
+void
+bssgp_api_send_ul_unitdata(TLLI tlli,T_CNI_RIL3_IE_CELL_ID cell_id,UINT8 *pdu_data,UINT16 pdu_len)
+{
+
+ printf("Do something here ;-) \n");
+}
+
+
+
+
+
+/*
+ * bssgp_util_get_rx_buff
+ */
+char *
+bssgp_util_get_rx_buff(int buff_size_reqd)
+{
+ char *return_buff=NULL;
+ return_buff = (char*)malloc(buff_size_reqd);
+ return (return_buff);
+}
+
+
+/*
+ * bssgp_util_return_rx_buff
+ */
+void
+bssgp_util_return_rx_buff(char *buff)
+{
+ free(buff);
+}
+
+
+
+
+/*
+ * llcwin32_pdu_handler
+ */
+void
+llcwin32_pdu_handler(LLC_PDU pdu)
+{
+ int count,index=0;
+ printf("LLC PDU of length %d\n",pdu.data_len);
+
+ DbgHexDump ((unsigned char*)pdu.data, pdu.data_len);
+
+ printf("End of LLC PDU\n");
+}
diff --git a/data/mnet/Common/bssgp/win32test/gprstest/gprstest.mak b/data/mnet/Common/bssgp/win32test/gprstest/gprstest.mak
new file mode 100644
index 0000000..cd07979
--- /dev/null
+++ b/data/mnet/Common/bssgp/win32test/gprstest/gprstest.mak
@@ -0,0 +1,238 @@
+# Microsoft Developer Studio Generated NMAKE File, Based on gprstest.dsp
+!IF "$(CFG)" == ""
+CFG=gprstest - Win32 Debug
+!MESSAGE No configuration specified. Defaulting to gprstest - Win32 Debug.
+!ENDIF
+
+!IF "$(CFG)" != "gprstest - Win32 Release" && "$(CFG)" != "gprstest - Win32 Debug"
+!MESSAGE Invalid configuration "$(CFG)" specified.
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "gprstest.mak" CFG="gprstest - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "gprstest - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "gprstest - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE
+!ERROR An invalid configuration is specified.
+!ENDIF
+
+!IF "$(OS)" == "Windows_NT"
+NULL=
+!ELSE
+NULL=nul
+!ENDIF
+
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "gprstest - Win32 Release"
+
+OUTDIR=.\Release
+INTDIR=.\Release
+# Begin Custom Macros
+OutDir=.\Release
+# End Custom Macros
+
+ALL : "$(OUTDIR)\gprstest.exe"
+
+
+CLEAN :
+ -@erase "$(INTDIR)\bssgp_decoder.obj"
+ -@erase "$(INTDIR)\bssgp_encoder.obj"
+ -@erase "$(INTDIR)\bssgp_ie_decoder.obj"
+ -@erase "$(INTDIR)\bssgp_ie_encoder.obj"
+ -@erase "$(INTDIR)\bssgp_unitdata.obj"
+ -@erase "$(INTDIR)\bssgp_util.obj"
+ -@erase "$(INTDIR)\bssgpwin32.obj"
+ -@erase "$(INTDIR)\dbgout.obj"
+ -@erase "$(INTDIR)\vc60.idb"
+ -@erase "$(OUTDIR)\gprstest.exe"
+
+"$(OUTDIR)" :
+ if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
+
+CPP_PROJ=/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /Fp"$(INTDIR)\gprstest.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
+BSC32=bscmake.exe
+BSC32_FLAGS=/nologo /o"$(OUTDIR)\gprstest.bsc"
+BSC32_SBRS= \
+
+LINK32=link.exe
+LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:no /pdb:"$(OUTDIR)\gprstest.pdb" /machine:I386 /out:"$(OUTDIR)\gprstest.exe"
+LINK32_OBJS= \
+ "$(INTDIR)\bssgp_util.obj" \
+ "$(INTDIR)\bssgp_encoder.obj" \
+ "$(INTDIR)\bssgp_ie_decoder.obj" \
+ "$(INTDIR)\bssgp_ie_encoder.obj" \
+ "$(INTDIR)\bssgp_unitdata.obj" \
+ "$(INTDIR)\bssgp_decoder.obj" \
+ "$(INTDIR)\dbgout.obj" \
+ "$(INTDIR)\bssgpwin32.obj"
+
+"$(OUTDIR)\gprstest.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
+ $(LINK32) @<<
+ $(LINK32_FLAGS) $(LINK32_OBJS)
+<<
+
+!ELSEIF "$(CFG)" == "gprstest - Win32 Debug"
+
+OUTDIR=.
+INTDIR=.
+# Begin Custom Macros
+OutDir=.
+# End Custom Macros
+
+ALL : "$(OUTDIR)\gprstest.exe"
+
+
+CLEAN :
+ -@erase "$(INTDIR)\bssgp_decoder.obj"
+ -@erase "$(INTDIR)\bssgp_encoder.obj"
+ -@erase "$(INTDIR)\bssgp_ie_decoder.obj"
+ -@erase "$(INTDIR)\bssgp_ie_encoder.obj"
+ -@erase "$(INTDIR)\bssgp_unitdata.obj"
+ -@erase "$(INTDIR)\bssgp_util.obj"
+ -@erase "$(INTDIR)\bssgpwin32.obj"
+ -@erase "$(INTDIR)\dbgout.obj"
+ -@erase "$(INTDIR)\vc60.idb"
+ -@erase "$(INTDIR)\vc60.pdb"
+ -@erase "$(OUTDIR)\gprstest.exe"
+ -@erase "$(OUTDIR)\gprstest.ilk"
+ -@erase "$(OUTDIR)\gprstest.pdb"
+
+CPP_PROJ=/nologo /MLd /W3 /Gm /GX /ZI /Od /I "\common\include" /I "\common\bssgp\win32test" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Fp"$(INTDIR)\gprstest.pch" /YX /FD /GZ /c
+BSC32=bscmake.exe
+BSC32_FLAGS=/nologo /o"$(OUTDIR)\gprstest.bsc"
+BSC32_SBRS= \
+
+LINK32=link.exe
+LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib wsock32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:yes /pdb:"$(OUTDIR)\gprstest.pdb" /debug /machine:I386 /out:"$(OUTDIR)\gprstest.exe" /pdbtype:sept
+LINK32_OBJS= \
+ "$(INTDIR)\bssgp_util.obj" \
+ "$(INTDIR)\bssgp_encoder.obj" \
+ "$(INTDIR)\bssgp_ie_decoder.obj" \
+ "$(INTDIR)\bssgp_ie_encoder.obj" \
+ "$(INTDIR)\bssgp_unitdata.obj" \
+ "$(INTDIR)\bssgp_decoder.obj" \
+ "$(INTDIR)\dbgout.obj" \
+ "$(INTDIR)\bssgpwin32.obj"
+
+"$(OUTDIR)\gprstest.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
+ $(LINK32) @<<
+ $(LINK32_FLAGS) $(LINK32_OBJS)
+<<
+
+!ENDIF
+
+.c{$(INTDIR)}.obj::
+ $(CPP) @<<
+ $(CPP_PROJ) $<
+<<
+
+.cpp{$(INTDIR)}.obj::
+ $(CPP) @<<
+ $(CPP_PROJ) $<
+<<
+
+.cxx{$(INTDIR)}.obj::
+ $(CPP) @<<
+ $(CPP_PROJ) $<
+<<
+
+.c{$(INTDIR)}.sbr::
+ $(CPP) @<<
+ $(CPP_PROJ) $<
+<<
+
+.cpp{$(INTDIR)}.sbr::
+ $(CPP) @<<
+ $(CPP_PROJ) $<
+<<
+
+.cxx{$(INTDIR)}.sbr::
+ $(CPP) @<<
+ $(CPP_PROJ) $<
+<<
+
+
+!IF "$(NO_EXTERNAL_DEPS)" != "1"
+!IF EXISTS("gprstest.dep")
+!INCLUDE "gprstest.dep"
+!ELSE
+!MESSAGE Warning: cannot find "gprstest.dep"
+!ENDIF
+!ENDIF
+
+
+!IF "$(CFG)" == "gprstest - Win32 Release" || "$(CFG)" == "gprstest - Win32 Debug"
+SOURCE=..\..\src\bssgp_decoder.cpp
+
+!IF "$(CFG)" == "gprstest - Win32 Release"
+
+CPP_SWITCHES=/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /Fp"$(INTDIR)\gprstest.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
+
+"$(INTDIR)\bssgp_decoder.obj" : $(SOURCE) "$(INTDIR)"
+ $(CPP) @<<
+ $(CPP_SWITCHES) $(SOURCE)
+<<
+
+
+!ELSEIF "$(CFG)" == "gprstest - Win32 Debug"
+
+CPP_SWITCHES=/nologo /MLd /W3 /Gm /GX /ZI /Od /I "\common\include" /I "\common\bssgp\win32test" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Fp"$(INTDIR)\gprstest.pch" /YX /FD /GZ /c
+
+"$(INTDIR)\bssgp_decoder.obj" : $(SOURCE) "$(INTDIR)"
+ $(CPP) @<<
+ $(CPP_SWITCHES) $(SOURCE)
+<<
+
+
+!ENDIF
+
+SOURCE=..\..\src\bssgp_encoder.cpp
+
+"$(INTDIR)\bssgp_encoder.obj" : $(SOURCE) "$(INTDIR)"
+ $(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+SOURCE=..\..\src\bssgp_ie_decoder.cpp
+
+"$(INTDIR)\bssgp_ie_decoder.obj" : $(SOURCE) "$(INTDIR)"
+ $(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+SOURCE=..\..\src\bssgp_ie_encoder.cpp
+
+"$(INTDIR)\bssgp_ie_encoder.obj" : $(SOURCE) "$(INTDIR)"
+ $(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+SOURCE=..\..\src\bssgp_unitdata.cpp
+
+"$(INTDIR)\bssgp_unitdata.obj" : $(SOURCE) "$(INTDIR)"
+ $(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+SOURCE=..\..\src\bssgp_util.cpp
+
+"$(INTDIR)\bssgp_util.obj" : $(SOURCE) "$(INTDIR)"
+ $(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+SOURCE=..\bssgpwin32.cpp
+
+"$(INTDIR)\bssgpwin32.obj" : $(SOURCE) "$(INTDIR)"
+ $(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+SOURCE=..\dbgout.cpp
+
+"$(INTDIR)\dbgout.obj" : $(SOURCE) "$(INTDIR)"
+ $(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+
+!ENDIF
+
diff --git a/data/mnet/Common/cdr/Makefile b/data/mnet/Common/cdr/Makefile
new file mode 100644
index 0000000..21cc2e2
--- /dev/null
+++ b/data/mnet/Common/cdr/Makefile
@@ -0,0 +1,47 @@
+##########################################################
+#
+# (c) Copyright Cisco 2000
+# All Rights Reserved
+#
+# Use Examples:
+#
+# Case 1:
+# make all VOB=GP10 -
+# Places .out in VOB/bin directory
+#
+# Case 2:
+# make all VOB=GP10 APPDIR=Host\<Application Name>\<Source Directory> -
+# Places .o file(s) in VOB\$(APPDIR)\bin directory.
+#
+# <Application Name> = Name of Application directory
+# <Source Directory> = application sub directory where the calling
+# Makefile resides.
+#
+# Example: make all VOB=GP10 APPDIR=Host\vxTemplate\src
+#
+# (OPTIONAL) Append REPLACE - Replaces the List of directories
+# to be used in the SUBDIRS variable
+#
+# Example: make all VOB=GP10 APPDIR=Host\vxTemplate\src REPLACE="src_api src_debug"
+#
+# Note: This make file must reference a VOB that
+# has a defs.mk in the top level directory.
+#
+##########################################################
+
+SUBDIRS = src src_client src_server
+
+# TOP_OF_VOB must be defined before including l3defs.mk
+TOP_OF_VOB = ..
+
+VOBDIR = $(TOP_OF_VOB)/../$(VOB)
+
+# Allows a sub-set of the source code directories to be used
+
+ifneq ($(REPLACE),)
+ SUBDIRS = $(REPLACE)
+endif
+
+include $(VOBDIR)\l3defs.mk
+
+
diff --git a/data/mnet/Common/cdr/certificate/Readme.txt b/data/mnet/Common/cdr/certificate/Readme.txt
new file mode 100644
index 0000000..170c88b
--- /dev/null
+++ b/data/mnet/Common/cdr/certificate/Readme.txt
@@ -0,0 +1,2 @@
+This directory contains default certificate, key and password files for the MNET CDR subsystem.
+Encrypted password is "cdr_password". \ No newline at end of file
diff --git a/data/mnet/Common/cdr/certificate/ca.pem b/data/mnet/Common/cdr/certificate/ca.pem
new file mode 100644
index 0000000..5571166
--- /dev/null
+++ b/data/mnet/Common/cdr/certificate/ca.pem
@@ -0,0 +1,18 @@
+-----BEGIN CERTIFICATE-----
+MIIC0jCCAjugAwIBAgIBADANBgkqhkiG9w0BAQQFADCBrjELMAkGA1UEBhMCVVMx
+EzARBgNVBAgTCkNhbGlmb3JuaWExETAPBgNVBAcTCFNhbiBKb3NlMRwwGgYDVQQK
+ExNDSVNDTyBTeXN0ZW1zLCBJbmMuMQwwCgYDVQQLEwNNV0cxKTAnBgNVBAMTIENJ
+U0NPIE1ORVQgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MSAwHgYJKoZIhvcNAQkBFhFz
+dXBwb3J0QGNpc2NvLmNvbTAeFw0wMTA3MjQwMTU4MTZaFw0wMjA3MjQwMTU4MTZa
+MIGuMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTERMA8GA1UEBxMI
+U2FuIEpvc2UxHDAaBgNVBAoTE0NJU0NPIFN5c3RlbXMsIEluYy4xDDAKBgNVBAsT
+A01XRzEpMCcGA1UEAxMgQ0lTQ08gTU5FVCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkx
+IDAeBgkqhkiG9w0BCQEWEXN1cHBvcnRAY2lzY28uY29tMIGfMA0GCSqGSIb3DQEB
+AQUAA4GNADCBiQKBgQCz+izH0Rff1+xzN3QWcxAwLdhBagel0q5rsxuS5PZofSkx
+FVTFx00I759+bXrBVOGFki4M9vlhDscrihwnL5mH3Eh8U0HcB0ec9nPY0fGj5XZ0
+NLetHmoUoTyXR8sPxvR3iaLJSbftl5H9/LJLZ1ZWsQWxrm3wUGNNRAfYq2c9GQID
+AQABMA0GCSqGSIb3DQEBBAUAA4GBAENH4Ck+zskqIm6iTm1iS+b6R2JNiWXRsaib
+ANoq+D6lw0kT1hPvQ0DF9LgcaE+b3FeyI8afie3snSX+7OKDzo//hSpeXUxMBu7G
+mt43B7cNOVzIrADHJUSYdMwHZYLrS2HGHEkA71QAQJ7q9X+kVRBzbsFZftNFfiGk
+mrUxmRSi
+-----END CERTIFICATE-----
diff --git a/data/mnet/Common/cdr/certificate/ca_cert/cakey.pem b/data/mnet/Common/cdr/certificate/ca_cert/cakey.pem
new file mode 100644
index 0000000..95fa181
--- /dev/null
+++ b/data/mnet/Common/cdr/certificate/ca_cert/cakey.pem
@@ -0,0 +1,18 @@
+-----BEGIN RSA PRIVATE KEY-----
+Proc-Type: 4,ENCRYPTED
+DEK-Info: DES-EDE3-CBC,63A6C5E14DF8F30B
+
+KumNLa3hHfOLuZU1It0ZSaMGFoRVyvzlt1BbmwP1r5IYZd7evHOOzrJsOhJ32UHY
+QVWmLgMEv+0FigRw8wqUhW8QT3Wohrd0kTEoxXPrENzK3K6g+/HlBvBhjci6BUjP
+HfE+qJ6dDsc/oIUTDqoZJwf+M8mlVvOzPALr979EdlFES8MrZj7hT0LLHO4xyhdn
+jSbgEbPimCR3AybuniPjpPHuNs2hGcQZ4lEZ/rl78OQIW3CLvqRWrZhZmuzzNMPx
+61vv/ezaX8iXdg5bkz34qE/2KNsmXH+wLRWkU9unYdoxisjhesvaRhNQKkQ6onBX
+jn8eDRHg+4ortHMQVWTETsPl/b3QVZXO4w6e1A08MVFhFiHt+uTEd/XP0wjgHICs
+llBcjPP90kOmRG8UJT0mwfUtsR26C3eZ5BUz2H8uxRRSPMU1Iwro4XvuD8Jtv9uU
+TJycEA+82BBfu94jEE4MLx+6h35mmf9HldaXb3ZONd9Ji34IBF+cp4+Wf3Fjsaj2
+k6FQO/ib4N3FZF8fEa/dcpbN1kBzXJTyy56i5wIskQHWe4yEgfT9NeBP/SyNG9KZ
+ZFaUR5Dqmuy2e2BG7TBC2dLDJ7q3SYGqTyi1S0Vp352kqKmwgNIi76nnZdWWcL4T
+Gt8WMEVpp+1rroXGHpliZ3GsN4AqdaT7IsEqWWk8fXiYlkYcKdjjzGWTQ96CBwz9
+KsL5eAqyRA2bnS+veUhEC5ZAzu7ATaDb+YmY2L+sa0jALqIw2Vw/JxM1FwuFvcp6
+e99uudN6LipqOolOs1aO5SAW2WeulfuNIrvNm2gabqKhpyNHU8oLPg==
+-----END RSA PRIVATE KEY-----
diff --git a/data/mnet/Common/cdr/certificate/cdrpwd.dat b/data/mnet/Common/cdr/certificate/cdrpwd.dat
new file mode 100644
index 0000000..7a3205c
--- /dev/null
+++ b/data/mnet/Common/cdr/certificate/cdrpwd.dat
Binary files differ
diff --git a/data/mnet/Common/cdr/certificate/cert.pem b/data/mnet/Common/cdr/certificate/cert.pem
new file mode 100644
index 0000000..68b7290
--- /dev/null
+++ b/data/mnet/Common/cdr/certificate/cert.pem
@@ -0,0 +1,50 @@
+Certificate:
+ Data:
+ Version: 1 (0x0)
+ Serial Number: 6503 (0x1967)
+ Signature Algorithm: md5WithRSAEncryption
+ Issuer: C=US, ST=California, L=San Jose, O=CISCO Systems, Inc., OU=MWG, CN=CISCO MNET Certificate Authority/Email=support@cisco.com
+ Validity
+ Not Before: Jul 24 01:58:18 2001 GMT
+ Not After : Jul 24 01:58:18 2002 GMT
+ Subject: C=US, ST=California, L=San Jose, O=CISCO Systems, Inc., OU=MWG, CN=CISCO MNET CDR USER/Email=support@cisco.com
+ Subject Public Key Info:
+ Public Key Algorithm: rsaEncryption
+ RSA Public Key: (1024 bit)
+ Modulus (1024 bit):
+ 00:e2:a5:09:d8:49:90:1e:0c:0e:ca:f7:e8:b5:b3:
+ 79:c3:d3:33:5d:25:3c:03:c2:9a:6e:4a:09:9c:c1:
+ cc:dc:34:3b:c9:0a:ef:84:45:05:ff:b3:5a:c6:73:
+ 33:9a:08:52:c5:7c:68:6e:f1:24:c9:7d:23:ad:9f:
+ a4:57:8b:63:07:21:bd:c9:f6:3f:b9:65:10:3f:8b:
+ 64:e7:44:d6:41:1e:c7:67:48:42:07:42:0a:df:a4:
+ 79:29:9a:ff:7a:ed:0a:68:e8:3b:eb:f0:e6:a7:bc:
+ 15:27:62:20:53:26:5b:0d:d9:21:f7:38:8d:36:7d:
+ 5d:28:65:a1:b6:9f:4e:24:b3
+ Exponent: 65537 (0x10001)
+ Signature Algorithm: md5WithRSAEncryption
+ 10:19:72:22:6a:94:00:a9:fd:cf:3f:ef:1a:d8:3c:c3:d0:7b:
+ c8:04:92:fe:d2:ef:34:f7:ba:f0:84:a2:34:77:89:c3:5e:7b:
+ 32:be:55:06:06:46:f8:93:72:20:13:d1:b9:4c:da:3b:77:70:
+ 9c:86:29:2d:d9:df:67:47:21:55:88:b8:08:08:bb:bc:33:ec:
+ 02:68:f6:5f:d1:e6:1b:2d:0a:bf:a2:c7:a1:f2:b4:cd:16:29:
+ 4d:55:f0:90:0b:2a:b2:52:1b:9e:6f:46:da:6b:a3:7b:a9:b8:
+ 2d:ad:00:8f:bc:b1:3a:72:b7:52:92:be:7c:31:5d:87:4d:b8:
+ f7:a2
+-----BEGIN CERTIFICATE-----
+MIICwTCCAioCAhlnMA0GCSqGSIb3DQEBBAUAMIGuMQswCQYDVQQGEwJVUzETMBEG
+A1UECBMKQ2FsaWZvcm5pYTERMA8GA1UEBxMIU2FuIEpvc2UxHDAaBgNVBAoTE0NJ
+U0NPIFN5c3RlbXMsIEluYy4xDDAKBgNVBAsTA01XRzEpMCcGA1UEAxMgQ0lTQ08g
+TU5FVCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkxIDAeBgkqhkiG9w0BCQEWEXN1cHBv
+cnRAY2lzY28uY29tMB4XDTAxMDcyNDAxNTgxOFoXDTAyMDcyNDAxNTgxOFowgaEx
+CzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMREwDwYDVQQHEwhTYW4g
+Sm9zZTEcMBoGA1UEChMTQ0lTQ08gU3lzdGVtcywgSW5jLjEMMAoGA1UECxMDTVdH
+MRwwGgYDVQQDExNDSVNDTyBNTkVUIENEUiBVU0VSMSAwHgYJKoZIhvcNAQkBFhFz
+dXBwb3J0QGNpc2NvLmNvbTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA4qUJ
+2EmQHgwOyvfotbN5w9MzXSU8A8KabkoJnMHM3DQ7yQrvhEUF/7NaxnMzmghSxXxo
+bvEkyX0jrZ+kV4tjByG9yfY/uWUQP4tk50TWQR7HZ0hCB0IK36R5KZr/eu0KaOg7
+6/Dmp7wVJ2IgUyZbDdkh9ziNNn1dKGWhtp9OJLMCAwEAATANBgkqhkiG9w0BAQQF
+AAOBgQAQGXIiapQAqf3PP+8a2DzD0HvIBJL+0u8097rwhKI0d4nDXnsyvlUGBkb4
+k3IgE9G5TNo7d3Cchikt2d9nRyFViLgICLu8M+wCaPZf0eYbLQq/oseh8rTNFilN
+VfCQCyqyUhueb0baa6N7qbgtrQCPvLE6crdSkr58MV2HTbj3og==
+-----END CERTIFICATE-----
diff --git a/data/mnet/Common/cdr/certificate/key.pem b/data/mnet/Common/cdr/certificate/key.pem
new file mode 100644
index 0000000..f3b1221
--- /dev/null
+++ b/data/mnet/Common/cdr/certificate/key.pem
@@ -0,0 +1,18 @@
+-----BEGIN RSA PRIVATE KEY-----
+Proc-Type: 4,ENCRYPTED
+DEK-Info: DES-EDE3-CBC,9D40E0AEA9699CC6
+
+o0x1NO0OC0zVke5WybdCdgnBtIm5wagFNHUCgUyj2ONTSDVdr4Aj+Rwa1nZVcxKo
+P3Vs3Juv58dlBUiPuxep7+nFY/W5xlcmt8TCuZwFjQgD4caCHDQ50m2XWq9OJ18Q
+L9Xsytx+KHYFcR7g/zkCYXzVU2D5Z2Mvvdx/vbMllcbjC5pGz0OhfPSe2HfuTzgo
+mHpdy8MfexLjqvGVu+XWvNEb7BkR1LxfKoAo84sIZpT8WvonSQLp19qmY6U65iWu
+cMI2JIgAv+oMa5tbRh51jthrFyVDf2c1cMosVVlK118bQmUjqw816GzmI8ml2n25
+MgW2Zt0j7CSqKX9zqncHpuOxLru3SlwDG2LGhmWJtlAOkaSxdopPw+ZminpHBPyy
+/+xIkzGrPCu6E7nogrmnxnR1lFG80T8OAebsCbumMdvi2WIPNYnL+vhaW++NMXeM
+Fj62dVaIl0+ozM5vr/C/puaVYeBS1+2dZMA+w9eP3r2yp7gn+uQb9BlQrFVG55yJ
+1TInbpYGrD8K3RmMsnY6iL7QyhdsRpXgo/fJOEd/bH89a8Ajuq+wbWz1EX0q4QeD
+LuI+cDOjNt64cHbIFQlYEGUxzvH9+Wdc0aFgFFxpoFR8e+/p/9OVpj4kxJMFdcDI
+CBhyJjIOORC/RBpcquUN//KrlpOuR0kx9W2LRK5+ufotDOSEYKKHXlQPKOm+hSIt
+zFCr7qfSXF6ibDQfzLSaP1N6r9QdParx8cL3aOoaoR5Ke3Ti8kPzl7G4bpswsId2
+g/mwVPXrkoAWNt1PzKIOuZzZkywyvT6sEV5ucNqD6qWQc8cqG+CVAQ==
+-----END RSA PRIVATE KEY-----
diff --git a/data/mnet/Common/cdr/include/CdrBase.h b/data/mnet/Common/cdr/include/CdrBase.h
new file mode 100644
index 0000000..ffd97b1
--- /dev/null
+++ b/data/mnet/Common/cdr/include/CdrBase.h
@@ -0,0 +1,179 @@
+// *******************************************************************
+//
+// (c) Copyright Cisco 2000
+// All Rights Reserved
+//
+// *******************************************************************
+// CdrBase.h: interface for the CCdrBase class.
+//
+//////////////////////////////////////////////////////////////////////
+#ifndef _CDR_BASE_H_
+#define _CDR_BASE_H_
+
+#include <time.h>
+
+#include "CdrInterface.h"
+
+#include "subsc/SubscInfoType.h" // in common vob - klim 11/09/00
+#include "ril3/ril3msgheader.h"
+#include "ril3/ril3_common.h"
+#include "ril3/ie_cause.h"
+#include "ril3/ie_calling_bcd.h"
+#include "ril3/ie_called_bcd.h"
+
+
+#define CNI_RIL3_CAUSE_SUCCESS ((T_CNI_RIL3_CAUSE_VALUE)255)
+#define CDR_CURRENT_VERSION_NUM 2
+
+typedef ubyte4 T_CDR_EVENT_REFERENCE_NUMBER;
+
+
+// CDR data types
+typedef enum
+{
+ CDR_REC_NORM_RELEASE = 0,
+ CDR_REC_PARTIAL = 1,
+ CDR_REC_PARTIAL_REC_CALL_REESTABLISHMENT = 2,
+ CDR_REC_UNSUCCESSFUL_CALL_ATTEMPT = 3,
+ CDR_REC_STABLE_CALL_ABNORMAL_TERM = 4,
+ CDR_REC_CAMEL_INIT_CALL_RELEASE = 5
+
+} CdrRecCauseTerm_t;
+
+
+typedef enum {
+ CDR_RECORD_TYPE_MOC =0 ,
+ CDR_RECORD_TYPE_MTC =1 ,
+ CDR_RECORD_TYPE_MOSMS =6 ,
+ CDR_RECORD_TYPE_MTSMS =7 ,
+ CDR_RECORD_TYPE_SSA =10,
+ CDR_RECORD_TYPE_CTR =11,
+ CDR_RECORD_TYPE_INVALID =99,
+} T_CDR_RECORD_TYPE;
+
+
+typedef enum {
+ CDR_FIELD_NOT_SET = 0, // the field has not being set at all
+ CDR_FIELD_SET_AND_PRINTED = 1, // the field has been set and has been printed already
+ CDR_FIELD_SET_BUT_NOT_PRINT = 2 // the field has been set but never been printed yet.
+} T_CDR_FIELD_STATUS;
+
+
+// CDR Field E164
+class CCdrFieldE164
+{
+public:
+ T_CDR_FIELD_STATUS status ;
+ char buffer[23]; // pre-formated ascii string
+
+ void initialize () { buffer[0]='\0'; status=CDR_FIELD_NOT_SET;};
+ CCdrFieldE164() { initialize(); };
+ virtual ~CCdrFieldE164() {};
+ char * string ();
+ void set (T_SUBSC_IE_ISDN *p_e164);
+ void set (T_CNI_RIL3_IE_CALLED_PARTY_BCD_NUMBER *);
+ void set (T_CNI_RIL3_IE_CALLING_PARTY_BCD_NUMBER *);
+};
+
+// CDR Field IMSI
+class CCdrFieldIMSI
+{
+public:
+ T_CDR_FIELD_STATUS status ;
+ char buffer[16]; // pre-formated ascii string
+
+ void initialize () { buffer[0]='\0'; status=CDR_FIELD_NOT_SET;};
+ CCdrFieldIMSI() { initialize(); };
+ virtual ~CCdrFieldIMSI() {};
+ void set (T_SUBSC_IE_MOBILE_ID_IMSI *p_IMSI) ;
+ char * string ();
+};
+
+// CDR Field IMEI
+class CCdrFieldIMEI
+{
+public:
+ T_CDR_FIELD_STATUS status ;
+ char buffer[20]; // pre-formated ascii string
+
+ void initialize () { buffer[0]='\0'; status=CDR_FIELD_NOT_SET;};
+ CCdrFieldIMEI() { initialize();};
+ virtual ~CCdrFieldIMEI() {};
+ void set (T_CNI_RIL3_IE_MOBILE_ID *p_IMEI) ;
+ char * string ();
+};
+
+// CDR Field LACID
+class CCdrFieldLACID
+{
+public:
+ T_CDR_FIELD_STATUS status;
+ char buffer[20]; // pre-formated ascii string
+
+ void initialize () { buffer[0]='\0'; status=CDR_FIELD_NOT_SET;};
+ CCdrFieldLACID() { initialize();};
+ virtual ~CCdrFieldLACID() {};
+ void set (T_CNI_RIL3_IE_LOCATION_AREA_ID *p_la_id ,
+ T_CNI_RIL3_IE_CELL_ID *p_cell_id);
+ char * string ();
+};
+
+
+// CDR FIeld Date and Time
+class CCdrFieldDateTime
+{
+private:
+ time_t lTime ; // current system time (not UTC)
+ char buffer[16]; // pre-formated ascii string
+
+public:
+ T_CDR_FIELD_STATUS status;
+
+ CCdrFieldDateTime() { initialize();};
+ virtual ~CCdrFieldDateTime() {};
+
+ void initialize () { buffer[0] = '\0' ;
+ lTime = 0 ;
+ status = CDR_FIELD_NOT_SET;};
+ time_t getTime () { return (lTime); }
+ void stamp (); // stamp the current date and time into buffer
+ char * string ();
+};
+
+
+// CDR Base Class
+class CCdrBase
+{
+protected:
+ T_CDR_RECORD_TYPE record_type;
+ T_CDR_EVENT_REFERENCE_NUMBER event_ref_number;
+ CCdrFieldIMSI served_imsi;
+ CCdrFieldE164 served_msisdn;
+
+public:
+ unsigned short count;
+ CdrMessage_t cdr_msg;
+
+ CCdrBase();
+ virtual ~CCdrBase();
+
+ virtual void initialize ();
+
+ void setRecordType (T_CDR_RECORD_TYPE type) { cdr_msg.msgType=record_type=type; };
+ T_CDR_RECORD_TYPE getRecordType () { return record_type; };
+ void setServedIMSI (T_SUBSC_IE_MOBILE_ID_IMSI *p_imsi)
+ { served_imsi.set(p_imsi); };
+ void setServedMSISDN(T_SUBSC_IE_ISDN *p_msisdn)
+ { served_msisdn.set(p_msisdn); };
+ void printBaseFields(); // print all the fields into outbuffer
+ void generateRecord (); // send the record to the CDR client
+ T_CDR_EVENT_REFERENCE_NUMBER
+ getEventRefNumber() { return event_ref_number; };
+
+};
+
+
+// This class should NOT be used directly. This is a base class to derive
+// CTR, VoiceCall, SSA, and SMS records
+
+#endif // _CDR_BASE_H_ \ No newline at end of file
diff --git a/data/mnet/Common/cdr/include/CdrCommon.h b/data/mnet/Common/cdr/include/CdrCommon.h
new file mode 100644
index 0000000..9bf7fd9
--- /dev/null
+++ b/data/mnet/Common/cdr/include/CdrCommon.h
@@ -0,0 +1,132 @@
+#ifndef __CDRCOMMON_H__
+#define __CDRCOMMON_H__
+
+// *******************************************************************
+//
+// (c) Copyright CISCO Systems, Inc 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// Status : Under development
+// File : CdrCommon.h
+// Author(s) : Igal Gutkin
+// Create Date : 06/20/00
+// Description :
+//
+// *******************************************************************
+
+#include "defs.h"
+
+// TCP Port number for CDR client to CDR server level 1 connection
+#define AM_MAIN_SERVER_PORT 11790
+
+// TCP Port number for client connection to CDR server level 2
+//#define CDR_MAIN_CONTROL_PORT 11792
+//#define CDR_MAIN_DATA_PORT 11793
+#define CDR_IPC_PORT 11794
+
+#define CDR_HEADER_SIZE 1 // CDR header length
+
+#define CDR_MAX_HEADER_LEN 100
+#define CDR_MAX_DATA_LENGTH 1200
+#define CDR_MAX_RECORD_LEN (CDR_MAX_DATA_LENGTH+CDR_MAX_HEADER_LEN)
+
+
+#define CDR_GENERIC_MSG_TYPE (0x1A2B3C4DL)
+
+#define CDR_FIELD_DELIMETER ' '
+
+// CDR Reference definitions
+#define CDR_INVALID_REFERENCE (0)
+#define CDR_MIN_REFERENCE (1)
+#define CDR_MAX_REFERENCE (0xFFFF)
+
+// CDR Version numbers
+#define CDR_INVALID_FORMAT_VER 0
+#define CDR_FORMAT_VER_1 1
+#define CDR_FORMAT_VER_2 2
+#define CDR_FORMAT_VER_3 3
+#define CDR_FORMAT_VER_4 4
+#define CDR_FORMAT_VER_5 5
+
+//Cdr Error codes
+#define CDR_STATUS_OK SOCKET_STATUS_OK
+#define CDR_STATUS_MSG_TOO_LONG SOCKET_STATUS_MSG_TOO_LONG
+#define CDR_STATUS_TEMP_SOC_ERR SOCKET_STATUS_TEMP_SOC_ERR
+#define CDR_STATUS_FATAL_SOC_ERR SOCKET_STATUS_FATAL_SOC_ERR
+
+// Buffer lengths
+#define CTRL_SOC_RCV_BUFF_LEN (0x1000)
+#define CTRL_SOC_SND_BUFF_LEN (0x1000)
+#define DATA_SOC_RCV_BUFF_LEN (0x500)
+#define DATA_SOC_SND_BUFF_LEN (0x10000)
+
+typedef char CdrLogPool_t [CDR_MAX_RECORD_LEN ];
+typedef char CdrRecPool_t [CDR_MAX_DATA_LENGTH];
+
+
+// CDR password filename
+#define CDR_PWD_FILE_NAME "cdrpwd.dat"
+
+
+typedef enum
+{
+ SOCK_ERROR = SOC_STATUS_ERROR,
+ SOCK_NORMAL = 0,
+ SOCKET_CLOSED = 1,
+ FILE_FULL = 2,
+ REGISTER_TIMEOUT = 3,
+ STATUS_QUERY_TIMEOUT= 4,
+ FILE_ACK_TIMEOUT = 5,
+ DATA_TIMEOUT = 6,
+ SHUTDOWN_CLIENT = 7
+
+} CDR_SOCK_RESULT;
+
+enum RegisterCause
+{
+ INIT_CAUSE,
+ FILE_TRANSFER_CAUSE
+};
+
+typedef enum
+{
+ CURRENT ,
+ FINISHED,
+ UNACK ,
+ ACK
+}CDR_FILE_EXTENSIONS;
+
+typedef enum
+{
+ DELETE_ENTRY ,
+ ADD_ENTRY ,
+ WRITE_FILE_CLOSE_TIME ,
+ WRITE_FILE_TRANSFER_TIME ,
+ WRITE_FILE_TRANSFER_STATUS
+
+} CDR_TIMESTAMP_FILE_OP;
+
+struct timeStampRec
+{
+ char fileName[MAX_PATH-1];
+ bool fileTransfer;
+ ubyte4 fileOpenTime;
+ ubyte4 fileCloseTime;
+ ubyte4 fileTransferTime;
+
+};
+
+typedef struct
+{
+ struct timeStampRec* rec;
+ sbyte4 numEntries;
+
+} timeStampStruct;
+
+
+#endif //__CDRCOMMON_H__
diff --git a/data/mnet/Common/cdr/include/CdrInterface.h b/data/mnet/Common/cdr/include/CdrInterface.h
new file mode 100644
index 0000000..701216f
--- /dev/null
+++ b/data/mnet/Common/cdr/include/CdrInterface.h
@@ -0,0 +1,87 @@
+#ifndef CDR_INTERFACE_H
+#define CDR_INTERFACE_H
+
+// *******************************************************************
+//
+// (c) Copyright Cisco Systems Inc, 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// Status : Under development
+// File : CdrInterface.h
+// Author(s) : Igal Gutkin
+// Create Date : 07-25-00
+// Description : CDR module interface to the CDR application classes
+//
+// *******************************************************************
+
+#ifndef __CDRCOMMON_H__
+#include "CdrCommon.h"
+#endif //__CDRCOMMON_H__
+
+
+// CDR message storage
+typedef struct
+{
+ ubyte4 msgType;
+ CdrRecPool_t record ;
+} CdrMessage_t;
+
+
+#ifdef __cplusplus
+ extern "C"
+ {
+
+ // CDR control functions
+ /*-------------------------------------------------------------*/
+
+ // Stop CDR logging
+ void cdrStopLog ();
+
+ // Start/resume CDR logging
+ void cdrStartLog ();
+
+ // CDR info functions
+ bool cdrGetStatus ();
+
+ bool _cdrSwitchServer (LPSTR ipAddr);
+
+ // CDR user functions
+ /*-------------------------------------------------------------*/
+
+ // Return unique CDR reference number
+ ubyte4 cdrAllocateRef ();
+
+ // Provide the local host IP address (network byte order!!!)
+ ubyte4 cdrGetLocalIp ();
+
+ // Send log to CDR subsystem
+ bool cdrSendLog (CdrMessage_t *);
+
+ // Save CDR password to the file
+ bool cdrSavePwd (LPCSTR lpPasswd);
+ }
+
+#else
+
+ // CDR control functions
+ void cdrStopLog (void);
+ void cdrStartLog (int );
+ bool cdrGetStatus (void);
+ bool _cdrSwitchServer (LPSTR ipAddr);
+
+ // CDR user functions
+ ubyte4 cdrAllocateRef (void);
+ ubyte4 cdrGetLocalIp (void);
+ bool cdrSendLog (CdrMessage_t *);
+
+ bool cdrSavePwd (LPCSTR lpPasswd);
+
+#endif // __cplusplus
+
+
+#endif // CDR_INTERFACE_H \ No newline at end of file
diff --git a/data/mnet/Common/cdr/include/CdrModule.h b/data/mnet/Common/cdr/include/CdrModule.h
new file mode 100644
index 0000000..d03f45c
--- /dev/null
+++ b/data/mnet/Common/cdr/include/CdrModule.h
@@ -0,0 +1,200 @@
+#ifndef __CDCMODULE_H__
+#define __CDRMODULE_H__
+// *******************************************************************
+//
+// (c) Copyright CISCO Systems, Inc 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// Status : Under development
+// File : CdrModule.h
+// Author(s) : Igal Gutkin
+// Create Date : 10/02/00
+// Description : CDR module class interface
+// Call Detail Recording (CDR) Client
+// Call Detail Recording is split into two parts. Much
+// of the work is done through the api functions providing
+// access to the record classes. However, a separate task
+// is used to perform network IO that is required to forward
+// the records to CDR Server which can cause some delay.
+// Thus, potentially lengthy operations can be done in the
+// background at a lower priority than call processing.
+// *******************************************************************
+
+#include "Os\JCModule.h"
+#include "Os\JCMsgQueue.h"
+#include "Os\JCTask.h"
+
+#include <usrLib.h>
+
+#include "AlarmCode.h"
+
+#include "CdrShellIntf.h"
+
+#include "CdrInterface.h"
+#include "cdrdefs.h"
+
+#include "CdrRefSem.h"
+#include "CdrRemClientSocket.h"
+
+
+// system definitions
+
+#define CDR_MSG_Q_MAX 128 // max msgs that can be queued
+#define CDR_MSG_SIZE_MAX sizeof (CdrMessage_t) // max bytes in a msg
+#define CDR_Q_OPTIONS JC_MSG_Q_FIFO // system options
+
+
+class CdrModule
+{
+// methods
+ public:
+
+// CDR API functions. Used by the CDR record classes
+friend void cdrDataPrint ();
+friend void cdrStartLog ();
+friend void cdrStopLog ();
+friend bool cdrGetStatus ();
+friend bool cdrSendLog (CdrMessage_t* msg);
+friend ubyte4 cdrAllocateRef ();
+friend ubyte4 cdrGetLocalIp ();
+friend int SysCommand_CDR (T_SYS_CMD cmd);
+
+ // Main loop entry point
+ static bool mainTaskHandle();
+
+ // Main access interface
+ static CdrModule *getInstance () {return (pCdr_) ;}
+
+ // Encrypts & write CDR access password to the file
+ static bool savePwd (LPCSTR lpPasswd);
+
+ // Alarm handling
+ static void raiseSslAlarm ();
+ static void cleanSslAlarm ();
+
+ static void raiseModuleAlarm (AlarmCode_t code);
+ static void cleanModuleAlarm ();
+
+ // Print operational information
+ void printInfo ();
+
+ // Test whether the CDR module is properly initialized
+ bool isSet () {return (pMainQueue_ != NULL && pSoc_ != NULL);}
+
+ // Test whether there is a connection to CDR server
+ bool isConnected () {return (srvOnline_);}
+
+ ubyte4 getServerIp () {return (srvrIp_ );}
+ ubyte2 getServerPort () {return (srvrPort_ );}
+
+ // use for debug purpose only
+ bool switchServer (ubyte4 newSrvrIp);
+
+ bool enableExtraInfo () { bExtraInfo_ = true ; }
+ bool disableExtraInfo () { bExtraInfo_ = false; }
+
+ private:
+
+ // Constructors & Destructor
+ CdrModule ();
+ ~CdrModule ();
+
+
+ // Create the module instance
+ static void create ();
+
+ // System Root control interface
+ static int sysCmdHandler (T_SYS_CMD cmd);
+
+ static bool readPwd ();
+
+ static LPSTR getPswdFile ();
+
+ // Setup the module task(s) and queue(s)
+ bool start ();
+
+ // Load init data
+ bool loadData ();
+
+ // Send log to the CDR module
+ bool submitRec (CdrMessage_t* msg);
+
+ // receive Msg from the incoming Queue
+ bool getMsg ();
+
+ // Access the module input queue
+ JCMsgQueue *getCdrMainQ () {return (pMainQueue_);}
+
+ // Allocate new CDR reference number
+ ubyte4 getNewRef () {return (localRef_.allocateRef());}
+
+ // setup socket connection to the CDR server
+ bool socketInit ();
+
+ // re-establish socket connection to the CDR server
+ bool socketReset ();
+
+ // Logging control interface
+ void enable () {logStatus_ = true ;}
+ void disable () {logStatus_ = false ;}
+ bool getStatus () {return (logStatus_);}
+
+
+// data members
+ private:
+
+ // provides information about using SSL
+ static bool bUseSSL_ ,
+ bUseMibSSL_;
+
+ static bool bExtraInfo_;
+
+
+ static char sPasswd_[SSL_MAX_PASSWORD_LENGTH+2];
+
+ // pointer to the module instance
+ static CdrModule *pCdr_ ;
+
+ // module system elements
+ static JCMsgQueue *pMainQueue_;
+ JCTask mainTask_ ;
+ JCMsgQueue *pReplayQ_ ;
+
+ // Alarm code
+ static AlarmCode_t majorAlarmCode_,
+ infoAlarmCode_ ;
+
+ // Client socket to the server
+ CdrRemClientSocket *pSoc_ ;
+
+ // CDR server parameters
+ ubyte4 srvrIp_ ;
+ ubyte2 srvrPort_ ;
+
+ // Local reference allocator
+ CdrRefSem localRef_ ;
+
+ // CDR Logging status
+ bool logStatus_;
+
+ // Cdr connection indicator
+ bool srvOnline_;
+
+ unsigned sentRecs_ ;
+ unsigned lostRecs_ ;
+
+ // message handling
+ unsigned inMsgSize_;
+ unsigned inMsgType_;
+ CdrMessage_t inMsgBuf_ ;
+ MNET_MODULE_ID fromModId_;
+
+};
+
+
+#endif //__CDRMODULE_H__ \ No newline at end of file
diff --git a/data/mnet/Common/cdr/include/CdrMsg.h b/data/mnet/Common/cdr/include/CdrMsg.h
new file mode 100644
index 0000000..adb41d6
--- /dev/null
+++ b/data/mnet/Common/cdr/include/CdrMsg.h
@@ -0,0 +1,112 @@
+#ifndef _CDRMSG_H_
+#define _CDRMSG_H_
+
+// *******************************************************************
+//
+// (c) Copyright CISCO Systems Inc. 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// Status : Under development
+// File : CdrMsg.h
+// Author(s) : Sandeep A.
+// Create Date : 9/26/00
+// Description :
+//
+// *******************************************************************
+
+#include "msgProc.h"
+
+
+#define INPUT_SIZE 8192 // Ananth: need to revisit the size
+#define REGISTER_MSG_TYPE (0x10000021)
+#define REGISTER_ACK_MSG_TYPE (0x10000031)
+
+#define FILE_ACK_MSG_TYPE (0x10000051)
+#define STATUS_QUERY_MSG_TYPE (0x10000061)
+#define STATUS_RESPONSE_MSG_TYPE (0x10000071)
+#define IPC_FILE_FULL_MSG_TYPE (0x10000151)
+
+#define REGISTER_TIMEOUT_MSG_TYPE (0x10000201)
+#define FILE_ACK_TIMEOUT_MSG_TYPE (0x10000211)
+#define STATUS_QUERY_TIMEOUT_MSG_TYPE (0x10000221)
+#define DATA_TIMEOUT_MSG_TYPE (0x10000231)
+
+// New error codes
+#define CDR_STATUS_FILE_TRANSFER_ERROR 5
+#define CDR_STATUS_NON_FATAL_SEND_ERROR 6
+#define CDR_STATUS_FATAL_SEND_ERROR 7
+
+#define CDR_NAME_MAX_SIZE 32
+
+#define FILE_ERROR (~1)
+
+
+typedef struct
+{
+ ubyte4 cause;
+ sbyte cdr1Name[CDR_NAME_MAX_SIZE];
+} RegisterData_t;
+
+typedef struct
+{
+ ubyte4 cdr1Id;
+} RegisterAckData_t;
+
+
+typedef struct
+{
+ // ubyte4 lastValidFileId;
+} FileAckData_t;
+
+typedef struct
+{
+ ubyte4 lastValidFileId;
+} StatusResponseData_t;
+
+typedef struct
+{
+ ubyte4 cdr1Id;
+ ubyte4 fileId;
+ sbyte4 fileSize;
+ ubyte4 fileOpenTime;
+ ubyte4 fileCloseTime;
+} StatusQueryData_t;
+
+typedef struct CdrControlMsg_t
+{
+ ClientInterfaceMsgHeader_t hdr;
+ union {
+ RegisterData_t registerData;
+ RegisterAckData_t registerAckData;
+ FileAckData_t fileAckData;
+ StatusQueryData_t statusQueryData;
+ StatusResponseData_t statusResponseData;
+ }body;
+} CdrControlMsg;
+
+typedef struct
+{
+ ubyte4 cdr1Id;
+ sbyte inmsgPool[INPUT_SIZE - 4];
+} FirstData_t;
+
+typedef struct
+{
+ sbyte inmsgPool[INPUT_SIZE];
+} NextData_t;
+
+
+typedef struct CdrDataMsg_t
+{
+ union {
+ FirstData_t firstData;
+ NextData_t nextData;
+ }data;
+}CdrDataMsg;
+
+#endif
diff --git a/data/mnet/Common/cdr/include/CdrRef.h b/data/mnet/Common/cdr/include/CdrRef.h
new file mode 100644
index 0000000..4723474
--- /dev/null
+++ b/data/mnet/Common/cdr/include/CdrRef.h
@@ -0,0 +1,38 @@
+#ifndef __CDRREF_H__
+#define __CDRREF_H__
+
+// *******************************************************************
+//
+// (c) Copyright CISCO Systems, Inc 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// File : cdrRef.h
+// Author(s) : Igal Gutkin
+// Create Date : 06/20/00
+// Description : interface for the CdrRef class
+//
+// *******************************************************************
+
+#include "CdrCommon.h"
+
+class CdrRef
+{
+public:
+ CdrRef() {;}
+ virtual ~CdrRef() {;}
+
+ static ubyte4 allocateRef ();
+ static ubyte4 getLastRef ();
+
+// data members
+private:
+ static ubyte4 lastRefNum_;
+};
+
+
+#endif // __CDRREF_H__ \ No newline at end of file
diff --git a/data/mnet/Common/cdr/include/CdrRefSem.h b/data/mnet/Common/cdr/include/CdrRefSem.h
new file mode 100644
index 0000000..793f12c
--- /dev/null
+++ b/data/mnet/Common/cdr/include/CdrRefSem.h
@@ -0,0 +1,42 @@
+#ifndef __CDRREFSEM_H__
+#define __CDRREFSEM_H__
+
+// *******************************************************************
+//
+// (c) Copyright CISCO Systems, Inc 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// File : CdrRefSem.h
+// Author(s) : Igal Gutkin
+// Create Date : 11/08/00
+// Description : Interface for the CdrRefSem class
+// Provides semaphore protection in the multitask environment
+// *******************************************************************
+
+#include "Os\JCMutex.h"
+
+#include "CdrCommon.h"
+
+#include "CdrRef.h"
+
+class CdrRefSem : public CdrRef
+{
+public:
+ CdrRefSem () : CdrRef (), mutex_() {}
+ virtual ~CdrRefSem () {}
+
+ ubyte4 allocateRef ();
+
+// data members
+private:
+ // Preserves generation of unique CDR ref numbers
+ JCMutex mutex_;
+};
+
+
+#endif // __CDRREFSEM_H__ \ No newline at end of file
diff --git a/data/mnet/Common/cdr/include/CdrRemClientSocket.h b/data/mnet/Common/cdr/include/CdrRemClientSocket.h
new file mode 100644
index 0000000..3642373
--- /dev/null
+++ b/data/mnet/Common/cdr/include/CdrRemClientSocket.h
@@ -0,0 +1,61 @@
+#ifndef __CDRREMCLIENTSOCKET_H__
+#define __CDRREMCLIENTSOCKET_H__
+
+// *******************************************************************
+//
+// (c) Copyright CISCO Systems, Inc 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// Status : Under development
+// File : CdrRemClientSocket.h
+// Author(s) : Igal Gutkin
+// Create Date : 06/20/00
+// Description : interface for the CdrRemClientSocket class.
+//
+// *******************************************************************
+
+#include "socket\GenClientSocket.h"
+
+#include "msgProc.h"
+
+
+#define CDR_CLIENT_SOC_RCV_BUFF_LEN (0x500)
+#define CDR_CLIENT_SOC_SND_BUFF_LEN (0x1024)
+
+class CdrRemClientSocket : public GenClientSocket
+{
+public:
+
+ CdrRemClientSocket ()
+ : GenClientSocket (CDR_CLIENT_SOC_SND_BUFF_LEN, CDR_CLIENT_SOC_RCV_BUFF_LEN)
+ {;}
+
+ CdrRemClientSocket (bool bEnableSSL, bool bEnableEncryption = true)
+ : GenClientSocket (CDR_CLIENT_SOC_SND_BUFF_LEN,
+ CDR_CLIENT_SOC_RCV_BUFF_LEN,
+ bEnableSSL ,
+ bEnableEncryption ) { ; }
+
+ virtual
+ ~CdrRemClientSocket () { ; }
+
+ int sendData (LPSTR szData);
+
+protected:
+
+private:
+ void zapLog ();
+
+// data members
+private:
+
+ ClientMsg_t outMsg_;
+
+};
+
+#endif //__CDRREMCLIENTSOCKET_H__ \ No newline at end of file
diff --git a/data/mnet/Common/cdr/include/CdrShellIntf.h b/data/mnet/Common/cdr/include/CdrShellIntf.h
new file mode 100644
index 0000000..fe47d40
--- /dev/null
+++ b/data/mnet/Common/cdr/include/CdrShellIntf.h
@@ -0,0 +1,39 @@
+#ifndef __CDRSHELLINTF_H__
+#define __CDRSHELLINTF_H__
+// *******************************************************************
+//
+// (c) Copyright Cisco Systems Inc, 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// Status : Under development
+// File : CdrShellIntf.h
+// Author(s) : Igal Gutkin
+// Create Date : 11/21/00
+// Description : CDR module shell interface definitions
+//
+// *******************************************************************
+
+#ifdef __cplusplus
+ extern "C"
+ {
+ void CdrDataPrint ();
+ void CdrEnableExtraInfo ();
+ void CdrDisableExtraInfo ();
+ int SavePwdCdr (LPCSTR lpPasswd);
+ void _CdrSendDebug ();
+ }
+#else
+ void CdrDataPrint (void);
+ void CdrEnableExtraInfo (void);
+ void CdrDisableExtraInfo (void);
+ int SavePwdCdr (LPCSTR lpPasswd);
+ void _CdrSendDebug (void);
+#endif //__cplusplus
+
+
+#endif //__CDRSHELLINTF_H__ \ No newline at end of file
diff --git a/data/mnet/Common/cdr/include/ConnList.h b/data/mnet/Common/cdr/include/ConnList.h
new file mode 100644
index 0000000..dea5486
--- /dev/null
+++ b/data/mnet/Common/cdr/include/ConnList.h
@@ -0,0 +1,98 @@
+#ifndef _CONNLIST_H_
+#define _CONNLIST_H_
+
+// *******************************************************************
+//
+// (c) Copyright CISCO Systems Inc. 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// Status : Under development
+// File : ConnList.h
+// Author(s) : Igal Gutkin
+// Create Date : 6/22/00
+// Description :
+//
+// *******************************************************************
+
+#include "socket\GenSocket.h"
+
+// Forward declarations
+class ClientConnectionList;
+class ClientConnListIterator;
+
+
+// *******************************************************************
+// Class ClientConnection
+// *******************************************************************
+class ClientConnection {
+public:
+ friend class ClientConnectionList;
+ friend class ClientConnListIterator;
+
+ ClientConnection (GenSocket&);
+
+ virtual ~ClientConnection ();
+
+ OS_SPECIFIC_SOCKET_HANDLE getSocket() {return (connSock_.getSocket());}
+ GenSocket *getClient() {return (&connSock_) ;}
+
+ int serveClient (const fd_set *set);
+
+
+private:
+ GenSocket & connSock_;
+ ClientConnection *next_ ;
+
+ // No default constructor
+ ClientConnection();
+};
+
+
+// *******************************************************************
+// Class ClientConnectionList
+// *******************************************************************
+class ClientConnectionList {
+public:
+ friend class ClientConnListIterator;
+
+ ClientConnectionList ();
+ ~ClientConnectionList();
+
+ SOC_STATUS InsertClientConnection (ClientConnection *pConn);
+ SOC_STATUS DeleteClientConnection (ClientConnection *pConn);
+
+private:
+ ClientConnection *pConnListHead_;
+};
+
+
+// *******************************************************************
+// Class ClientConnListIterator
+// *******************************************************************
+class ClientConnListIterator {
+public:
+ ClientConnListIterator (ClientConnectionList& List) : theList_(List)
+ { pClientConn_ = theList_.pConnListHead_; }
+ ~ClientConnListIterator() {}
+
+ void Reset() { pClientConn_ = theList_.pConnListHead_; }
+ ClientConnection *Next ()
+ {
+ ClientConnection *pCurrConn = pClientConn_;
+ return (pCurrConn ? (pClientConn_ = pCurrConn->next_) : pCurrConn);
+ }
+
+ ClientConnection *Current() { return pClientConn_;}
+
+private:
+ ClientConnection *pClientConn_;
+ ClientConnectionList& theList_ ;
+};
+
+
+#endif /* _CONNLIST_H_ */
diff --git a/data/mnet/Common/cdr/include/msgProc.h b/data/mnet/Common/cdr/include/msgProc.h
new file mode 100644
index 0000000..4b30fd1
--- /dev/null
+++ b/data/mnet/Common/cdr/include/msgProc.h
@@ -0,0 +1,47 @@
+#ifndef _MSGPROC_H_
+#define _MSGPROC_H_
+
+// *******************************************************************
+//
+// (c) Copyright CISCO Systems Inc. 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// Status : Under development
+// File : msgProc.h
+// Author(s) : Igal Gutkin
+// Create Date : 6/21/00
+// Description :
+//
+// *******************************************************************
+
+
+
+/* CDR Message common header */
+typedef struct
+{
+ ubyte4 msgType; // reserved for the future use
+ ubyte4 dataLen;
+} ClientInterfaceMsgHeader_t;
+
+#define clientMsgHdrLen (sizeof(ClientInterfaceMsgHeader_t))
+
+
+typedef struct
+{
+ char logData [CDR_MAX_DATA_LENGTH];
+} ClientCdrData_t;
+
+
+typedef struct
+{
+ ClientInterfaceMsgHeader_t hdr;
+ ClientCdrData_t msg;
+} ClientMsg_t;
+
+
+#endif /* _MSGPROC_H_ */
diff --git a/data/mnet/Common/cdr/src/CdrRef.cpp b/data/mnet/Common/cdr/src/CdrRef.cpp
new file mode 100644
index 0000000..54a3641
--- /dev/null
+++ b/data/mnet/Common/cdr/src/CdrRef.cpp
@@ -0,0 +1,49 @@
+// *******************************************************************
+//
+// (c) Copyright CISCO Systems, Inc 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 2.0
+// File : CdrRef.cpp
+// Author(s) : Igal Gutkin
+// Create Date : 06/20/00
+// Description : implementation of the CdrRef class.
+//
+// *******************************************************************
+
+#include "cdrRef.h"
+
+
+//////////////////////////////////////////////////////////////////////
+// Static Data members declarations
+//////////////////////////////////////////////////////////////////////
+
+ubyte4 CdrRef::lastRefNum_ = CDR_INVALID_REFERENCE;
+
+
+//////////////////////////////////////////////////////////////////////
+// Construction/Destruction
+//////////////////////////////////////////////////////////////////////
+
+
+//////////////////////////////////////////////////////////////////////
+// Primary behaviour methods
+//////////////////////////////////////////////////////////////////////
+
+ubyte4 CdrRef::allocateRef ()
+{
+ if (++lastRefNum_ > CDR_MAX_REFERENCE)
+ lastRefNum_ = CDR_MIN_REFERENCE;
+
+ return (lastRefNum_);
+}
+
+
+ubyte4 CdrRef::getLastRef()
+{
+ return (lastRefNum_);
+}
diff --git a/data/mnet/Common/cdr/src/Makefile b/data/mnet/Common/cdr/src/Makefile
new file mode 100644
index 0000000..ca246f8
--- /dev/null
+++ b/data/mnet/Common/cdr/src/Makefile
@@ -0,0 +1,61 @@
+##########################################################
+#
+# (c) Copyright Cisco 2000
+# All Rights Reserved
+#
+# Use Examples:
+#
+# Case 1:
+# make all VOB=GP10 -
+# Places .out in VOB/bin directory
+#
+# Case 2:
+# make all VOB=GP10 APPDIR=Host\<Application Name>\<Source Directory> -
+# Places .o file(s) in VOB\$(APPDIR)\bin directory.
+#
+# <Application Name> = Name of Application directory
+# <Source Directory> = application sub directory where the calling
+# Makefile resides.
+#
+# Example: make all VOB=GP10 APPDIR=Host\vxTemplate\src
+#
+#
+# Note: This make file must reference a VOB that
+# has a defs.mk in the top level directory.
+#
+##########################################################
+
+# TOP_OF_VOB must be defined before including l3defs.mk
+TOP_OF_VOB = ..\..
+
+# Name of this App's Directory
+THIS_APP_DIR = cdr
+
+VOB2DIR = $(TOP_OF_VOB)\..\$(VOB)
+BINDIR = ..\bin
+
+ifeq ($(APPDIR),)
+ MY_OUTPUT = $(VOB2DIR)\bin\cdr_com.out
+else
+ MY_OUTPUT = $(OBJDIR)\cdr_com.out
+endif
+
+include $(VOB2DIR)\l3defs.mk
+
+
+all: $(MY_OUTPUT)
+
+$(MY_OUTPUT): $(MODULE_OBJS)
+ $(LD) -r -o $@.tmp $(MODULE_OBJS)
+ $(NM) $@.tmp | munch > _ctdt.c
+ $(CC) -traditional $(CC_ARCH_SPEC) -c _ctdt.c
+ $(LD) -r -o $@ _ctdt.o $@.tmp
+ $(RM)$(subst /,$(DIRCHAR), _ctdt.c _ctdt.o $@.tmp)
+
+cleanall:
+ @for %f in ($(notdir $(MODULE_OBJS))) do \
+ $(RM) ..\bin\%f
+
+ $(RM) $(MY_OUTPUT)
+
+
diff --git a/data/mnet/Common/cdr/src/readme.txt b/data/mnet/Common/cdr/src/readme.txt
new file mode 100644
index 0000000..8a52ae0
--- /dev/null
+++ b/data/mnet/Common/cdr/src/readme.txt
@@ -0,0 +1 @@
+This folder contains source files common to CDR Client and CRD Server applications.
diff --git a/data/mnet/Common/cdr/src_client/CdrApi.cpp b/data/mnet/Common/cdr/src_client/CdrApi.cpp
new file mode 100644
index 0000000..c4e6a8e
--- /dev/null
+++ b/data/mnet/Common/cdr/src_client/CdrApi.cpp
@@ -0,0 +1,159 @@
+// *******************************************************************
+//
+// (c) Copyright CISCO Systems, Inc 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 2.0
+// File : CdrApi.cpp
+// Author(s) : Igal Gutkin
+// Create Date : 11/08/00
+// Description : Application interface for the CDR subsystem
+//
+// *******************************************************************
+
+#include "stdafx.h"
+
+#include "CdrModule.h"
+
+/*******************************************************************************
+ *
+ * cdrStartLog, cdrStopLog, cdrGetStatus
+ *
+ * These functions are used to turn CDR logging On/Off and check current
+ * logging status
+ *
+ ********************************************************************************/
+
+void cdrStartLog ()
+{
+ if (CdrModule::getInstance())
+ CdrModule::getInstance()->enable();
+}
+
+
+void cdrStopLog ()
+{
+ if (CdrModule::getInstance())
+ CdrModule::getInstance()->disable();
+}
+
+
+bool cdrGetStatus ()
+{
+ if (CdrModule::getInstance())
+ return (CdrModule::getInstance()->getStatus());
+}
+
+
+/*******************************************************************************
+ *
+ * cdrAllocateRef Allocate a Call Detail Record
+ *
+ * This function is used to allocate a CDR record. Since CDR records are
+ * stored in the application context only new CDR Reference number will
+ * be issued.
+ *
+ * Call: newRefNum = cdrAllocateRef()
+ *
+ * newRefNum - This is a unique 16 bit number that can be used
+ * to identify the record by.
+ * Note: After reaching max value (65,536), the number
+ * will wrap and we start re-using the reference numbers.
+ *
+ ******************************************************************************/
+ubyte4 cdrAllocateRef ()
+{
+ ubyte4 newRef = 0;
+
+ AM_FUNC ("cdrAllocateRef", LAYER_ID);
+ AM_ENTER();
+
+ if (CdrModule::getInstance())
+ newRef = CdrModule::getInstance()->getNewRef();
+
+ AM_LEAVE ();
+ return (newRef);
+}
+
+
+/*******************************************************************************
+ *
+ * cdrGetLocalIp Provides the local host IP address to the CDR classes
+ *
+ * This function is using cached value initialized during the init.
+ *
+ * Call : uIpAddrr = cdrGetLocalIp()
+ *
+ * Return value: NULL on error;
+ *
+ ******************************************************************************/
+ubyte4 cdrGetLocalIp ()
+{
+ return (htonl(GenSocket::getLocalHostAddress()));
+}
+
+
+/*******************************************************************************
+ *
+ * cdrSendLog API for sending prepared CDR log to the CDR subsystem
+ *
+ * This function is used to send CDR log from the application to CDR subsystem.
+ * Should be invoked only by the CDR base class
+ * being allocated.
+ *
+ * Call: result = cdrSendLog (&recordPool)
+ *
+ * Return Value: true if success, otherwise - false
+ *
+ ******************************************************************************/
+bool cdrSendLog (CdrMessage_t* msg)
+{
+ if (CdrModule::getInstance())
+ return (CdrModule::getInstance()->submitRec (msg));
+ else
+ return (false);
+}
+
+
+/*******************************************************************************
+ *
+ * _cdrSwitchServer API for changing CDR Server IP address
+ *
+ * This function should be used for changing CDR Server IP address
+ * for DEBUG purposes ONLY!!!
+ * Should be invoked only by the CDR base class being allocated.
+ *
+ * Call: result = _cdrSwitchServer (char* ipAddress)
+ *
+ * Input Parameter: string containing an (Ipv4) Internet Protocol dotted address
+ * Return Value : true if success, otherwise - false
+ *
+ ******************************************************************************/
+bool _cdrSwitchServer (LPSTR ipAddr)
+{
+ bool retVal = false ;
+ unsigned len = strlen(ipAddr);
+ ubyte4 srvrIp ;
+
+ if (len < 7 || len > 15)
+ {
+ printf ("Invalid IP address length.\n");
+ }
+ else if ((srvrIp=inet_addr(ipAddr)) == INADDR_NONE)
+ {
+ printf ("Invalid IP address (%s) is provided\n", ipAddr);
+ }
+ else
+ {
+ if (CdrModule::getInstance())
+ retVal = CdrModule::getInstance()->switchServer(srvrIp);
+ else
+ printf ("Cdr Client module is not allocated properly.\n");
+ }
+
+ return (retVal);
+} \ No newline at end of file
diff --git a/data/mnet/Common/cdr/src_client/CdrBase.cpp b/data/mnet/Common/cdr/src_client/CdrBase.cpp
new file mode 100644
index 0000000..158f6ae
--- /dev/null
+++ b/data/mnet/Common/cdr/src_client/CdrBase.cpp
@@ -0,0 +1,222 @@
+// *******************************************************************
+//
+// (c) Copyright Cisco 2000
+// All Rights Reserved
+//
+// *******************************************************************
+// CdrBase.cpp: implementation of the CCdrBase class.
+//
+//////////////////////////////////////////////////////////////////////
+
+#include "StdAfx.h"
+
+#include "CdrBase.h"
+
+bool CDR_Enable_Debug = false;
+
+
+// CDR Field E164
+
+void CCdrFieldE164::set(T_SUBSC_IE_ISDN *p_e164)
+{
+ if (p_e164->num_digit)
+ {
+ p_e164->digits[ (p_e164->num_digit>MAX_NUM_SUBSC_ISDN)? MAX_NUM_SUBSC_ISDN : p_e164->num_digit]=0;
+ sprintf (buffer, "%02X%s", (p_e164->num_plan[0] & 0x7F), p_e164->digits);
+ status = CDR_FIELD_SET_BUT_NOT_PRINT;
+ }
+}
+
+void CCdrFieldE164::set (T_CNI_RIL3_IE_CALLED_PARTY_BCD_NUMBER *pNum)
+{
+ unsigned offset ,
+ index = 0,
+ numDigits = (pNum->numDigits > CNI_RIL3_MAX_BCD_DIGITS)
+ ? CNI_RIL3_MAX_BCD_DIGITS
+ : pNum->numDigits ;
+
+ // correction for zero lenght number
+ if (pNum->numDigits)
+ {
+ offset = sprintf (buffer, "%1X%1X", pNum->numberType, pNum->numberingPlan);
+
+ // print BCD digits
+ while (index < numDigits)
+ {
+ *(buffer + offset + index) = 0x30 + pNum->digits [index++];
+ }
+
+ *(buffer + offset + index) = '\0';
+
+ status=CDR_FIELD_SET_BUT_NOT_PRINT;
+ }
+}
+
+void CCdrFieldE164::set (T_CNI_RIL3_IE_CALLING_PARTY_BCD_NUMBER *pNum)
+{
+ T_CNI_RIL3_IE_CALLED_PARTY_BCD_NUMBER shortForm;
+
+ shortForm.ie_present = pNum->ie_present ;
+ shortForm.numberType = pNum->numberType ;
+ shortForm.numberingPlan = pNum->numberingPlan;
+ shortForm.numDigits = pNum->numDigits ;
+ memcpy (shortForm.digits, pNum->digits, CNI_RIL3_MAX_BCD_DIGITS);
+
+ set (&shortForm);
+}
+
+
+char * CCdrFieldE164::string()
+{
+ status=CDR_FIELD_SET_AND_PRINTED;
+ return buffer;
+};
+
+
+// CDR Field IMSI
+
+void CCdrFieldIMSI::set(T_SUBSC_IE_MOBILE_ID_IMSI *p_IMSI)
+{
+ p_IMSI->imsi[ (p_IMSI->num_digit>MAX_NUM_SUBSC_IMSI) ? MAX_NUM_SUBSC_ISDN : p_IMSI->num_digit ]=0;
+ sprintf(buffer, "%s", p_IMSI->imsi);
+ status=CDR_FIELD_SET_BUT_NOT_PRINT;
+};
+
+char * CCdrFieldIMSI::string()
+{
+ status=CDR_FIELD_SET_AND_PRINTED;
+ return buffer;
+};
+
+void CCdrFieldIMEI::set (T_CNI_RIL3_IE_MOBILE_ID *pIMEI)
+{
+ unsigned index = 0;
+
+ // print BCD digits
+ while (index < 15)
+ {
+ buffer [index] = 0x30 + pIMEI->digits [index++];
+ }
+
+ buffer[index] = '\0';
+
+ status = CDR_FIELD_SET_BUT_NOT_PRINT;
+}
+
+
+char * CCdrFieldIMEI::string()
+{
+ status = CDR_FIELD_SET_AND_PRINTED;
+ return (buffer);
+}
+
+// CDR Field LACID
+
+void CCdrFieldLACID::set(T_CNI_RIL3_IE_LOCATION_AREA_ID *p_la_id, T_CNI_RIL3_IE_CELL_ID *p_cell_id)
+{
+ sprintf (buffer, "%1u%1u%1u%1u%1u%1x%04X%04X",
+ p_la_id->mcc[0], p_la_id->mcc[1], p_la_id->mcc[2],
+ p_la_id->mnc[0], p_la_id->mnc[1], ((unsigned)p_la_id->mnc[2] > 9) ? 0xF : p_la_id->mnc[2],
+ (unsigned short)p_la_id->lac , (unsigned short)p_cell_id->value);
+
+ status = CDR_FIELD_SET_BUT_NOT_PRINT;
+};
+
+char * CCdrFieldLACID::string()
+{
+ status = CDR_FIELD_SET_AND_PRINTED;
+ return buffer;
+};
+
+
+// CDR Field Date and Time
+
+void CCdrFieldDateTime::stamp()
+{
+ // The following time function comes from standard ANSI library.
+ // Therefore, the body of the code, including type/structure definition are
+ // the same for both Windows NT and VxWorks environment. No conditional
+ // compilation is needed between the two operating systems.
+
+ struct tm *gmt;
+
+ time (&lTime); // get local time
+ gmt = gmtime (&lTime); // convert to UTC time
+
+ // the final format is UTC time, YYMMDDhhmmss
+ sprintf(buffer,"%02d%02d%02d%02d%02d%02d",
+ gmt->tm_year % 100, // year since 1900
+ gmt->tm_mon + 1 , // month since Jan 0..11
+ gmt->tm_mday , // day of the month 1..31
+ gmt->tm_hour , // hours after midnight 0..23
+ gmt->tm_min , // minutes after hour 0..59
+ gmt->tm_sec // seconds after minutes 0..59
+ );
+
+ status = CDR_FIELD_SET_BUT_NOT_PRINT;
+}
+
+
+char * CCdrFieldDateTime::string()
+{
+ status=CDR_FIELD_SET_AND_PRINTED;
+ return buffer;
+};
+
+// CDR Base class
+void CCdrBase::initialize()
+{
+ count =0 ;
+ cdr_msg.record[0] ='\0';
+ record_type = CDR_RECORD_TYPE_INVALID;
+ event_ref_number = cdrAllocateRef () ;
+
+ served_imsi.initialize ();
+ served_msisdn.initialize ();
+}
+
+
+CCdrBase::CCdrBase()
+{
+ initialize();
+}
+
+CCdrBase::~CCdrBase()
+{
+}
+
+void CCdrBase::printBaseFields()
+{
+ // print all the fields of this class to the outbuffer
+ //
+ // A2=IP-address field of the recording entity
+ // A3=Event Reference Number
+ // A4=Served IMSI
+ // A5=Served MSISDN
+ // A6=CDR Format Version (current = 2)
+ // A7=Record Type
+ count+=sprintf(&cdr_msg.record[count],"A2=%08X", cdrGetLocalIp());
+ count+=sprintf(&cdr_msg.record[count],"%cA3=%d",CDR_FIELD_DELIMETER,event_ref_number);
+ if(served_imsi.status==CDR_FIELD_SET_BUT_NOT_PRINT)
+ count+=sprintf(&cdr_msg.record[count],"%cA4=%s",CDR_FIELD_DELIMETER,served_imsi.string());
+ if(served_msisdn.status==CDR_FIELD_SET_BUT_NOT_PRINT)
+ count+=sprintf(&cdr_msg.record[count],"%cA5=%s",CDR_FIELD_DELIMETER,served_msisdn.string());
+ count+=sprintf(&cdr_msg.record[count],"%cA6=%u",CDR_FIELD_DELIMETER, CDR_CURRENT_VERSION_NUM);
+ count+=sprintf(&cdr_msg.record[count],"%cA7=%d",CDR_FIELD_DELIMETER,(unsigned long)record_type);
+}
+
+
+void CCdrBase::generateRecord()
+{
+ // print to stdout under debug control flag
+ if(CDR_Enable_Debug) printf("%s\n", cdr_msg.record);
+
+ // send the record to the CDR client
+ cdrSendLog(&cdr_msg);
+
+ // reset the output buffer to its initial state
+ count=0;
+ cdr_msg.record[0]='\0';
+}
+
+
diff --git a/data/mnet/Common/cdr/src_client/CdrMain.cpp b/data/mnet/Common/cdr/src_client/CdrMain.cpp
new file mode 100644
index 0000000..057a92a
--- /dev/null
+++ b/data/mnet/Common/cdr/src_client/CdrMain.cpp
@@ -0,0 +1,212 @@
+// *******************************************************************
+//
+// (c) Copyright CISCO Systems Inc., 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 2.0
+// Status : Under development
+// File : CdrMain.cpp
+// Author(s) : Igal Gutkin
+// Create Date : 09-09-00
+// Description : CDR client module main task function implementation
+//
+// *******************************************************************
+
+
+// *******************************************************************
+// Include Files.
+// *******************************************************************
+
+#include "StdAfx.h"
+
+#include <msgQLib.h>
+
+#include "AlarmCode.h"
+
+#include "CdrModule.h"
+
+
+//////////////////////////////////////////////////////////////////////
+// Static data members
+//////////////////////////////////////////////////////////////////////
+bool CdrModule::bExtraInfo_ =
+#ifdef _AM_DEBUG_
+ true;
+#else
+ false;
+#endif // _AM_DEBUG_
+
+//////////////////////////////////////////////////////////////////////
+// Cdr task main loop functions
+//////////////////////////////////////////////////////////////////////
+
+bool CdrModule::mainTaskHandle ()
+{
+ int errorCode;
+ bool retVal = true;
+
+ CdrModule * module = CdrModule::getInstance();
+
+ AM_FUNC ("CdrModule::mainTaskHandle", LAYER_ID);
+ AM_ENTER();
+
+ if (module && pMainQueue_)
+ {
+ // Load system data
+ if ((retVal = module->loadData()) == false)
+ {
+ raiseModuleAlarm (EC_CDR_CLIENT_INIT_FAILED);
+ module->disable ();
+
+ // keep going in order to allow the user to update a MIB variable when MIB is not
+ // initialized properly
+ // AM_RETURN (retVal);
+ }
+ else
+ {
+ cleanModuleAlarm ();
+ cleanSslAlarm ();
+
+ // Setup CDR Server connection
+ if (!module->socketInit())
+ {
+ AM_TRACE (("CDR Client: Unable to establish link to CDR Server.\n"));
+ // Continue. Will try to establish connection later
+ }
+
+ AM_TRACE (("CDR Server IP address is set to %#08lx (%s)\n", module->srvrIp_,
+ GenSocket::getIp(module->srvrIp_) ));
+
+ if (bExtraInfo_)
+ module->printInfo ();
+ }
+
+ module->mainTask_.JCTaskEnterLoop();
+
+ while (true)
+ {
+ // Allow other tasks with the same priority to run before retriving the next
+ // message from the Queue.
+ taskDelay (NO_WAIT);
+
+ if (module->getMsg () == true)
+ {
+ AM_DEBUG (("CDR Client receivced a new message\n"));
+
+ if (!module->getStatus())
+ {
+ ++(module->lostRecs_);
+ AM_TRACE ( ("CDR Client: Logging is disabled. Discard the record %d.\n %s",
+ (module->sentRecs_+module->lostRecs_),
+ module->inMsgBuf_.record ) );
+ continue;
+ }
+
+ if (!module->isConnected() && !module->socketReset())
+ {
+ ++(module->lostRecs_);
+
+ raiseSslAlarm ();
+ raiseModuleAlarm (EC_CDR_CLIENT_UNABLE_CONNECT_SERVER);
+
+ AM_TRACE (("CDR Client: Failed connect to server. Discard the record %d:\n %s\n",
+ (module->sentRecs_+module->lostRecs_),
+ module->inMsgBuf_.record ));
+ continue;
+ }
+
+ cleanModuleAlarm ();
+ cleanSslAlarm ();
+
+ if (module->inMsgBuf_.msgType == CDR_GENERIC_MSG_TYPE)
+ {
+ AM_DEBUG (("CDR Client: Processing new log:\n%100s\n", module->inMsgBuf_.record));
+
+ errorCode = module->pSoc_->sendData (module->inMsgBuf_.record);
+
+ switch (errorCode)
+ {
+ case CDR_STATUS_OK:
+ ++(module->sentRecs_);
+ AM_TRACE (("CDR Client: Record %d sent successully\n",
+ (module->sentRecs_+module->lostRecs_)));
+ break;
+
+ case CDR_STATUS_MSG_TOO_LONG:
+ // message can't be sent over the network
+ ++(module->lostRecs_);
+ AM_WARNING (("CDR Client: Record is too long. Discard record %d.\n",
+ (module->sentRecs_+module->lostRecs_) ));
+ break;
+
+ case CDR_STATUS_FATAL_SOC_ERR:
+ // fatal socket error
+ // attempt to reconnect to the CDR server
+ AM_TRACE (("CDR Client: Server connection is broken. Attempt to reconnect.\n"));
+ if (!module->socketReset())
+ {
+ ++(module->lostRecs_);
+
+ cleanModuleAlarm ();
+ raiseModuleAlarm (EC_CDR_CLIENT_UNABLE_CONNECT_SERVER);
+
+ AM_TRACE (("CDR Client: Failed reconnect to server. Discard record %d.\n",
+ (module->sentRecs_+module->lostRecs_)));
+ break;
+ }
+ // break is omitted intentionally, continue to resend
+
+ case CDR_STATUS_TEMP_SOC_ERR:
+ // non-fatal error
+ // buffer overloading. It's possible to retry
+ if (module->pSoc_->sendData (module->inMsgBuf_.record) == CDR_STATUS_OK)
+ {
+ ++(module->sentRecs_);
+ AM_TRACE (("CDR Client: Record %d resent successully\n",
+ (module->sentRecs_+module->lostRecs_)) );
+ }
+ else
+ {
+ ++(module->lostRecs_);
+ AM_TRACE (("CDR Client: Record sending has failed. Discard record %d.\n",
+ (module->sentRecs_+module->lostRecs_)) ) ;
+ }
+ break;
+
+ default:
+ AM_TRACE (("CDR Client: Unknown return code %d from CdrRemClientSocket::sendData.\n",
+ errorCode));
+ break;
+ }
+ }
+ else
+ {
+ ++(module->lostRecs_);
+ AM_TRACE (("CDR Client: Unknown CDR Message type %lx. Discard record %d.\n",
+ module->inMsgBuf_.msgType, (module->sentRecs_+module->lostRecs_)));
+ }
+ }
+ else if (pMainQueue_)
+ { // Error on the Queue
+ AM_ERROR (("CDR Client: Error on CDR task queue read attempt.\n"));
+ }
+ else
+ { // Queue is deleted. Exit
+ break;
+ }
+ } // while
+
+ }
+ else
+ {
+ AM_ERROR (("CDR Client module is not initialised.\n"));
+ retVal = false;
+ }
+
+ AM_RETURN (retVal);
+}
+
diff --git a/data/mnet/Common/cdr/src_client/CdrModule.cpp b/data/mnet/Common/cdr/src_client/CdrModule.cpp
new file mode 100644
index 0000000..f3d8389
--- /dev/null
+++ b/data/mnet/Common/cdr/src_client/CdrModule.cpp
@@ -0,0 +1,521 @@
+// *******************************************************************
+//
+// (c) Copyright CISCO Systems, 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// Status : Under development
+// File : CdrModule.cpp
+// Author(s) : Igal Gutkin
+// Create Date : 10/02/00
+// Description : CDR client module class implementation
+//
+// *******************************************************************
+
+#include "StdAfx.h"
+
+#include "CdrModule.h"
+
+
+//////////////////////////////////////////////////////////////////////
+// Static Data members declarations
+//////////////////////////////////////////////////////////////////////
+
+CdrModule *CdrModule::pCdr_ = NULL ;
+JCMsgQueue *CdrModule::pMainQueue_= NULL ;
+
+// SSL related variables
+bool CdrModule::bUseSSL_ = false;
+bool CdrModule::bUseMibSSL_= false;
+char CdrModule::sPasswd_[SSL_MAX_PASSWORD_LENGTH+2] = "";
+
+AlarmCode_t CdrModule::majorAlarmCode_ = EC_NOERROR;
+AlarmCode_t CdrModule::infoAlarmCode_ = EC_NOERROR;
+
+
+//////////////////////////////////////////////////////////////////////
+// Constructors/Destructors
+//////////////////////////////////////////////////////////////////////
+
+CdrModule::CdrModule ()
+ : mainTask_ ("tCdrClient" ),
+ fromModId_ (MNET_MAX_MODULE_IDS),
+ srvrPort_ (AM_MAIN_SERVER_PORT),
+ pReplayQ_ (NULL ),
+ pSoc_ (NULL ),
+ logStatus_ (true ),
+ srvOnline_ (false),
+ srvrIp_ (0),
+ sentRecs_ (0),
+ lostRecs_ (0),
+ inMsgType_ (0),
+ inMsgSize_ (0),
+ localRef_ ( )
+{
+ pCdr_ = this;
+}
+
+
+CdrModule::~CdrModule ()
+{
+ int tId = mainTask_.GetTaskId();
+
+ // Suspend CDR task
+ if (tId)
+ taskSuspend (tId);
+
+ mainTask_.JCTaskNormExit();
+
+ // Close opened files, sockets and etc. before the shutdown
+
+ if (pMainQueue_)
+ delete pMainQueue_;
+
+ if (pSoc_)
+ delete pSoc_;
+
+ pMainQueue_ = NULL;
+ pCdr_ = NULL;
+ pSoc_ = NULL;
+
+ bUseSSL_ = false;
+ *sPasswd_ = '\0';
+}
+
+
+//////////////////////////////////////////////////////////////////////
+// Static methods
+//////////////////////////////////////////////////////////////////////
+
+void CdrModule::create ()
+{
+ if (!pCdr_)
+ { // Create a single CDR client module instance
+ new CdrModule ();
+ }
+}
+
+
+int CdrModule::sysCmdHandler (T_SYS_CMD sysCmd)
+{
+ int retVal = true;
+
+ AM_FUNC ("CdrModule::sysCmdHandler", LAYER_ID);
+ AM_ENTER();
+
+ switch (sysCmd)
+ {
+ case SYS_START:
+ printf ("[CDR client] Received start notification.\n");
+
+ create ();
+
+ if (pCdr_)
+ {
+ if ((retVal = pCdr_->start()) == false)
+ delete pCdr_;
+ }
+ break;
+
+ case SYS_SHUTDOWN:
+ printf ("[CDR client] Received system shutdown notification.\n");
+
+ if (pCdr_)
+ delete pCdr_;
+
+ break;
+
+ case SYS_REBOOT:
+
+ printf ("[CDR client] Reboot ready.\n");
+
+ if (pCdr_)
+ delete pCdr_;
+
+ break;
+
+ default:
+ printf ("[CDR client] Ignore unknown system command %d.\n", sysCmd);
+ break;
+ }
+
+ AM_RETURN (retVal);
+}
+
+
+
+//////////////////////////////////////////////////////////////////////
+// Public methods
+//////////////////////////////////////////////////////////////////////
+void CdrModule::printInfo ()
+{
+ SslError_t tmpError;
+
+ printf ("=====================================\n");
+ printf ("CDR Client logging is %s\n", (getStatus() ? "On" : "Off"));
+
+ printf ("CDR Client Security is%s supported, %s \n",
+ (pSoc_->isSupportSSL() ? "" : " not" ),
+ (pSoc_->isEnableSSL () ? "enabled" : "disabled"));
+
+ if (bExtraInfo_ && isSSL())
+ {
+ if ((tmpError = pSoc_->getError()) != SSL_NO_ERROR)
+ printf ("Last SSL error detected = %u\n", tmpError);
+ }
+
+ if (isSet())
+ {
+ if (bExtraInfo_)
+ {
+ printf ("CDR Client is initialized properly.\nCDR Server socket Info:\n");
+ pSoc_->printInfo();
+ }
+ else
+ {
+ printf ("CDR Client is initialized properly.\nCDR Server is set to %s\n",
+ GenSocket::getIp(getServerIp()) );
+ }
+
+ printf ("CDR stats: records sent %lu, records lost %lu\n",
+ sentRecs_, lostRecs_ );
+ }
+ else
+ {
+ printf ("CDR Socket is not initialized properly.\n");
+
+ printf ("CDR server address is set to (%s)\n",
+ GenSocket::getIp(getServerIp()) );
+ }
+
+ printf ("=====================================\n");
+}
+
+
+
+//////////////////////////////////////////////////////////////////////
+// Private methods
+//////////////////////////////////////////////////////////////////////
+
+bool CdrModule::start ()
+{
+ bool retVal = false;
+
+ AM_FUNC ("CdrModule::start", LAYER_ID);
+ AM_ENTER();
+
+ pMainQueue_ = new JCMsgQueue (CDR_MSG_Q_MAX , // max msgs that can be queued
+ CDR_MSG_SIZE_MAX, // max bytes in a msg
+ CDR_Q_OPTIONS ); // message queue options
+
+ // spawn CDR task(s)
+ if (pMainQueue_)
+ {
+ retVal = (mainTask_.JCTaskSpawn (CDR_TASK_PRIORITY ,
+ CDR_TASK_OPTION ,
+ CDR_TASK_STACK_SIZE ,
+ (FUNCPTR)mainTaskHandle,
+ 0, 0, 0, 0, 0, 0, 0 , 0, 0, 0,
+ CDR_MODULE_ID ,
+ JC_CRITICAL_TASK ) != 0);
+ }
+
+ AM_RETURN (retVal);
+}
+
+
+bool CdrModule::submitRec (CdrMessage_t* msg)
+{
+ bool retVal = false;
+ size_t recLen = strlen (msg->record);
+
+ AM_FUNC ("CdrModule::submitRec", LAYER_ID);
+ AM_ENTER ();
+
+ if (recLen >= CDR_HEADER_SIZE &&
+ recLen < CDR_MAX_DATA_LENGTH )
+ {
+ msg->msgType = CDR_GENERIC_MSG_TYPE ;
+ recLen += sizeof(msg->msgType) + 1;
+
+ retVal = (pMainQueue_->JCMsgQSend (pMainQueue_ ,
+ msg->msgType ,
+ CDR_MODULE_ID ,
+ (char *)msg ,
+ recLen ,
+ JC_WAIT_FOREVER ,
+ JC_MSG_PRI_NORMAL) == OK);
+ }
+ else
+ {
+ AM_TRACE (("Invalid record length %d. Discard message:\n %100s\n",
+ recLen, msg->record));
+ }
+
+ AM_RETURN (retVal);
+}
+
+
+bool CdrModule::getMsg ()
+{
+ // receive messages from the queue
+ return (pMainQueue_->JCMsgQReceive (&pReplayQ_ ,
+ (unsigned *)&inMsgType_,
+ &fromModId_ ,
+ (char * )&inMsgBuf_ ,
+ &inMsgSize_ ,
+ WAIT_FOREVER ) != ERROR);
+}
+
+
+bool CdrModule::socketInit ()
+{
+ bool retVal = false;
+ AM_FUNC ("CdrModule::socketInit", LAYER_ID);
+ AM_ENTER();
+
+ if (!pSoc_) // Create a socket
+ {
+ // Use SSL function only when both SSL MIB variable is true
+ // and socket library supports SSL
+ // bUseMibSSL_ is preset with the MIB value
+ bUseSSL_ = bUseMibSSL_ && GenSocketSSL::isSupportSSL();
+
+ AM_DEBUG (("Cdr Client%s using SSL\n", (bUseSSL_ ? "" : " is not") ));
+
+ // set password and initalize SSL Client context
+ if (bUseSSL_)
+ GenClientSocket::initSslContext (strlen(sPasswd_) ? sPasswd_ : NULL);
+
+ pSoc_ = new CdrRemClientSocket (bUseSSL_);
+ }
+
+ if (pSoc_)
+ {
+ retVal = pSoc_->connectServer(srvrIp_, srvrPort_);
+ srvOnline_ = retVal;
+
+ if (!srvOnline_)
+ raiseSslAlarm();
+
+#ifdef _AM_DEBUG_
+ pSoc_->printInfo ();
+#endif // _AM_DEBUG
+ }
+ else
+ {
+ AM_ERROR (("CDR Client: unable to initiate link to CDR Server on %s:%u\n",
+ GenSocket::getIp(srvrIp_), srvrPort_ ));
+ }
+
+ AM_RETURN (retVal);
+}
+
+
+bool CdrModule::socketReset ()
+{
+ bool retVal = false;
+
+ AM_FUNC ("CdrModule::socketReset", LAYER_ID);
+ AM_ENTER();
+
+ if (!pSoc_) // Create it upon need
+ retVal = socketInit ();
+ else
+ { // reset the server conection
+ retVal = pSoc_->reconnect();
+ }
+
+ srvOnline_ = retVal;
+
+ AM_TRACE (("CDR server reconnect result %d\n", retVal));
+
+ AM_RETURN (retVal);
+}
+
+
+// Raise alarm for the recognized SSL problems (only first time)
+void CdrModule::raiseSslAlarm ()
+{
+ AM_FUNC ("CdrModule::raiseSslAlarm", LAYER_ID);
+ AM_ENTER();
+
+ if (infoAlarmCode_ == EC_NOERROR)
+ {
+ switch (GenSocketSSL::getError())
+ {
+ case SSL_BAD_PASSWORD:
+ infoAlarmCode_ = EC_CDR_CLIENT_BAD_SSL_PASSWORD_FILE;
+ break;
+ case SSL_BAD_KEY:
+ infoAlarmCode_ = EC_CDR_CLIENT_BAD_SSL_KEY_FILE ;
+ break;
+ case SSL_BAD_CA_ERROR:
+ case SSL_BAD_USER_CERT:
+ infoAlarmCode_ = EC_CDR_CLIENT_BAD_LOCAL_CERTIFICATE;
+ break;
+ case SSL_BAD_PEER_CERT:
+ infoAlarmCode_ = EC_CDR_CLIENT_BAD_PEER_CERTIFICATE ;
+ break;
+ default:
+ // either non-SSL or unrecognized error
+ // will open general communication problem alarm only
+ break;
+ }
+
+ if (infoAlarmCode_ != EC_NOERROR)
+ {
+ AM_DEBUG (("Raise CDR SSL alarm %u\n", infoAlarmCode_));
+ alarm_raise (CDR_MODULE_ID, CDR_CLIENT_ALARM_ERRCODE, infoAlarmCode_);
+ }
+ }
+
+ AM_LEAVE();
+}
+
+
+// Clean SSL alarm if any
+void CdrModule::cleanSslAlarm ()
+{
+ if (infoAlarmCode_ != EC_NOERROR)
+ {
+ alarm_clear (CDR_MODULE_ID, CDR_CLIENT_ALARM_ERRCODE, infoAlarmCode_);
+ infoAlarmCode_ = EC_NOERROR;
+ }
+}
+
+
+void CdrModule::raiseModuleAlarm (AlarmCode_t code)
+{
+ // raise new CDR alarm
+ if (majorAlarmCode_ == EC_NOERROR)
+ {
+ majorAlarmCode_ = code;
+ alarm_raise (CDR_MODULE_ID, CDR_CLIENT_ALARM_ERRCODE, majorAlarmCode_);
+ }
+}
+
+
+void CdrModule::cleanModuleAlarm ()
+{
+ if (majorAlarmCode_ != EC_NOERROR)
+ {
+ alarm_clear (CDR_MODULE_ID, CDR_CLIENT_ALARM_ERRCODE, majorAlarmCode_);
+ majorAlarmCode_ = EC_NOERROR;
+ }
+}
+
+
+
+// This function should be used for debug purpose only
+bool CdrModule::switchServer (ubyte4 newSrvrIp)
+{
+ bool retVal = false;
+
+ AM_FUNC ("CdrModule::switchServer", LAYER_ID);
+ AM_ENTER();
+
+ srvrIp_ = newSrvrIp;
+
+ if (pSoc_) // Release connection to the old server
+ {
+ delete pSoc_;
+ pSoc_ = NULL;
+ }
+
+ if (retVal = socketInit())
+ {
+ AM_TRACE (("Connected to the new CDR server %s \n", GenSocket::getIp(srvrIp_)));
+ }
+ else
+ {
+ AM_TRACE (("Failed connect to the new CDR server %s \n", GenSocket::getIp(srvrIp_)));
+ }
+
+ AM_RETURN (retVal);
+}
+
+
+bool CdrModule::savePwd (LPCSTR lpPasswd)
+{
+ bool retVal = false;
+
+ AM_FUNC ("CdrModule::savePwd", LAYER_ID);
+ AM_ENTER();
+
+ if (GenSocketSSL::isSupportSSL())
+ {
+ retVal = encryptPassword (lpPasswd, getPswdFile());
+ }
+ else
+ {
+ AM_ERROR (("SSL is not supported.\n"));
+ }
+
+ AM_RETURN (retVal);
+}
+
+
+bool CdrModule::readPwd ()
+{
+ bool retVal = false;
+
+ AM_FUNC ("CdrModule::readPwd", LAYER_ID);
+ AM_ENTER();
+
+ // Read password from the password file
+ if (GenSocketSSL::isSupportSSL() && !GenSocketSSL::isPswdSet())
+ {
+ retVal = decryptPassword (sPasswd_, getPswdFile());
+
+#ifdef _AM_DEBUG_
+ AM_DEBUG (("SSL password is \"%s\" of length %u\n",
+ sPasswd_, strlen (sPasswd_) ));
+#endif // _AM_DEBUG
+ }
+
+ AM_RETURN (retVal);
+}
+
+
+LPSTR CdrModule::getPswdFile ()
+{
+ static char szFile [MAX_PATH] = "" ;
+ static bool bSet = false;
+
+ if (!bSet)
+ {
+ LPSTR pRoot = NULL;
+ size_t length = 0 ;
+
+ // Construct full pathname for the SSL password file
+ pRoot = getenv ("MNET_BASE");
+
+ if (!pRoot || !*pRoot || (strlen (pRoot) > MAX_PATH - 10))
+ {
+ pRoot = DEF_ROOT_DIR;
+ }
+
+ if (pRoot)
+ length = strlen(pRoot);
+
+ sprintf (szFile, "%s%c%s", pRoot, ((length) ? DIR_DELIMITER : '\0'), CDR_PWD_FILE_NAME);
+
+ bSet = true;
+ }
+
+ return (szFile);
+}
+
+
+// Interface for the HTTP module
+int SavePwdCdr (LPCSTR lpPasswd)
+{
+ return ((int)CdrModule::savePwd(lpPasswd));
+}
+
+
diff --git a/data/mnet/Common/cdr/src_client/CdrRefSem.cpp b/data/mnet/Common/cdr/src_client/CdrRefSem.cpp
new file mode 100644
index 0000000..e3e9a87
--- /dev/null
+++ b/data/mnet/Common/cdr/src_client/CdrRefSem.cpp
@@ -0,0 +1,42 @@
+// *******************************************************************
+//
+// (c) Copyright CISCO Systems, Inc 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 2.0
+// File : CdrRefSem.cpp
+// Author(s) : Igal Gutkin
+// Create Date : 06/20/00
+// Description : implementation of the CdrRefSem class.
+//
+// *******************************************************************
+
+#include "CdrRefSem.h"
+
+
+
+//////////////////////////////////////////////////////////////////////
+// Construction/Destruction
+//////////////////////////////////////////////////////////////////////
+
+
+//////////////////////////////////////////////////////////////////////
+// Primary behaviour methods
+//////////////////////////////////////////////////////////////////////
+
+ubyte4 CdrRefSem::allocateRef ()
+{
+ ubyte4 newRef;
+
+ mutex_.take ();
+
+ newRef = CdrRef::allocateRef();
+
+ mutex_.give ();
+
+ return (newRef);
+}
diff --git a/data/mnet/Common/cdr/src_client/CdrRemClientSocket.cpp b/data/mnet/Common/cdr/src_client/CdrRemClientSocket.cpp
new file mode 100644
index 0000000..8a517c8
--- /dev/null
+++ b/data/mnet/Common/cdr/src_client/CdrRemClientSocket.cpp
@@ -0,0 +1,71 @@
+// *******************************************************************
+//
+// (c) Copyright CISCO Systems, Inc 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 2.0
+// Status : Under development
+// File : CdrRemClientSocket.cpp
+// Author(s) : Igal Gutkin
+// Create Date : 06/20/00
+// Description : Implementation of the CdrRemClient class.
+//
+// *******************************************************************
+
+#include "StdAfx.h"
+#include "CdrCommon.h"
+
+#include "CdrRemClientSocket.h"
+
+
+//////////////////////////////////////////////////////////////////////
+// Primary behaviour methods
+//////////////////////////////////////////////////////////////////////
+
+int CdrRemClientSocket::sendData (LPSTR szData)
+{
+ AM_FUNC ("CdrRemClientSocket::sendData", LAYER_ID);
+ AM_ENTER ();
+
+ int retVal = CDR_STATUS_FATAL_SOC_ERR;
+ size_t inDataLen = strlen (szData) + 1; // correction for terminating '0'
+ int sentDataLen , socError;
+
+ if (inDataLen <= CDR_MAX_DATA_LENGTH)
+ {
+ // Prepare the message structure
+ outMsg_.hdr.msgType = htonl (CDR_GENERIC_MSG_TYPE);
+ outMsg_.hdr.dataLen = htonl (inDataLen);
+ memcpy (outMsg_.msg.logData, szData, inDataLen);
+
+ inDataLen +=clientMsgHdrLen;
+
+ retVal = tcpSend ((sbyte *)&outMsg_, inDataLen);
+ }
+ else
+ {
+ retVal = CDR_STATUS_MSG_TOO_LONG;
+
+ AM_TRACE (("CDR data length %u exciding maximum. Discard the record.\n",
+ inDataLen));
+ }
+
+ AM_RETURN (retVal);
+}
+
+
+//////////////////////////////////////////////////////////////////////
+// Service methods
+//////////////////////////////////////////////////////////////////////
+
+
+void CdrRemClientSocket::zapLog()
+{
+ memset ((char *)&outMsg_, 0, sizeof outMsg_);
+}
+
+
diff --git a/data/mnet/Common/cdr/src_client/CdrSSA.cpp b/data/mnet/Common/cdr/src_client/CdrSSA.cpp
new file mode 100644
index 0000000..271d75d
--- /dev/null
+++ b/data/mnet/Common/cdr/src_client/CdrSSA.cpp
@@ -0,0 +1,124 @@
+// *******************************************************************
+//
+// (c) Copyright Cisco 2000
+// All Rights Reserved
+//
+// *******************************************************************
+// CdrSSA.cpp: implementation of the CCdrSSA class.
+//
+//////////////////////////////////////////////////////////////////////
+
+#include "StdAfx.h"
+
+#include "Cdr\CdrSSA.h"
+
+
+CCdrSSA::CCdrSSA()
+ : CCdrBase (),
+ isInit (true )
+{
+ initialize ();
+}
+
+CCdrSSA::~CCdrSSA()
+{
+}
+
+void CCdrSSA::initialize ()
+{
+ // skip in for the very first time when is called by the constructor
+ if (!isInit)
+ CCdrBase::initialize ();
+ else
+ isInit = false;
+
+ setRecordType (CDR_RECORD_TYPE_SSA);
+
+ basic_service_code = 0 ;
+ basic_service_selector = 0 ;
+ basic_service_set = false;
+ correlated_event_ref_number = 0 ;
+ correlated_event_ref_number_set = false;
+
+ redirected_dn.initialize ();
+ transfer_dn.initialize ();
+ translated_redirected_dn.initialize ();
+ translated_transfer_dn.initialize ();
+}
+
+void CCdrSSA::setBearerServiceCode(unsigned char code)
+{
+ basic_service_set=true;
+ basic_service_selector=1;
+ basic_service_code=code;
+}
+
+void CCdrSSA::setTeleServiceCode(unsigned char code)
+{
+ basic_service_set=true;
+ basic_service_selector=2;
+ basic_service_code=code;
+}
+
+void CCdrSSA::setCorrelatedEventRefNumber( T_CDR_EVENT_REFERENCE_NUMBER event_number)
+{
+ correlated_event_ref_number_set=true;
+ correlated_event_ref_number=event_number;
+}
+
+void CCdrSSA::setRedirectedNumber(T_SUBSC_IE_ISDN * p_DN) { redirected_dn.set(p_DN); }
+void CCdrSSA::setTranslatedRedirectedNumber(T_SUBSC_IE_ISDN * p_DN){ translated_redirected_dn.set(p_DN); }
+void CCdrSSA::setTransferNumber(T_SUBSC_IE_ISDN * p_DN) { transfer_dn.set(p_DN); }
+void CCdrSSA::setTranslatedTransferNumber(T_SUBSC_IE_ISDN * p_DN) { translated_transfer_dn.set(p_DN); }
+
+void CCdrSSA::generateRecord(
+ T_CDR_SS_ACTION ss_action,
+ unsigned char ss_code,
+ T_CNI_RIL3_CAUSE_VALUE ss_cause
+ )
+{
+ CCdrFieldDateTime ss_action_time;
+
+ // get current time
+ ss_action_time.stamp();
+
+ // first generate common header fields
+ printBaseFields();
+
+ // print all the fields of this class to the outbuffer
+ //
+ // K1=SS Action
+ // K2=SS Code
+ // K3=SS Cause
+ // T5=SS Action Time
+ // N5=Redirected Number
+ // N6=Translated Redirected Number
+ // N7=Transfer Number
+ // N8=Translated Transfer Number
+ // B1=Basic Service Code
+ // R1=Correlated Event Reference Number
+ //
+ count+=sprintf(&cdr_msg.record[count],"%cK1=%02X",CDR_FIELD_DELIMETER,(unsigned long)ss_action);
+ count+=sprintf(&cdr_msg.record[count],"%cK2=%02X",CDR_FIELD_DELIMETER, ss_code);
+ count+=sprintf(&cdr_msg.record[count],"%cK3=%03d" ,CDR_FIELD_DELIMETER, ss_cause);
+
+ count+=sprintf(&cdr_msg.record[count],"%cT5=%s",CDR_FIELD_DELIMETER,ss_action_time.string());
+
+ if(redirected_dn.status==CDR_FIELD_SET_BUT_NOT_PRINT)
+ count+=sprintf(&cdr_msg.record[count],"%cN5=%s",CDR_FIELD_DELIMETER,redirected_dn.string());
+ if(translated_redirected_dn.status==CDR_FIELD_SET_BUT_NOT_PRINT)
+ count+=sprintf(&cdr_msg.record[count],"%cN6=%s",CDR_FIELD_DELIMETER,translated_redirected_dn.string());
+ if(transfer_dn.status==CDR_FIELD_SET_BUT_NOT_PRINT)
+ count+=sprintf(&cdr_msg.record[count],"%cN7=%s",CDR_FIELD_DELIMETER,transfer_dn.string());
+ if(translated_transfer_dn.status==CDR_FIELD_SET_BUT_NOT_PRINT)
+ count+=sprintf(&cdr_msg.record[count],"%cN8=%s",CDR_FIELD_DELIMETER,translated_transfer_dn.string());
+ if(basic_service_set)
+ count+=sprintf(&cdr_msg.record[count],"%cB1=%1d%02X",CDR_FIELD_DELIMETER,
+ basic_service_selector, basic_service_code );
+ if(correlated_event_ref_number_set)
+ count+=sprintf(&cdr_msg.record[count],"%cR1=%d",CDR_FIELD_DELIMETER, correlated_event_ref_number );
+
+ // send the generated record off to the CDR client
+ CCdrBase::generateRecord();
+}
+
diff --git a/data/mnet/Common/cdr/src_client/CdrSystem.cpp b/data/mnet/Common/cdr/src_client/CdrSystem.cpp
new file mode 100644
index 0000000..6f7f55a
--- /dev/null
+++ b/data/mnet/Common/cdr/src_client/CdrSystem.cpp
@@ -0,0 +1,98 @@
+// *******************************************************************
+//
+// (c) Copyright CISCO Systems, Inc 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// Status : Under development
+// File : CdrSystem.cpp
+// Author(s) : Igal Gutkin
+// Create Date : 10/02/00
+// Description : System interface for CDR module
+//
+// *******************************************************************
+
+
+#include "stdafx.h"
+
+#include "CdrModule.h"
+
+
+int SysCommand_CDR (T_SYS_CMD cmd)
+{
+ return (CdrModule::sysCmdHandler (cmd));
+}
+
+
+void CdrDataPrint ()
+{
+ CdrModule * pInst = CdrModule::getInstance();
+
+ if (pInst)
+ pInst->printInfo();
+ else
+ printf ("CDR module is not started.\n");
+}
+
+
+bool cdrSavePwd (LPCSTR lpPasswd)
+{
+ bool retVal = false;
+ CdrModule * pInst = CdrModule::getInstance();
+
+ if (pInst)
+ retVal = pInst->savePwd (lpPasswd);
+ else
+ printf ("CDR module is not started.\n");
+
+ return (retVal);
+}
+
+
+void CdrEnableExtraInfo ()
+{
+ CdrModule::getInstance()->enableExtraInfo();
+}
+
+
+void CdrDisableExtraInfo ()
+{
+ CdrModule::getInstance()->disableExtraInfo();
+}
+
+
+// CDR debug input
+void _CdrSendDebug ()
+{
+ static CdrMessage_t msg ;
+ sbyte szHostName[MAX_PATH] ;
+ ubyte4 uHostIp = 0;
+ int ch ;
+
+ struct tm *currTime;
+ time_t lTime ;
+
+ // get a local host name
+ if (gethostname (szHostName, sizeof(szHostName)) != SOC_STATUS_ERROR)
+ {
+ uHostIp = htonl (cdrGetLocalIp());
+ }
+ else
+ *szHostName = '\0';
+
+ msg.msgType = CDR_GENERIC_MSG_TYPE;
+
+ /* Obtain coordinated universal time: */
+ time (&lTime );
+ currTime = gmtime (&lTime);
+ sprintf ((char *)msg.record, "Test CDR log number %d from virtual client on host %s (%s), %s",
+ cdrAllocateRef(), szHostName, GenSocket::getIp(uHostIp), asctime(currTime));
+
+ printf ("Sending CDR log: %s\n", msg.record);
+
+ cdrSendLog (&msg);
+}
diff --git a/data/mnet/Common/cdr/src_client/Makefile b/data/mnet/Common/cdr/src_client/Makefile
new file mode 100644
index 0000000..252ec4a
--- /dev/null
+++ b/data/mnet/Common/cdr/src_client/Makefile
@@ -0,0 +1,61 @@
+##########################################################
+#
+# (c) Copyright Cisco 2000
+# All Rights Reserved
+#
+# Use Examples:
+#
+# Case 1:
+# make all VOB=GP10 -
+# Places .out in VOB/bin directory
+#
+# Case 2:
+# make all VOB=GP10 APPDIR=Host\<Application Name>\<Source Directory> -
+# Places .o file(s) in VOB\$(APPDIR)\bin directory.
+#
+# <Application Name> = Name of Application directory
+# <Source Directory> = application sub directory where the calling
+# Makefile resides.
+#
+# Example: make all VOB=GP10 APPDIR=Host\vxTemplate\src
+#
+#
+# Note: This make file must reference a VOB that
+# has a defs.mk in the top level directory.
+#
+##########################################################
+
+# TOP_OF_VOB must be defined before including l3defs.mk
+TOP_OF_VOB = ..\..
+
+# Name of this App's Directory
+THIS_APP_DIR = cdr
+
+VOB2DIR = $(TOP_OF_VOB)\..\$(VOB)
+BINDIR = ..\bin
+
+ifeq ($(APPDIR),)
+ MY_OUTPUT = $(VOB2DIR)\bin\cdr_client.out
+else
+ MY_OUTPUT = $(OBJDIR)\cdr_client.out
+endif
+
+include $(VOB2DIR)\l3defs.mk
+
+
+all: $(MY_OUTPUT)
+
+$(MY_OUTPUT): $(MODULE_OBJS)
+ $(LD) -r -o $@.tmp $(MODULE_OBJS)
+ $(NM) $@.tmp | munch > _ctdt.c
+ $(CC) -traditional $(CC_ARCH_SPEC) -c _ctdt.c
+ $(LD) -r -o $@ _ctdt.o $@.tmp
+ $(RM)$(subst /,$(DIRCHAR), _ctdt.c _ctdt.o $@.tmp)
+
+cleanall:
+ @for %f in ($(notdir $(MODULE_OBJS))) do \
+ $(RM) ..\bin\%f
+
+ $(RM) $(MY_OUTPUT)
+
+
diff --git a/data/mnet/Common/cdr/src_client/readme.txt b/data/mnet/Common/cdr/src_client/readme.txt
new file mode 100644
index 0000000..de5c2c5
--- /dev/null
+++ b/data/mnet/Common/cdr/src_client/readme.txt
@@ -0,0 +1 @@
+This folder contains source files common for the CDR Client applications.
diff --git a/data/mnet/Common/cdr/src_server/ConnList.cpp b/data/mnet/Common/cdr/src_server/ConnList.cpp
new file mode 100644
index 0000000..8ea9a77
--- /dev/null
+++ b/data/mnet/Common/cdr/src_server/ConnList.cpp
@@ -0,0 +1,177 @@
+// *******************************************************************
+//
+// (c) Copyright CISCO Systems Inc. 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// Status : Under development
+// File : ConnList.cpp
+// Author(s) : Igal Gutkin
+// Create Date : 6/21/00
+// Description :
+//
+// *******************************************************************
+
+
+#include "stdAfx.h"
+#include "ConnList.h"
+
+// *******************************************************************
+// Class ClientConnection
+// *******************************************************************
+
+/*----------------------------------------------------------------------------**
+**
+** METHOD NAME: ClientConnection constructor
+**
+** PURPOSE: Save the socket for this connection and initialize the next
+** pointer to be null.
+**
+** INPUT PARAMETERS: sock - socket for the new client connection
+**
+** RETURN VALUE(S): none
+**
+**----------------------------------------------------------------------------*/
+ClientConnection::ClientConnection (GenSocket& Client)
+ : connSock_ (Client), next_ (NULL)
+{
+ ;
+}
+
+
+/*----------------------------------------------------------------------------**
+**
+** METHOD NAME: ClientConnection destructor
+**
+** PURPOSE: Delete ClientConnection data members.
+**
+** INPUT PARAMETERS: none
+**
+** RETURN VALUE(S): none
+**
+**----------------------------------------------------------------------------*/
+ClientConnection::~ClientConnection ()
+{
+ delete &connSock_;
+}
+
+
+int ClientConnection::serveClient (const fd_set *set)
+{
+ GenSocket * notInUse = NULL; // dummy value
+
+ return (getClient()->serve(set, notInUse));
+}
+
+
+
+// *******************************************************************
+// Class ClientConnectionList
+// *******************************************************************
+
+/*----------------------------------------------------------------------------**
+**
+** METHOD NAME: ClientConnectionList constructor
+**
+** PURPOSE: Initialize list to be null.
+**
+** INPUT PARAMETERS: none
+**
+** RETURN VALUE(S): none
+**
+**----------------------------------------------------------------------------*/
+ClientConnectionList::ClientConnectionList()
+{
+ pConnListHead_ = NULL;
+}
+
+
+/*----------------------------------------------------------------------------**
+**
+** METHOD NAME: ClientConnectionList destructor
+**
+** PURPOSE: Delete ClientConnectionList data members.
+**
+** INPUT PARAMETERS: none
+**
+** RETURN VALUE(S): none
+**
+**----------------------------------------------------------------------------*/
+ClientConnectionList::~ClientConnectionList()
+{
+ ClientConnection *pPrevConn, *pCurrConn = pConnListHead_;
+
+ while (pCurrConn)
+ {
+ pPrevConn = pCurrConn;
+ pCurrConn = pCurrConn->next_;
+ delete pPrevConn;
+ }
+}
+
+/*----------------------------------------------------------------------------**
+**
+** METHOD NAME: InsertClientConnection
+**
+** PURPOSE: Insert an client connection at the head of the list.
+**
+** INPUT PARAMETERS: pConn - pointer to the connection object to be added.
+**
+** RETURN VALUE(S): SOC_STATUS_OK - for success
+** SOC_STATUS_ERROR - for failure
+**
+**----------------------------------------------------------------------------*/
+SOC_STATUS ClientConnectionList::InsertClientConnection (ClientConnection *pConn)
+{
+ pConn->next_ = pConnListHead_;
+ pConnListHead_ = pConn;
+ return (SOC_STATUS_OK);
+}
+
+/*----------------------------------------------------------------------------**
+**
+** METHOD NAME: DeleteClientConnection
+**
+** PURPOSE: Remove an client connection from the list of client connections.
+** The socket is used as the identifier to locate the client connection.
+**
+** INPUT PARAMETERS: sock - socket for the desired client connection
+**
+** RETURN VALUE(S): SOC_STATUS_OK - for success
+** SOC_STATUS_ERROR - for failure
+**
+**----------------------------------------------------------------------------*/
+SOC_STATUS ClientConnectionList::DeleteClientConnection (ClientConnection *pConn)
+{
+ ClientConnection *pCurrConn, *pPrevConn;
+ OS_SPECIFIC_SOCKET_HANDLE Socket = pConn->getSocket();
+
+ pCurrConn = pPrevConn = pConnListHead_;
+
+ while (pCurrConn)
+ {
+ if (pCurrConn->connSock_.getSocket() == Socket)
+ {
+ if (pCurrConn == pConnListHead_)
+ {
+ pConnListHead_ = pCurrConn->next_;
+ }
+ else
+ {
+ pPrevConn->next_ = pCurrConn->next_;
+ }
+
+ delete pCurrConn;
+ break;
+ }
+
+ pPrevConn = pCurrConn;
+ pCurrConn = pCurrConn->next_;
+ }
+
+ return (SOC_STATUS_OK);
+}
diff --git a/data/mnet/Common/cdr/src_server/Makefile b/data/mnet/Common/cdr/src_server/Makefile
new file mode 100644
index 0000000..3c7aaeb
--- /dev/null
+++ b/data/mnet/Common/cdr/src_server/Makefile
@@ -0,0 +1,62 @@
+##########################################################
+#
+# (c) Copyright Cisco 2000
+# All Rights Reserved
+#
+# Use Examples:
+#
+# Case 1:
+# make all VOB=GP10 -
+# Places .out in VOB/bin directory
+#
+# Case 2:
+# make all VOB=GP10 APPDIR=Host\<Application Name>\<Source Directory> -
+# Places .o file(s) in VOB\$(APPDIR)\bin directory.
+#
+# <Application Name> = Name of Application directory
+# <Source Directory> = application sub directory where the calling
+# Makefile resides.
+#
+# Example: make all VOB=GP10 APPDIR=Host\vxTemplate\src
+#
+#
+# Note: This make file must reference a VOB that
+# has a defs.mk in the top level directory.
+#
+##########################################################
+
+# TOP_OF_VOB must be defined before including l3defs.mk
+TOP_OF_VOB = ..\..
+
+# Name of this App's Directory
+THIS_APP_DIR = cdrserver
+
+VOB2DIR = $(TOP_OF_VOB)\..\$(VOB)
+BINDIR = ..\bin
+
+ifeq ($(APPDIR),)
+ MY_OUTPUT = $(VOB2DIR)\bin\cdr_common_src_server.out
+else
+ MY_OUTPUT = $(OBJDIR)\cdr_common_src_server.out
+endif
+
+include $(VOB2DIR)\l3defs.mk
+CC_INCLUDE += -I$(COMMON_VOB_DIR)/os
+
+all: $(MY_OUTPUT)
+
+$(MY_OUTPUT): $(MODULE_OBJS)
+ $(LD) -r -o $@.tmp $(MODULE_OBJS)
+ $(NM) $@.tmp | munch > _ctdt.c
+ $(CC) -traditional $(CC_ARCH_SPEC) -c _ctdt.c
+ $(LD) -r -o $@ _ctdt.o $@.tmp
+ $(RM)$(subst /,$(DIRCHAR), _ctdt.c _ctdt.o $@.tmp)
+
+
+cleanall:
+ @for %f in ($(notdir $(MODULE_OBJS))) do \
+ $(RM) ..\bin\%f
+
+ $(RM) $(MY_OUTPUT)
+
+
diff --git a/data/mnet/Common/cdr/src_test/simulator.cpp b/data/mnet/Common/cdr/src_test/simulator.cpp
new file mode 100644
index 0000000..fd723a0
--- /dev/null
+++ b/data/mnet/Common/cdr/src_test/simulator.cpp
@@ -0,0 +1,278 @@
+// *******************************************************************
+//
+// (c) Copyright CISCO Systems, Inc 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 2.0
+// File : simulator.cpp
+// Author(s) : Igal Gutkin
+// Create Date : 08/28/01
+// Description : Cdr Client simulator
+//
+// *******************************************************************
+
+#include "stdafx.h"
+#include "Os\JCCTimer.h"
+#include "Os\JCMsgQueue.h"
+#include "Os\JCTask.h"
+
+#include "CdrModule.h"
+
+#define CDR_DEFAULT_PERIOD 10
+#define CDR_SIM_PIPE "/pipe/cdrSimPipe"
+
+#ifdef __cplusplus
+ extern "C"
+ {
+ bool _CdrInitTest ();
+ void _CdrCleanTest ();
+
+ bool _CdrStartTest (unsigned period = 0, unsigned num = 0);
+ void _CdrStopTest ();
+
+ void _CdrSimCallback ();
+ bool _CdrSimHandle ();
+
+ void _CdrTestStatus ();
+ void _CdrSimHelp ();
+
+ }
+#endif
+
+// CDR message resend timer
+static JCCTimer *pCdrSimTimer;
+static JCMsgQueue *pCdrSimQueue;
+static JCTask *pCdrSimTask ;
+
+static unsigned uTime = CDR_DEFAULT_PERIOD;
+
+static int iMaxTimes = 0,
+ iCount = 0;
+
+static bool bCdrSimSet = false,
+ bCdrTestStart = false;
+
+//===================================================================
+
+void _CdrSimHelp ()
+{
+ printf ("Cdr Client Simulator Commands:\n\
+ _CdrTestStatus - print simulation status\n\
+ _CdrInitTest - initialize simulator\n\
+ _CdrCleanTest - remove simulator\n\
+ _CdrStartTest - begin simulation\n\
+ Parameters : (period [in 100 mS], number of messages [0 - unlimited]\n\
+ _CdrStopTest - end simulation\n");
+}
+
+
+bool _CdrInitTest ()
+{
+ bool retVal = false;
+
+ if (bCdrSimSet)
+ {
+ printf ("CDR simulator is initialized already\n");
+ return (true);
+ }
+
+ if ((pCdrSimTimer = new JCCTimer((FUNCPTR)_CdrSimCallback)) != NULL)
+ {
+ if ((pCdrSimQueue = new JCMsgQueue (200 , // max num of msgs
+ sizeof (int) , // max size of a msg
+ JC_MSG_Q_FIFO )) // message queue options
+ != NULL)
+ { // create and spawn simulator task
+ if (pCdrSimTask = new JCTask ("tCdrSim"))
+ {
+ if (pCdrSimTask->JCTaskSpawn (100, 0, 5000 ,
+ (FUNCPTR)_CdrSimHandle,
+ 0, 0, 0, 0, 0 ,
+ 0, 0, 0, 0, 0 ,
+ CDR_MODULE_ID ,
+ JC_NON_CRITICAL_TASK ) != ERROR)
+ {
+ retVal = true;
+ bCdrSimSet = true;
+ }
+ }
+ }
+ }
+
+ if (!retVal)
+ {
+ printf ("Unable to start CDR Client Simulator\n");
+ _CdrCleanTest ();
+ }
+
+ return (retVal);
+}
+
+
+void _CdrCleanTest ()
+{
+ // kill timer
+ if (pCdrSimTimer)
+ {
+ _CdrStopTest ();
+ delete pCdrSimTimer;
+ pCdrSimTimer = NULL;
+ }
+
+ // kill task
+ if (pCdrSimTask)
+ {
+ int tId = pCdrSimTask->GetTaskId();
+
+ taskSuspend (tId);
+ taskDelete (tId);
+ delete pCdrSimTask;
+ pCdrSimTask = NULL;
+ }
+
+ // kill queue
+ if (pCdrSimQueue)
+ {
+ delete pCdrSimQueue;
+ pCdrSimQueue = NULL;
+ }
+
+ bCdrSimSet = false;
+}
+
+// use resolution of 100 mSec
+// number of attempts = 0 ==> unlimited till stop is called
+bool _CdrStartTest (unsigned period, unsigned num)
+{
+ bool retVal = false;
+
+ if (bCdrSimSet || (retVal=_CdrInitTest()) )
+ {
+ if (!bCdrTestStart)
+ {
+ uTime = (period) ? period : CDR_DEFAULT_PERIOD;
+ iMaxTimes = (int)num;
+
+ pCdrSimTimer->setTimerMSec (period);
+ bCdrTestStart = true;
+ retVal = true;
+ printf ("CDR Client simulation begin\n");
+ }
+ else
+ printf ("CDR Client simulator is already started\n");
+ }
+
+ return (retVal);
+}
+
+
+void _CdrStopTest ()
+{
+ if (bCdrSimSet)
+ {
+ pCdrSimTimer->cancelTimer();
+
+ iMaxTimes = 0;
+ iCount = 0;
+ bCdrTestStart = false ;
+ uTime = CDR_DEFAULT_PERIOD;
+ }
+}
+
+
+void _CdrTestStatus ()
+{
+ if (bCdrSimSet)
+ {
+ printf ("CDR Client Simulator is %s\n", ((bCdrTestStart) ? "running" : "stoped") );
+ }
+ else
+ printf ("CDR Client Simulator is not initialized\n");
+}
+
+
+//===================================================================
+
+// simulator task handler
+bool _CdrSimHandle ()
+{
+ bool keepGoing = true;
+ CdrMessage_t msg ;
+ sbyte szHostName[MAX_PATH];
+ ubyte4 uHostIp = 0;
+ struct tm *currTime ;
+ time_t lTime ;
+
+ JCMsgQueue *pReplayQ ;
+ unsigned inMsgType ,
+ inMsgSize ,
+ inMsgBuf ;
+
+ MNET_MODULE_ID fromModId;
+
+ // Spin here forever waiting for simulator activations
+ while (keepGoing)
+ {
+ if (pCdrSimQueue->JCMsgQReceive (&pReplayQ ,
+ &inMsgType ,
+ &fromModId ,
+ (char *)&inMsgBuf,
+ &inMsgSize ,
+ WAIT_FOREVER ) != ERROR)
+ {
+ if (!uHostIp)
+ {
+ msg.msgType = CDR_GENERIC_MSG_TYPE;
+
+ // get a local host name
+ if (gethostname (szHostName, sizeof(szHostName)) != SOC_STATUS_ERROR)
+ {
+ uHostIp = htonl (cdrGetLocalIp());
+ }
+ else
+ *szHostName = '\0';
+ }
+
+ /* Obtain coordinated universal time: */
+ time (&lTime);
+ currTime = gmtime (&lTime);
+ sprintf ((char *)msg.record, "Test log number %u [ref. %u] from a virtual client on host %s [%s], %s",
+ iCount, cdrAllocateRef(), szHostName, GenSocket::getIp(uHostIp), asctime(currTime) );
+
+ cdrSendLog (&msg);
+ }
+ }
+
+ return (true);
+}
+
+
+// timer ISR call back
+void _CdrSimCallback ()
+{
+ static CdrMessage_t msg ;
+ static sbyte szHostName[MAX_PATH];
+ static ubyte4 uHostIp = 0;
+
+ struct tm *currTime;
+ time_t lTime ;
+
+ if (!iMaxTimes || iCount < iMaxTimes)
+ {
+ ++iCount;
+
+ pCdrSimQueue->JCMsgQSend (pCdrSimQueue, 0, CDR_MODULE_ID, (char *)&iCount, sizeof iCount,
+ JC_NO_WAIT, JC_MSG_PRI_NORMAL);
+
+ pCdrSimTimer->setTimerMSec (uTime, iCount);
+ }
+ else
+ {
+ _CdrStopTest ();
+ }
+
+}
diff --git a/data/mnet/Common/cli/Makefile b/data/mnet/Common/cli/Makefile
new file mode 100644
index 0000000..ff0ff37
--- /dev/null
+++ b/data/mnet/Common/cli/Makefile
@@ -0,0 +1,47 @@
+##########################################################
+#
+# (c) Copyright Cisco 2000
+# All Rights Reserved
+#
+# Use Examples:
+#
+# Case 1:
+# make all VOB=GP10 -
+# Places .out in VOB/bin directory
+#
+# Case 2:
+# make all VOB=GP10 APPDIR=Host\<Application Name>\<Source Directory> -
+# Places .o file(s) in VOB\$(APPDIR)\bin directory.
+#
+# <Application Name> = Name of Application directory
+# <Source Directory> = application sub directory where the calling
+# Makefile resides.
+#
+# Example: make all VOB=GP10 APPDIR=Host\vxTemplate\src
+#
+# (OPTIONAL) Append REPLACE - Replaces the List of directories
+# to be used in the SUBDIRS variable
+#
+# Example: make all VOB=GP10 APPDIR=Host\vxTemplate\src REPLACE="src_api src_debug"
+#
+# Note: This make file must reference a VOB that
+# has a defs.mk in the top level directory.
+#
+##########################################################
+
+SUBDIRS = src vxsh
+
+# TOP_OF_VOB must be defined before including l3defs.mk
+TOP_OF_VOB = ..
+
+VOBDIR = $(TOP_OF_VOB)/../$(VOB)
+
+# Allows a sub-set of the source code directories to be used
+
+ifneq ($(REPLACE),)
+ SUBDIRS = $(REPLACE)
+endif
+
+include $(VOBDIR)\l3defs.mk
+
+
diff --git a/data/mnet/Common/cli/include/address.h b/data/mnet/Common/cli/include/address.h
new file mode 100644
index 0000000..64ea31b
--- /dev/null
+++ b/data/mnet/Common/cli/include/address.h
@@ -0,0 +1,188 @@
+/* $Id: address.h,v 10.7 1999/08/17 01:05:18 sutton Exp $
+ * $Source: /export/sbcc/cepro/h/parser/address.h,v $
+ *------------------------------------------------------------------
+ * Cisco MicroWeb Server Version 2
+ *
+ * File: address.h
+ * Description: Address(es) Header
+ * Owner: Prasanna Parthasarathy
+ * Notes:
+ *
+ * Copyright (c) 1997 by cisco Systems, Inc.
+ * All rights reserved.
+ *------------------------------------------------------------------
+ * $Log: address.h,v $
+ * Revision 10.7 1999/08/17 01:05:18 sutton
+ * Replaced red-black tree implementation with IOS code.
+ * CSCdm75775: Assert in cepro_201b11_dbg_cus1
+ *
+ * Revision 10.6 1999/08/05 20:53:51 vernikov
+ * CSCdm69411: delete of defualt gateway from GUI is BAD
+ *
+ * Revision 10.5.14.2 1999/08/16 23:18:33 sutton
+ * Replaced red-black tree implementation with code from IOS.
+ * CSCdm75775: Assert in cepro_201b11_dbg_cus1
+ * Branch: ROBIN202BR
+ *
+ * Revision 10.5.14.1 1999/08/05 20:51:27 vernikov
+ * CSCdm69411: delete of defualt gateway from GUI is BAD
+ * Branch: ROBIN202BR
+ *
+ * Revision 10.5 1999/03/30 02:15:17 vernikov
+ * CSCdm08933: Need validation during configuration of certain address
+ * fields
+ *
+ * Revision 10.4 1999/02/19 09:55:45 loril
+ * CSCdm02735: Add hostname support & martian validation in cli & gui
+ * where needed
+ *
+ * Revision 10.3 1998/10/07 03:03:41 pradeep
+ * CSCdk50280: ICP CLI needes to be checked in
+ *
+ * Revision 10.2 1998/07/11 16:51:04 sutton
+ * Straighten out some of the spaghetti dependencies between modules.
+ * CSCdk13101: merge MicroServer and Cache Engine source trees
+ *
+ * Revision 10.1 1998/06/09 17:41:39 sutton
+ * code merge
+ *
+ * Revision 1.2 1997/10/09 18:14:14 pparthas
+ * First Attempt to cleanup dead-code to reduce code-size; Included debug
+ * scheme in place
+ *
+ * Revision 1.1 1997/06/25 00:36:54 pparthas
+ * Initial Commit
+ *
+ *------------------------------------------------------------------
+ * $Endlog$
+ */
+
+#ifndef __ADDRESS_H__
+#define __ADDRESS_H__
+
+
+#define CLASS_A_BIT 0x80000000 /* off for class A, on for B, C, D */
+#define CLASS_B_BIT 0x40000000 /* off for class B, on for C, D */
+#define CLASS_C_BIT 0x20000000 /* off for class C, on for D */
+#define CLASS_D_BIT 0x10000000 /* off for class D */
+
+#define CLASSA_BIT 0x80 /* off for class A, on for B, C, D */
+#define CLASSB_BIT 0x40 /* off for class B, on for C, D */
+#define CLASSC_BIT 0x20 /* off for class C, on for D */
+#define CLASSD_BIT 0x10 /* off for class D */
+
+#define CLASS_A_MASK 0xFF000000 /* mask for class A net */
+#define CLASS_B_MASK 0xFFFF0000 /* mask for class B net */
+#define CLASS_C_MASK 0xFFFFFF00 /* mask for class C net */
+#define CLASS_D_MASK 0x00000000 /* mask for class D net??? */
+
+#define CLASS_A_SHIFT 24 /* A: bits shift to make int */
+#define CLASS_B_SHIFT 16 /* B: bits shift to make int */
+#define CLASS_C_SHIFT 8 /* C: bits shift to make int */
+
+#define ADDR_ILLEGAL 0 /* illegal address */
+#define ADDR_IP 1 /* IP address */
+
+#define ADDRLEN_IP 4
+
+/*
+ * Flag bit definitions for use in martian() api
+ */
+#define MARTIAN_FLAG_IS_HOST 0x01 /* TRUE => ipaddr is a host */
+ /* FALSE => ipaddr may be a */
+ /* network address */
+#define MARTIAN_FLAG_MULTICAST_ALLOWED 0x02 /* TRUE => do not consider a */
+ /* CLASS D ipaddr */
+ /* a martian addr */
+ /* FALSE => do consider a */
+ /* CLASS D ipaddr */
+ /* a martian addr */
+
+/*
+ * Special networks and addresses.
+ */
+#define IP_LOOPBACK_NET 0x7f000000 /* 127.0.0.0 */
+#define MASK_HOST 0xffffffff /* 255.255.255.255 */
+#define IP_LIMITED_BROADCAST 0xffffffff /* 255.255.255.255 */
+#define IP_BSD_LIMITED_BROADCAST 0 /* 0.0.0.0 */
+#define IPADDR_ZERO ((ipaddrtype) 0) /* for use as a default address */
+
+
+union addresses {
+ ipaddrtype ip_address;
+};
+
+#define ip_addr addr.ip_address
+
+typedef struct addrtype_ {
+ uchar type;
+ uchar length;
+ union addresses addr;
+} addrtype;
+
+/* Structure and #defines used in parser_ipaddr_or_hostname() api */
+
+typedef struct ipAddr_ {
+ ipaddrtype ipAddrNetOrder; /* network byte order */
+ ipaddrtype ipAddrHostOrder; /* host byte order */
+ char ipAddrStr[INET_ADDR_LEN]; /* dotted-decimal string */
+} ipAddr_t, *pIpAddr_t;
+
+/* Values of flags as the calling parameter to parser_ipaddr_or_hostname() */
+
+#define IPADDR_CLI_PROCESSING 0x01 /* TRUE => processing for cli
+ * FALSE => processing for gui
+ */
+#define IPADDR_CLI_IN_HELP 0x02 /* Flag is valid only if
+ * IPADDR_CLI_HANDLING == TRUE
+ * TRUE => in cli help
+ * processing
+ * FALSE => not in cli help
+ * processing
+ */
+#define IPADDR_HOSTNAME_ALLOWED 0x04 /* TRUE => input string can
+ * be ipaddr or
+ * hostname
+ * FALSE => input string can
+ * an ipaddr only
+ */
+#define IPADDR_MARTIAN_TEST_REQUIRED 0x08 /* TRUE => do martian test
+ * FALSE => skip martian test
+ */
+#define IPADDR_MARTIAN_IS_HOST_ADDRESS 0x10 /* Flag is valid only if
+ * IPADDR_MARTIAN_TEST_REQUIRED
+ * == TRUE
+ * TRUE => input is host addr
+ * FALSE => input can be a
+ * network addr
+ */
+
+#define IPADDR_MARTIAN_MULTICAST_ALLOWED 0x20 /* Flag is valid only if
+ * IPADDR_MARTIAN_TEST_REQUIRED
+ * == TRUE
+ * TRUE => multicast addr
+ * wil not be
+ * consider a
+ * martian
+ * FALSE => multicast addr
+ * will be considered
+ * a martian
+ */
+
+#define IPADDR_DEFAULT_ROUTING 0x40 /* Flag is valid only for
+ * default routing
+ * if ip address is 0.0.0.0
+ */
+
+/* The default flags represent what the GUI uses in most cases. */
+
+#define IPADDR_GUI_DEFAULT_FLAGS (IPADDR_HOSTNAME_ALLOWED | \
+ IPADDR_MARTIAN_TEST_REQUIRED | \
+ IPADDR_MARTIAN_IS_HOST_ADDRESS)
+
+extern void ip_address_init( void );
+extern boolean good_address (ipaddrtype , ipaddrtype , boolean );
+extern boolean martian (ipaddrtype , ulong);
+extern int parser_ipaddr_or_hostname (char *, int *, ulong, pIpAddr_t, char **);
+extern int ValidateNetMask (ipaddrtype, char *, char **);
+#endif /* __ADDRESS_H__ */
diff --git a/data/mnet/Common/cli/include/cfg_end.h b/data/mnet/Common/cli/include/cfg_end.h
new file mode 100644
index 0000000..259e6e9
--- /dev/null
+++ b/data/mnet/Common/cli/include/cfg_end.h
@@ -0,0 +1,49 @@
+/* $Id: cfg_end.h,v 10.2 1998/12/30 18:13:01 sundars Exp $
+ * $Source: /export/sbcc/cepro/os/parser/src/cfg_end.h,v $
+ *------------------------------------------------------------------
+ * Cisco MicroWeb Server Version 2
+ *
+ * File: cfg_end.h
+ * Description: end - exit configuration mode
+ * Owner: Prasanna Parthasarathy
+ * Notes:
+ *
+ * Copyright (c) 1997 by cisco Systems, Inc.
+ * All rights reserved.
+ *------------------------------------------------------------------
+ * $Log: cfg_end.h,v $
+ * Revision 10.2 1998/12/30 18:13:01 sundars
+ * Fix help texts for CLI commands
+ * CSCdk69292: CLI Command Descriptions When Entering a ?-Part 2
+ *
+ * Revision 10.1 1998/06/10 20:41:51 sutton
+ * code merge
+ *
+ * Revision 1.4 1998/04/21 01:26:41 pparthas
+ * CLI Related changes / Undo log / Errno propagation
+ * CSCdj68847: CLI changes
+ *
+ * Revision 1.3 1997/08/04 19:28:27 pparthas
+ * Made 'end' from config mode a hidden command
+ *
+ * Revision 1.2 1997/05/14 22:12:01 pparthas
+ * Removed test_* files. Included some files for Show routines
+ * and cleaned-up file structure ( not source code ;-) )
+ *
+ *------------------------------------------------------------------
+ * $Endlog$
+ */
+
+/***************************************************************
+ * end
+ *
+ * exits from config mode
+ */
+
+EOLS (act_end_configure, exit_config_command, CMD_END);
+
+KEYWORD (end_configure, act_end_configure, ALTERNATE, "end",
+ "Exit configuration mode", PRIV_MIN);
+
+#undef ALTERNATE
+#define ALTERNATE end_configure
diff --git a/data/mnet/Common/cli/include/cfg_exit.h b/data/mnet/Common/cli/include/cfg_exit.h
new file mode 100644
index 0000000..722e2e4
--- /dev/null
+++ b/data/mnet/Common/cli/include/cfg_exit.h
@@ -0,0 +1,42 @@
+/* $Id: cfg_exit.h,v 10.2 1998/12/30 18:13:01 sundars Exp $
+ * $Source: /export/sbcc/cepro/os/parser/src/cfg_exit.h,v $
+ *------------------------------------------------------------------
+ * Cisco MicroWeb Server Version 2
+ *
+ * File: cfg_exit.h
+ * Description: exit - exit configuration mode
+ * Owner: Prasanna Parthasarathy
+ * Notes:
+ *
+ * Copyright (c) 1997 by cisco Systems, Inc.
+ * All rights reserved.
+ *------------------------------------------------------------------
+ * $Log: cfg_exit.h,v $
+ * Revision 10.2 1998/12/30 18:13:01 sundars
+ * Fix help texts for CLI commands
+ * CSCdk69292: CLI Command Descriptions When Entering a ?-Part 2
+ *
+ * Revision 10.1 1998/06/10 20:41:52 sutton
+ * code merge
+ *
+ * Revision 1.2 1997/05/14 22:12:02 pparthas
+ * Removed test_* files. Included some files for Show routines
+ * and cleaned-up file structure ( not source code ;-) )
+ *
+ *------------------------------------------------------------------
+ * $Endlog$
+ */
+
+/***************************************************************
+ * exit
+ *
+ * exits from config mode
+ */
+
+EOLS (act_exit_configure, exit_config_command, CMD_EXIT);
+
+KEYWORD (exit_configure, act_exit_configure, ALTERNATE,
+ "exit", "Exit configuration mode", PRIV_MIN);
+
+#undef ALTERNATE
+#define ALTERNATE exit_configure
diff --git a/data/mnet/Common/cli/include/cli_parser_api.h b/data/mnet/Common/cli/include/cli_parser_api.h
new file mode 100644
index 0000000..b1815aa
--- /dev/null
+++ b/data/mnet/Common/cli/include/cli_parser_api.h
@@ -0,0 +1,18 @@
+#ifndef __CLI_PARSER_API_H__
+#define __CLI_PARSER_API_H__
+
+/* exported by cli_parser_init.c */
+extern void CliParserInit();
+extern void CliIOInit (int);
+
+/* exported by debug.cpp */
+
+extern void debug_init();
+
+/* exported by command_chain.cpp */
+extern void command_parser_init();
+
+/* exported by exec_chain.cpp */
+extern void exec_parser_init();
+
+#endif /* __CLI_PARSER_API_H__ */
diff --git a/data/mnet/Common/cli/include/cli_parser_private.h b/data/mnet/Common/cli/include/cli_parser_private.h
new file mode 100644
index 0000000..31758f2
--- /dev/null
+++ b/data/mnet/Common/cli/include/cli_parser_private.h
@@ -0,0 +1,11 @@
+#ifndef __CLI_PARSER_PRIVATE_H__
+#define __CLI_PARSER_PRIVATE_H__
+
+#define PARSER_TASK_PRIORITY 150
+#define PARSER_TASK_OPTION 0
+#define PARSER_TASK_STACK_SIZE 20000
+#define DEBUG_CLI_PARSER 0
+
+#define DBG_PARSER(s) if (DEBUG_CLI_PARSER) printf(s);
+
+#endif /* __CLI_PARSER_PRIVATE_H__ */
diff --git a/data/mnet/Common/cli/include/cli_private.h b/data/mnet/Common/cli/include/cli_private.h
new file mode 100644
index 0000000..7b40c2a
--- /dev/null
+++ b/data/mnet/Common/cli/include/cli_private.h
@@ -0,0 +1,114 @@
+#ifndef __CLI_PRIVATE_H__
+#define __CLI_PRIVATE_H__
+
+typedef char tOCTET; /* signed octet */
+typedef unsigned char tUOCTET; /* unsigned octet */
+typedef int tINT; /* Integer */
+typedef short tOCTET2; /* signed 2 octets */
+typedef short s_size_t; /* signed size_t */
+typedef unsigned us_size_t; /* unsigned size_t */
+typedef long tOCTET4; /* signed 4 octets */
+typedef unsigned short tUOCTET2; /* unsigned 2 octets */
+typedef unsigned long tUOCTET4; /* unsigned 4 octets */
+typedef FILE tFILE;
+typedef int tTASKID;
+typedef int boolean;
+typedef uint32_t ipaddrtype;
+
+ /*
+ **
+ ** Basic data type pointers
+ **
+ */
+
+typedef char * tpOCTET;
+typedef unsigned char * tpUOCTET;
+typedef short * tpOCTET2;
+typedef long * tpOCTET4;
+typedef unsigned short * tpUOCTET2;
+typedef unsigned long * tpUOCTET4;
+
+/*
+ * libc data types
+ */
+typedef FILE * tpFILE;
+
+/*
+ * kernel data types
+ */
+typedef SEM_ID tSEMAPHORE; /* semaphore */
+typedef SEM_ID tCSEMAPHORE; /* counting semaphore */
+typedef SEM_ID tBSEMAPHORE; /* binary semaphore */
+typedef SEM_ID tMSEMAPHORE; /* mutex semaphore */
+
+/*
+ * missing from vxWorks' Posix types
+ */
+typedef long long int64_t;
+typedef unsigned long long uint64_t;
+
+/*
+ * Cisco IOS compatibility
+ */
+typedef long long longlong;
+typedef unsigned int uint;
+typedef unsigned char uchar;
+typedef unsigned long ulong;
+typedef unsigned long long ulonglong;
+typedef unsigned long long sys_timestamp;
+
+/*
+ * Special values for data types
+ */
+#ifndef NULLP
+#define NULLP ((void *) 0)
+#endif
+
+#ifndef TRUE
+#define TRUE 1
+#endif
+
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+
+/*
+ * copied from dosfs/uvfatTypes.h
+ */
+
+typedef uid_t tUID;
+typedef gid_t tGID;
+typedef tOCTET2 tMODE;
+typedef unsigned long tDIRNUM, *tpDIRNUM;
+typedef tOCTET4 tCOMPATDWORD;
+
+
+#define INVALID_UID ((unsigned short)-1)
+#define INVALID_GID ((unsigned short)-1)
+#define INVALID_MODE -1
+#define INVALID_DIRNUM -1L
+#define INVALID_FLAGS -1L
+
+#define INIT_DIRNUM 0
+#define ROOTDIR_DIRNUM 1
+
+typedef tOCTET2 tACCESS;
+
+#define setuid setUid
+#define getuid getUid
+
+
+
+
+/*
+** vxWorks mutex semphore default flag
+*/
+#define PS_DEFAULT_MUTEX_SEM_FLAG \
+ (SEM_Q_PRIORITY | SEM_DELETE_SAFE | SEM_INVERSION_SAFE)
+#define PS_DEFAULT_BINARY_SEM_FLAG (SEM_Q_PRIORITY)
+#define PS_DEFAULT_COUNT_SEM_FLAG (SEM_Q_PRIORITY)
+#define PS_DEFAULT_BINARY_SEM_STAT (SEM_FULL)
+#define PS_DEFAULT_COUNT_SEM_COUNT 1
+
+#endif /* __CLI_PRIVATE_H_ */
diff --git a/data/mnet/Common/cli/include/config.h b/data/mnet/Common/cli/include/config.h
new file mode 100644
index 0000000..022e3ea
--- /dev/null
+++ b/data/mnet/Common/cli/include/config.h
@@ -0,0 +1,389 @@
+#ifndef __CONFIG_H__
+#define __CONFIG_H__
+
+#define SABUFSIZE 3000 /* buffer size for config from term */
+#define TOKLEN 85 /* maximum token length */
+#define WORD 0 /* gettoken should return a word */
+#define LINE 1 /* gettoken should return a line */
+
+
+/*
+ * flags used in csb->flags
+ */
+#define CONFIG_TERM 0x00000001 /* configuring from a terminal */
+#define CONFIG_ABORT 0x00000002 /* need to abort the config */
+#define CONFIG_DONE 0x00000004 /* config is done */
+#define CONFIG_HTTP 0x00000008 /* configuring from http */
+#define KEYWORD_MATCHED 0x00000010 /* keyword was matched */
+#define COMMAND_AUTHORIZE 0x00000020 /* expand command into nv_command */
+#define COMMAND_FUNCTION 0x00000040 /* substitute function on accept */
+#define HIDE_PASSWORDS 0x00000080 /* Don't print password during nvgen */
+#define PARSE_EMPTY_STRING 0x00000100 /* Try to parse empty string */
+#define CONFIG_PER_USER 0x00000200 /* Per-user configuration */
+#define CONFIG_CGI 0x00000400 /* configuring from http */
+#define COMMAND_COMPLETE 0x00000800 /* Indicate to I/O so it can do History */
+#define CONFIG_FILE 0x00001000 /* Copy Startup to Disk */
+#define TERMINAL_MODE 0x00002000 /* Indicate to Callback to leave at
+ * Terminal Mode */
+
+#define NOMEANSZERO 1 /* if "no", assume number 0 */
+#define NONULL 2 /* null args not allowed */
+#define NOMEANSMINUS 3 /* if "no", assume number -1 */
+#define NOMEANSNULL 4 /* if "no", assume null string */
+#define NULLMEANSDONE 5 /* if NULL, quiet error return */
+
+
+/*
+ * Methods for resolving protocol addresses and configuration information.
+ * Note that this list has grown to be used for lots more than resolving
+ * protocol addresses, however.
+ */
+enum RES {
+ RES_NULL, /* Not resolved */
+ RES_CONFIG, /* Configuration file */
+ RES_MANUAL, /* Manually set */
+ RES_NONVOL, /* Read from non-volatile RAM */
+ RES_PRIVATE_NONVOL, /* Read from private non-volatile RAM */
+ RES_WRITING_NONVOL /* Writing to non-volatile RAM */
+};
+
+
+
+/*
+ * RAMS : this was under ifdef of IOS_PARSER
+ */
+
+/*
+ * A list of file access methods.
+ * The bootstrap monitor knows about the TFTP, MOP, and FLASH codes,
+ * so don't change their values.
+ */
+typedef enum {
+ FILE_ACCESS_UNKNOWN = 0,
+ FILE_ACCESS_TFTP = 1,
+ FILE_ACCESS_FLASH = 3,
+ FILE_ACCESS_ROM = 4,
+ FILE_ACCESS_RCP = 5,
+ FILE_ACCESS_FTP = 8,
+} file_access_protocol;
+
+
+/*
+ * now define a generic named thing.
+ */
+typedef struct namedthingtype_ {
+ struct namedthingtype_ *next;
+ NAMEDTHINGMACRO
+ uchar data[1];
+} namedthingtype;
+
+/*
+ * RAMS : ifdef ended here
+ */
+
+
+
+
+
+
+/************************************************************************/
+/*********** START OF NEW PARSER STRUCTURE ******************************/
+/************************************************************************/
+
+
+#define PARSEBUF 256 /* Input buffer length */
+#define MAXTOKLEN 21 /* Maximum token length */
+#define MAXPROMPTLEN 30 /* Maximum prompt; prompt truncated to fit */
+
+/* Structure for saving blocks of character strings like comments,
+ * help output, and NV generation.
+ */
+typedef struct save_buf_ {
+ char *buf; /* The buffer itself */
+ int size; /* Size of the malloc'ed buffer area */
+ int used; /* Number of characters stored in the buffer */
+} save_buf;
+
+/*
+ *
+ */
+typedef struct ambig_struct_ {
+ char ambig[PARSEBUF];
+ char ambig_save[PARSEBUF];
+ int multiple_funcs;
+} ambig_struct;
+
+/* The 'transition' struct is the central data structure of the parser.
+ * A parse tree is built of transition nodes, each of which references
+ * an action routine (func() in the structure). The action routine
+ * will transition to the 'accept' node if the input was matched (or
+ * some other action was successful). The 'alternate' transition is taken
+ * if the action failed, and after the accepting node returns (recursion
+ * is currently used to transition between nodes). The 'args' variable
+ * may be used to pass additional parameters to the action routine. It is
+ * generally defined as one of several types of structures to allow passing
+ * multiple parameters.
+ *
+ * The parse_token() function handles transitioning between nodes.
+ */
+
+typedef void (*trans_func)(parseinfo *, transition *, const void * const);
+struct transition_ {
+ transition *accept;
+ transition *alternate;
+ const trans_func func;
+ const void * const args;
+};
+
+/*
+ * Dynamic transitions used for adding parse chains at run time
+ */
+typedef struct dynamic_transition_ dynamic_transition;
+struct dynamic_transition_ {
+ dynamic_transition *accept;
+ dynamic_transition *alternate;
+ const trans_func func;
+ const void *args;
+};
+
+typedef void (*command_func)(parseinfo *);
+
+/* The parseinfo struct is used by the parser routines for
+ * parameter storage between the parser and command action routines.
+ * The parser and action functions must agree as to where
+ * values are stored in this struct. Generally, this is
+ * in order in which the values appear in the input stream.
+ *
+ * Parser internal state info is also kept here.
+ */
+
+
+struct parseinfo_ {
+
+/*** Start of cleared area ***/
+
+/*** Note that csb_start_data is defined as txt1 below! ***/
+
+ /* Variable storage for parsed data being passed to functions */
+ char txt1[PARSEBUF], txt2[PARSEBUF], txt3[PARSEBUF]; /* String data */
+ char txt4[PARSEBUF], txt5[PARSEBUF], txt6[PARSEBUF]; /* String data */
+ char txt7[PARSEBUF], txt8[PARSEBUF]/*, txt9[PARSEBUF]*/; /* String data */
+
+ uint val1, val2, val3, val4, val5; /* Integer values */
+ uint val6, val7, val8, val9, val10;
+ uint val11, val12, val13, val14, val15;
+
+ addrtype addr1, addr2, addr3, addr4, addr5, addr6, addr7, addr8;
+
+ int interface;
+
+ void *vptr0, *vptr1;
+
+ void *udb1,*udb2;
+
+ boolean leave_subcommand;
+
+ parser_mode *pmp;
+
+ uint end_of_data; /* Dummy to mark end of data area */
+
+/*** End of cleared area ***/
+
+ /* The below two variables are used in determining the command action
+ * routine to execute.
+ * 'which' is the command type code passed in the EOL structure and is
+ * used by the called function to switch out to the command action routine.
+ * An example is CMD_CLEAR, which causes the clear_command() function to
+ * be called.
+ * 'func' is a function code which determines which of several command
+ * functions was requested. An example is CLEAR_VINES_ROUTE which is
+ * used by the clear_command() function to decide which action to take.
+ */
+
+ uint which; /* Which command type being executed */
+ uint func; /* Command function being executed */
+
+ boolean sense; /* FALSE if we parsed a 'no' prefix. Also
+ * FALSE if a 'default' prefix parsed
+ * because the off state is the default
+ * for most commands.
+ */
+
+ boolean set_to_default; /* TRUE if we parsed a 'default'
+ * prefix
+ */
+
+ int resolvemethod; /* Config source: term, mem, or net */
+ uint flags; /* misc flags */
+
+
+ char *batch_buf; /* Batch input buffer. NULL pointer if
+ * no batch buffer.
+ */
+
+ char *batch_offset; /* Current offset into batch buffer */
+
+ /* NV generation variables */
+ boolean nvgen; /* We're doing NV generation */
+ char nv_command[PARSEBUF]; /* The command being generated */
+
+ /* Structures for saving comments, help output, and NV generation */
+ save_buf comment_save, help_save;
+ int saved_help_used; /* How many bytes of help we've seen */
+
+ /* Parser internal state info */
+
+ /* The number of commands which matched the input stream,
+ * the function to call if only one matched, and a pointer to any
+ * additional parseinfo structures we created.
+ */
+ queuetype *tokenQ; /* Token processing queue. This is a
+ * push-down queue. The top of the
+ * stack is the next element to
+ * process.
+ */
+ ambig_struct visible_ambig;
+ ambig_struct hidden_ambig;
+
+ boolean command_visible; /* TRUE if current keyword is visible */
+ boolean unsupported; /* TRUE if current keyword is unsupported */
+
+ void (* action_func)(parseinfo *); /* Command function to call */
+ struct parseinfo_ *next; /* Next structure, or NULL */
+
+ int in_help; /* We're processing a help request */
+
+ uchar priv_set; /* If non-zero, then set keywords to
+ * this privilege level.
+ */
+
+ uchar priv; /* User's current privilege level */
+ uchar highest_priv; /* Highest keyword priv level parsed */
+ uchar last_priv; /* Privilege level of last keyword */
+ queuetype *privQ; /* stack of transitions that will have
+ * their privilege level changed */
+
+ queuetype *priv_nvgenQ; /* stack for doing NV generation */
+
+ int exit_all; /* Exit flag */
+
+ char prompt[MAXPROMPTLEN+1]; /* Command line prompt */
+ char line_buffer[PARSEBUF]; /* String being consumed */
+
+ char *line; /* Pointer to string being consumed */
+ int line_index; /* Current token ptr into line */
+ int error_index; /* Position of error in input line */
+ char *break_chars; /* Texti break character set */
+ char lastchar; /* last char read by readline() */
+ parser_mode *mode; /* Current parser mode */
+ command_func command_function; /* Substitute function on accept */
+
+ /* Microweb Specific Additions */
+ ushort MoreStatus; /* Who does 'more' etc. ? */
+ SEM_ID configSemId; /* Semaphore to hold for configuration */
+ boolean giveConfigSem; /* Easy access to release configuration
+ semaphore */
+
+ int inFd; /* Input 'fd' */
+ int outFd; /* Output 'fd' */
+ int savedFd; /* saved outFd when output is redirected */
+ void *pIndex; /* Used for 'more' kind of processing,
+ cookie */
+ long maxRecordCount; /* Used for 'more'; Maximum record count */
+ int moduleId; /* Who owns this CSB ? */
+
+
+ int uid; /* UID of the I/O Module */
+
+ int ioTaskId; /* Task Id of the I/O Module */
+ timer_t io_timer; /* io input timeout */
+ boolean return_val; /* return value for command */
+ int errno_val; /* error value for command */
+ void *userDataBlock[2];
+ /* struct parser_session *session; parser session, if one exists */
+
+};
+
+/* Start and end of variable area (for clearing purposes) */
+
+#define csb_start_data txt1 /* First address to clear */
+#define csb_end_data end_of_data /* Last address + 1 to clear */
+
+#define PFLAG_in_help in_help /* Help flag */
+#define PFLAG_nvgen nvgen /* NV gen flag */
+#define PFLAG_sense sense /* sense flag */
+#define PFLAG_which which /* which flag */
+
+#define PTXT_0 nv_command
+#define PTXT_1 txt1
+#define PTXT_2 txt2
+#define PTXT_3 txt3
+#define PTXT_4 txt4
+#define PTXT_5 txt5
+#define PTXT_6 txt6
+#define PTXT_7 txt7
+#define PTXT_8 txt8
+#define PTXT_9 txt9
+#define PTXT_prompt prompt
+#define PTXT_line line
+#define PTXT_break_chars break_chars
+
+#define PVPTR_0 vptr0
+#define PVPTR_1 vptr1
+
+
+#define PCHAR_lastchar lastchar
+
+#define PTYPE_int(num) val ## num /* Integer */
+#define PTYPE_char(num) PCHAR ## num
+#define PTYPE_string(num) PTXT_ ## num /* String */
+#define PTYPE_paddr(num) addr ## num /* Protocol address ptr */
+#define PTYPE_hwaddr(num) hwaddr ## num /* Hardware address ptr */
+#define PTYPE_maskedAddr(num) maskedAddr ## num /* masked address ptr */
+#define PTYPE_flag(num) PFLAG_ ## num /* Parser flags */
+#define PTYPE_vptr(num) PVPTR_ ## num /* Parser void* */
+#define PUDB_current1 userDataBlock[0]
+#define PUDB_current2 userDataBlock[1]
+#define PUDB_1 udb1
+#define PUDB_2 udb2
+#define PTYPE_udb(num) PUDB_ ## num /* User Defined data block ptr */
+
+
+#define PPTR_int
+#define PPTR_string
+#define PPTR_paddr &
+#define PPTR_hwaddr &
+#define PPTR_maskedAddr &
+#define PPTR_flag
+#define PPTR_vptr
+#define PPTR_udb
+
+#define GETOBJ(type,num) (PPTR_ ## type ## (csb->PTYPE_ ## type ## ( ## num ## )))
+#define SETOBJ(type,num) csb->PTYPE_ ## type ## ( ## num ## )
+#define ISOBJ(type,num) ((int) GETOBJ(type,num) != 0)
+
+/************************************************************************/
+/*********** END OF NEW PARSER STRUCTURE ********************************/
+/************************************************************************/
+
+/***********************************************************************
+ *
+ * Externs and Prototypes
+ *
+ ***********************************************************************/
+
+/*
+ * parser.c
+ */
+typedef boolean (*match_gen_func)(parseinfo *, char *, int *, void *,
+ int, uint, void *);
+typedef char * (*short_help_func)(parseinfo *, uint, void *);
+
+extern void parser_add_address(const uint, short_help_func, match_gen_func);
+extern void exit_config_submode(parseinfo *);
+extern void exit_config_modes(parseinfo *);
+extern void parse_configure (char *, int , int , uchar );
+extern void wait_for_system_load( void );
+extern boolean yes_or_no(const char *prompt, boolean def, boolean usedef);
+#endif __CONFIG_H__
+
diff --git a/data/mnet/Common/cli/include/debug.h b/data/mnet/Common/cli/include/debug.h
new file mode 100644
index 0000000..51e4229
--- /dev/null
+++ b/data/mnet/Common/cli/include/debug.h
@@ -0,0 +1,70 @@
+#ifndef __DEBUG_H__
+#define __DEBUG_H__
+
+
+
+#define MIN_DEBUG_LEVEL 1
+#define MAX_DEBUG_LEVEL 5
+
+/*
+ * debug_item_type defines a standard way of describing a debugging
+ * flag. Most protocols keep their debugging flags in special
+ * cells, which are pointed to by the members of arrays of entries
+ * of this type. The generic debugging support provides a few routines
+ * for dealing with such arrays. By convention, the end of an array
+ * is flagged by a null flag pointer.
+ */
+typedef struct debug_item_type_ {
+ boolean *var; /* Address of on/off flag */
+ char *txt; /* Descriptive text about what to debug */
+} debug_item_type;
+
+/* Initialize the debugging system */
+extern void debug_init(void);
+
+/*
+ * Determine whether "debug all" is in effect. When a new subsystem
+ * is initialized, it uses this routine to determine whether it should
+ * immediately turn on its debugging flags or not.
+ */
+extern boolean debug_all_p(void);
+
+/*
+ * Generic routine for "debug" parse chains to call. Only useful if you're
+ * using totally stock flags and arrays.
+ */
+extern void debug_command(parseinfo *csb);
+
+/* Routine to handle "debug all" and "undebug all" */
+extern void debug_all_cmd(parseinfo *csb);
+
+/* Routine that implements the "show debug" command */
+extern void show_debug(void);
+
+/*
+ * Display the value of a debugging flag in the common format used for
+ * all such flags.
+ */
+extern void debug_show_flag(boolean flag, char *text);
+
+/*
+ * Show a whole array of flags. The end of the array is marked by an
+ * entry with a null flag pointer.
+ */
+extern void debug_show_flags(const debug_item_type *array, const char *heading,
+ boolean printLevel );
+
+/*
+ * generic routine to call when anybody issues
+ * a "debug all" or "undebug all" command or
+ * whenever you want to set the state of all
+ * debug flags at once.
+ */
+
+extern void generic_debug_all (const debug_item_type *, boolean );
+extern void generic_debug_show (const debug_item_type *, const char* );
+extern STATUS generic_debug_init (const debug_item_type *, const char* );
+
+extern void debug_init( void );
+
+#endif __DEBUG_H__
diff --git a/data/mnet/Common/cli/include/debug_macros.h b/data/mnet/Common/cli/include/debug_macros.h
new file mode 100644
index 0000000..76a3dc7
--- /dev/null
+++ b/data/mnet/Common/cli/include/debug_macros.h
@@ -0,0 +1,70 @@
+
+
+/* This perverted abuse of the C preprocessor is designed to keep us from
+ * having to keep too many files consistent to make debugging DEBUG_FLAGs work.
+ * To make a standard debugging DEBUG_FLAG, we have to create 3 things:
+ *
+ * o A boolean flag variable (tested by the routines that print the actual
+ * debugging output)
+ *
+ * o An array element that associates that variable with a textual
+ * description (used by the parsing and printing routines to talk about
+ * the flag)
+ *
+ * o A symbolic name for the array index (used by parse chains to designate
+ * which flag is to be set or cleared within an array).
+ *
+ * Rather than ask a human being to type in all three definitions, we use
+ * the macros below and some include file hackery to create them all from
+ * the same data. If the magic symbol "__DECLARE_DEBUG_ARR__" is defined,
+ * we assume that whatever file includes us wants to actually declare
+ * initialized data... presumably we've been included by an xxx_debug.c
+ * module. If "__DECLARE_DEBUG_NUMS__" is defined instead, we assume
+ * that an include file wants to create the symbolic names for array
+ * offsets. If neither magic symbol is defined, we assume that an include
+ * file (probably the same one) wants to create external declarations
+ * for the booleans themselves, as well as an external declaration for
+ * the array.
+ *
+ * There are some instances in which a debug flag is defined that should
+ * not be declared by us; in such cases the DEBUG_FLAG_NO_DECL macro
+ * should be used, rather than the DEBUG_FLAG macro.
+ */
+
+/* We've probably been called before, so let's clean up what we did then */
+#undef DEBUG_ARRDECL
+#undef DEBUG_FLAG
+#undef DEBUG_ARRDONE
+#undef DEBUG_FLAG_NO_DECL
+
+#if defined(__DECLARE_DEBUG_ARR__)
+
+#define DEBUG_ARRDECL(arrname) const debug_item_type arrname[] = {
+#define DEBUG_FLAG(varname,codename,textname) {&varname, textname},
+#define DEBUG_FLAG_NO_DECL(varname,codename,textname) {&varname, textname},
+#define DEBUG_ARRDONE {(boolean *) NULL, (char *) NULL} };
+
+#elif defined(__DECLARE_DEBUG_NUMS__)
+
+#define DEBUG_ARRDECL(arrname) enum {
+#define DEBUG_FLAG(varname,codename,textname) codename,
+#define DEBUG_FLAG_NO_DECL(varname,codename,textname) codename,
+#define DEBUG_ARRDONE };
+
+#else
+
+#define DEBUG_ARRDECL(arrname) extern const debug_item_type arrname[];
+#if defined(__DECLARE_DEBUG_VARS__)
+#define DEBUG_FLAG(varname,codename,textname) boolean varname;
+#else
+#define DEBUG_FLAG(varname,codename,textname) extern boolean varname;
+#endif
+#define DEBUG_FLAG_NO_DECL(varname,codename,textname) /* Nothing */
+#define DEBUG_ARRDONE /* Nothing */
+
+#endif
+
+/* Some other include file might want to reuse us... */
+#undef __DECLARE_DEBUG_VARS__
+#undef __DECLARE_DEBUG_ARR__
+#undef __DECLARE_DEBUG_NUMS__
diff --git a/data/mnet/Common/cli/include/defs.h b/data/mnet/Common/cli/include/defs.h
new file mode 100644
index 0000000..aa88fc8
--- /dev/null
+++ b/data/mnet/Common/cli/include/defs.h
@@ -0,0 +1,127 @@
+#ifndef _PARSER_DEFS_H
+#define _PARSER_DEFS_H
+
+#ifdef NONE
+#undef NONE
+#endif
+
+#define pname(x) PARSER_ ## x
+#define pdecl(x) extern transition pname(x)
+#define lpdecl(x) extern dynamic_transition pname(x);
+
+#define CSBOFF(elem) ((int) &((parseinfo*)NULL)->elem)
+#define CSBVAR(csb, offset, type) ((type *) ((u_char*) csb + offset))
+
+extern transition PARSER_NONE;
+
+pdecl(no_alt);
+pdecl(link_point);
+pdecl(link_trans);
+
+/*
+ * List structure for parser extension
+ */
+typedef const struct {
+ uint type; /* Type code */
+ dynamic_transition *commands; /* Transition pointer */
+} parser_extension_request;
+
+/*
+ * Extending the parser.
+ * Some brave soul should turn this into an enum and rearrange things
+ * intelligently.
+ */
+enum {
+ PARSE_LIST_END=0, /* End of list - not a real code */
+ PARSE_ADD_EXEC_CMD,
+ PARSE_ADD_SHOW_CMD,
+ PARSE_ADD_CLEAR_CMD,
+ PARSE_ADD_DEBUG_CMD,
+ PARSE_ADD_TERM_CMD, /* "term xxx" commands, not saved */
+ PARSE_ADD_CFG_TOP_CMD, /* top level config commands */
+ PARSE_ADD_GLOBAL_CMD, /* global commands */
+ PARSE_ADD_PING_CMD, /* exec ping commands */
+ PARSE_ADD_COPY_CMD, /* copy commands */
+ PARSE_ADD_COPYFILE_CMD, /* copy file commands */
+ PARSE_ADD_CFG_LAST_CMD, /* top level config commands at end */
+ PARSE_ADD_CFG_CDP, /* Cisco Discovery Protocol */
+ PARSE_ADD_WRITE_CMD, /* to add dynamic write commands */
+ PARSE_ADD_CFG_FILE_CMD, /* to add config file command */
+ PARSE_ADD_COPY_RUNNING_CMD, /* extending copy running-config */
+ PARSE_ADD_COPY_STARTUP_CMD, /* extending copy startup-config */
+ PARSE_ADD_COPY_FLASH_CMD, /* extending copy flash */
+ PARSE_ADD_COPY_DISK_CMD, /* extending copy disk cmd */
+ PARSE_ADD_COPY_TFTP_CMD, /* extending copy tftp cmd */
+ PARSE_ADD_COPY_RUNNING_FILE_CMD, /* extending copy running-config */
+ PARSE_ADD_COPY_STARTUP_FILE_CMD, /* extending copy startup-config */
+ PARSE_ADD_COPY_FLASH_FILE_CMD, /* extending copy flash */
+ PARSE_ADD_COPY_RCP_FILE_CMD, /* extending copy rcp */
+ PARSE_ADD_COPY_TFTP_FILE_CMD, /* extending copy tftp cmd */
+ PARSE_ADD_ERASE_CMD, /* to add erase file cmd */
+ PARSE_ADD_CFG_LOG_CMD, /* syslog history config cmd */
+ PARSE_ADD_SHOW_LOG_CMD, /* syslog history show cmd */
+ PARSE_ADD_GLOBAL_EXIT, /* Global command exit */
+ PARSE_ADD_SHOW_TECHSUPPORT_CMD, /* show tech-support commands */
+ PARSE_ADD_SHOW_TECHSUPPORT_EXIT, /* show tech-support exit */
+ PARSE_ADD_SHOW_REV_CMD, /* show revision commands */
+ PARSE_ADD_CFG_INTERFACE_TOP_CMD, /* Config Interface commands */
+ PARSE_ADD_CFG_CELL_CMD, /* config cell mode commands */
+ PARSE_ADD_CFG_ADJCELL_CMD, /* config adjacent cell mode commands */
+ PARSE_ADD_CFG_PROTO_CMD, /* config protocol mode commands */
+ PARSE_ADD_SHOW_STATS_CMD, /* show statistics */
+ PARSE_ADD_CLEAR_STATS_CMD, /* clear statistics */
+ PARSE_ADD_CFG_DNS_BOOM_CLIENT_TOP_CMD,/* Config dns-boomerang client cmds */
+ PARSE_ADD_CFG_DNS_BOOM_SERVER_TOP_CMD,/* Config dns-boomerang server cmds */
+ PARSE_ADD_CFG_GP10_CELL,
+ PARSE_ADD_CFG_GP10_ADJCELL,
+ PARSE_ADD_CFG_GP10_PROTO,
+ PARSE_ADD_CFG_GP10_CELL_TRX,
+ PARSE_ADD_CFG_GP10_CELL_BTS,
+ PARSE_ADD_CFG_GP10_CELL_CCCH,
+ PARSE_ADD_CFG_GMC_CAPS, /* Config GMC CAPS Paramaters */
+ PARSE_ADD_CFG_GMC_CCS, /* Config GMC CCS Paramaters */
+ PARSE_ADD_CFG_GMC_SYNAXIS, /* Config GMC SYNAXIS Paramaters */
+ PARSE_ADD_EXEC_SMSCB_SCHEDULE, /* Exec commands for SMS-CB Schedule Messages */
+ PARSE_ADD_EXEC_SMSCB_CHANGE, /* Exec commands for SMS-CB Change Messages */
+ PARSE_ADD_CFG_GMC_ITP, /* Config GMC ITP Paramaters */
+ PARSE_ADD_CFG_GMC_ITP_PATH /* Config GMC ITP Path Paramaters */
+
+};
+
+#ifdef PARSER_DEBUG_LINKS
+#define parser_add_commands(def, trans, str)\
+ parser_add_commands_func(def, trans, str)
+#define parser_add_command_list(list, str)\
+ parser_add_command_list_func(list, str)
+#define parser_add_link_point(def, str, trans)\
+ parser_add_link_point_func(def, str, trans)
+#define parser_add_link_exit(def, str, trans)\
+ parser_add_link_exit_func(def, str, trans)
+
+extern boolean parser_add_commands_func(uint, dynamic_transition *, const char *);
+extern boolean parser_add_command_list_func(parser_extension_request *,
+ const char *);
+extern boolean parser_add_link_point_func(uint, const char *, transition *);
+extern boolean parser_add_link_exit_func(uint, const char *, transition *);
+#else /* PARSER_DEBUG_LINKS */
+#define parser_add_commands(def, trans, str)\
+ parser_add_commands_func(def, trans)
+#define parser_add_command_list(list, str)\
+ parser_add_command_list_func(list)
+#define parser_add_link_point(def, str, trans)\
+ parser_add_link_point_func(def, trans)
+#define parser_add_link_exit(def, str, trans)\
+ parser_add_link_exit_func(def, trans)
+
+extern boolean parser_add_commands_func(uint, dynamic_transition *);
+extern boolean parser_add_command_list_func(parser_extension_request *);
+extern boolean parser_add_link_point_func(uint, transition *);
+extern boolean parser_add_link_exit_func(uint, transition *);
+#endif /* PARSER_DEBUG_LINKS */
+
+/*
+ * True during reading of the configuration from NVRAM
+ */
+extern boolean systemloading;
+
+#endif /* _PARSER_DEFS_H */
diff --git a/data/mnet/Common/cli/include/exec_clear.h b/data/mnet/Common/cli/include/exec_clear.h
new file mode 100644
index 0000000..f2c0d61
--- /dev/null
+++ b/data/mnet/Common/cli/include/exec_clear.h
@@ -0,0 +1,47 @@
+/* $Id: exec_clear.h,v 10.2 1999/02/12 03:19:54 sundars Exp $
+ * $Source: /export/sbcc/cepro/os/parser/src/exec_clear.h,v $
+ *------------------------------------------------------------------
+ * Cisco MicroWeb Server Version 2
+ *
+ * File: exec_clear.h
+ * Description: clear - Reset Functions
+ * Owner: Prasanna Parthasarathy
+ * Notes:
+ *
+ * Copyright (c) 1997 by cisco Systems, Inc.
+ * All rights reserved.
+ *------------------------------------------------------------------
+ * $Log: exec_clear.h,v $
+ * Revision 10.2 1999/02/12 03:19:54 sundars
+ * create a customer debug build; remove lots of junk printfs from
+ * customer builds;disable wccp when we suspend a task due to
+ * panic/exception etc.
+ * CSCdk92101: Make cli as the default on development
+ *
+ * Revision 10.1 1998/06/10 20:41:58 sutton
+ * code merge
+ *
+ * Revision 1.3 1997/12/05 18:17:43 pparthas
+ * Unhide the 'clear' command
+ * CSCdj39802: A command to clear serial interfaces
+ *
+ * Revision 1.2 1997/05/14 22:12:04 pparthas
+ * Removed test_* files. Included some files for Show routines
+ * and cleaned-up file structure ( not source code ;-) )
+ *
+ *------------------------------------------------------------------
+ * $Endlog$
+ */
+/******************************************************************/
+#ifdef MNET_GP10
+EOLNS (exec_clear_help_eol, clear_help_command);
+PRIV_TEST(exec_clear_help, exec_clear_help_eol, NONE,
+ exec_clear_commands, PRIV_CONF | PRIV_HIDDEN );
+
+KEYWORD (exec_clear, exec_clear_help, ALTERNATE,
+ "clear", "Reset functions", PRIV_CONF | PRIV_HIDDEN);
+
+#undef ALTERNATE
+#define ALTERNATE exec_clear
+
+#endif
diff --git a/data/mnet/Common/cli/include/exec_configure.h b/data/mnet/Common/cli/include/exec_configure.h
new file mode 100644
index 0000000..4f7f888
--- /dev/null
+++ b/data/mnet/Common/cli/include/exec_configure.h
@@ -0,0 +1,47 @@
+
+/* $Id: exec_configure.h,v 10.1 1998/06/10 20:41:59 sutton Exp $
+ * $Source: /export/sbcc/cepro/os/parser/src/exec_configure.h,v $
+ *------------------------------------------------------------------
+ * Cisco MicroWeb Server Version 2
+ *
+ * File: exec_configure.h
+ * Description: configure commands
+ * Owner: Prasanna Parthasarathy
+ * Notes:
+ *
+ * Copyright (c) 1997 by cisco Systems, Inc.
+ * All rights reserved.
+ *------------------------------------------------------------------
+ * $Log: exec_configure.h,v $
+ * Revision 10.1 1998/06/10 20:41:59 sutton
+ * code merge
+ *
+ * Revision 1.4 1997/10/11 00:51:07 pparthas
+ * Reverted to configure terminal , except that 'terminal' is now hidden
+ *
+ * Revision 1.3 1997/10/09 18:14:15 pparthas
+ * First Attempt to cleanup dead-code to reduce code-size; Included debug
+ * scheme in place
+ *
+ * Revision 1.2 1997/05/14 22:12:05 pparthas
+ * Removed test_* files. Included some files for Show routines
+ * and cleaned-up file structure ( not source code ;-) )
+ *
+ *------------------------------------------------------------------
+ * $Endlog$
+ */
+
+
+/*************************************************************n
+ * configure
+ *
+ */
+
+EOLS (exec_config_term_eol, manual_configure, PARSER_CONF_TERM);
+KEYWORD (exec_config_term, exec_config_term_eol, exec_config_term_eol,
+ "terminal", "Configure from Terminal", PRIV_ROOT | PRIV_HIDDEN);
+KEYWORD (exec_configure, exec_config_term, ALTERNATE,
+ "configure", "Enter configuration mode", PRIV_ROOT);
+
+#undef ALTERNATE
+#define ALTERNATE exec_configure
diff --git a/data/mnet/Common/cli/include/exec_debug.h b/data/mnet/Common/cli/include/exec_debug.h
new file mode 100644
index 0000000..606a2c9
--- /dev/null
+++ b/data/mnet/Common/cli/include/exec_debug.h
@@ -0,0 +1,46 @@
+/* $Id: exec_debug.h,v 10.1 1998/06/10 20:42:01 sutton Exp $
+ * $Source: /export/sbcc/cepro/os/parser/src/exec_debug.h,v $
+ *------------------------------------------------------------------
+ * Cisco MicroWeb Server Version 2
+ *
+ * File: exec_debug.h
+ * Description: debug command support
+ * Owner: Prasanna Parthasarathy
+ * Notes:
+ *
+ * Copyright (c) 1997 by cisco Systems, Inc.
+ * All rights reserved.
+ *------------------------------------------------------------------
+ * $Log: exec_debug.h,v $
+ * Revision 10.1 1998/06/10 20:42:01 sutton
+ * code merge
+ *
+ * Revision 1.3 1998/04/21 01:26:41 pparthas
+ * CLI Related changes / Undo log / Errno propagation
+ * CSCdj68847: CLI changes
+ *
+ * Revision 1.2 1997/05/14 22:12:06 pparthas
+ * Removed test_* files. Included some files for Show routines
+ * and cleaned-up file structure ( not source code ;-) )
+ *
+ *------------------------------------------------------------------
+ * $Endlog$
+ */
+
+EOLNS (exec_debug_help_eol, debug_help_command);
+PRIV_TEST(exec_debug_help, exec_debug_help_eol, NONE,
+ exec_debug_commands, PRIV_USER | PRIV_HIDDEN);
+
+KEYWORD_ID(exec_debug_false, exec_debug_help, no_alt,
+ sense, FALSE,
+ "debug", "Disable debugging functions",
+ PRIV_OPR);
+KEYWORD (exec_debug_no, exec_debug_false, ALTERNATE,
+ "no", "Disable debugging functions", PRIV_OPR);
+
+KEYWORD_ID(exec_debug_true, exec_debug_help, exec_debug_no,
+ sense, TRUE,
+ "debug", "Debugging functions", PRIV_OPR);
+
+#undef ALTERNATE
+#define ALTERNATE exec_debug_true
diff --git a/data/mnet/Common/cli/include/exec_debug_all.h b/data/mnet/Common/cli/include/exec_debug_all.h
new file mode 100644
index 0000000..4d78558
--- /dev/null
+++ b/data/mnet/Common/cli/include/exec_debug_all.h
@@ -0,0 +1,41 @@
+/* $Id: exec_debug_all.h,v 10.1 1998/06/10 20:42:02 sutton Exp $
+ * $Source: /export/sbcc/cepro/os/parser/src/exec_debug_all.h,v $
+ *------------------------------------------------------------------
+ * Cisco MicroWeb Server Version 2
+ *
+ * File: exec_debug_all.h
+ * Description: debug all command support
+ * Owner: Prasanna Parthasarathy
+ * Notes:
+ *
+ * Copyright (c) 1997 by cisco Systems, Inc.
+ * All rights reserved.
+ *------------------------------------------------------------------
+ * $Log: exec_debug_all.h,v $
+ * Revision 10.1 1998/06/10 20:42:02 sutton
+ * code merge
+ *
+ * Revision 1.3 1998/04/03 21:21:59 pparthas
+ * Changed EOLS macro to EOLI macro
+ * CSCdj89287: make the CLI callable from TCL
+ *
+ * Revision 1.2 1997/05/14 22:12:07 pparthas
+ * Removed test_* files. Included some files for Show routines
+ * and cleaned-up file structure ( not source code ;-) )
+ *
+ *------------------------------------------------------------------
+ * $Endlog$
+ */
+/******************************************************************
+ * debug all
+ *
+
+EOLI (debug_all_eol, debug_all_cmd, 0);
+KEYWORD (debug_all, debug_all_eol, ALTERNATE,
+ "all", "Enable all debugging", PRIV_OPR);
+
+
+#undef ALTERNATE
+#define ALTERNATE debug_all
+
+*/ \ No newline at end of file
diff --git a/data/mnet/Common/cli/include/exec_disable.h b/data/mnet/Common/cli/include/exec_disable.h
new file mode 100644
index 0000000..9ceb7cf
--- /dev/null
+++ b/data/mnet/Common/cli/include/exec_disable.h
@@ -0,0 +1,55 @@
+/* $Id: exec_disable.h,v 10.2 1999/03/18 01:23:08 sundars Exp $
+ * $Source: /export/sbcc/cepro/os/parser/src/exec_disable.h,v $
+ *------------------------------------------------------------------
+ * Cisco MicroWeb Server Version 2
+ *
+ * File: exec_disable.h
+ * Description: disable command support
+ * Owner: Prasanna Parthasarathy
+ * Notes:
+ *
+ * Copyright (c) 1997 by cisco Systems, Inc.
+ * All rights reserved.
+ *------------------------------------------------------------------
+ * $Log: exec_disable.h,v $
+ * Revision 10.2 1999/03/18 01:23:08 sundars
+ * CSCdm02577: No Context sensitive help available for disable and enable
+ * CLI comma
+ *
+ * Revision 10.1 1998/06/10 20:42:02 sutton
+ * code merge
+ *
+ * Revision 1.6 1998/04/21 01:26:41 pparthas
+ * CLI Related changes / Undo log / Errno propagation
+ * CSCdj68847: CLI changes
+ *
+ * Revision 1.5 1998/03/18 04:34:53 sutton
+ * Initial release of CLI/TCL integration.
+ * Still missing -- sysconf commit, sysconf abort,
+ * and interrupt character processing.
+ * Also changed the output pager (More processing) to
+ * be much simpler and universal for all commands.
+ * CSCdj89287: make the CLI callable from TCL
+ *
+ * Revision 1.4 1997/10/09 18:14:17 pparthas
+ * First Attempt to cleanup dead-code to reduce code-size; Included debug
+ * scheme in place
+ *
+ * Revision 1.3 1997/09/27 04:30:57 pparthas
+ * Removed levels for 'disable' command
+ *
+ * Revision 1.2 1997/05/14 22:12:07 pparthas
+ * Removed test_* files. Included some files for Show routines
+ * and cleaned-up file structure ( not source code ;-) )
+ *
+ *------------------------------------------------------------------
+ * $Endlog$
+ */
+EOLI (exec_disable_endline, enable_command, CMD_DISABLE);
+KEYWORD_ID(exec_disable, exec_disable_endline, ALTERNATE,
+ OBJ(int,1), DEFAULT_PRIV,
+ "disable", "Turn off privileged commands",
+ PRIV_ROOT);
+
+#undef ALTERNATE
+#define ALTERNATE exec_disable
diff --git a/data/mnet/Common/cli/include/exec_enable.h b/data/mnet/Common/cli/include/exec_enable.h
new file mode 100644
index 0000000..b498b16
--- /dev/null
+++ b/data/mnet/Common/cli/include/exec_enable.h
@@ -0,0 +1,58 @@
+/* $Id: exec_enable.h,v 10.2 1999/03/18 01:23:09 sundars Exp $
+ * $Source: /export/sbcc/cepro/os/parser/src/exec_enable.h,v $
+ *------------------------------------------------------------------
+ * Cisco MicroWeb Server Version 2
+ *
+ * File: exec_enable.h
+ * Description: enable command
+ * Owner: Prasanna Parthasarathy
+ * Notes:
+ *
+ * Copyright (c) 1997 by cisco Systems, Inc.
+ * All rights reserved.
+ *------------------------------------------------------------------
+ * $Log: exec_enable.h,v $
+ * Revision 10.2 1999/03/18 01:23:09 sundars
+ * CSCdm02577: No Context sensitive help available for disable and enable
+ * CLI comma
+ *
+ * Revision 10.1 1998/06/10 20:42:03 sutton
+ * code merge
+ *
+ * Revision 1.6 1998/04/21 01:26:42 pparthas
+ * CLI Related changes / Undo log / Errno propagation
+ * CSCdj68847: CLI changes
+ *
+ * Revision 1.5 1998/03/18 04:34:53 sutton
+ * Initial release of CLI/TCL integration.
+ * Still missing -- sysconf commit, sysconf abort,
+ * and interrupt character processing.
+ * Also changed the output pager (More processing) to
+ * be much simpler and universal for all commands.
+ * CSCdj89287: make the CLI callable from TCL
+ *
+ * Revision 1.4 1997/10/09 18:14:17 pparthas
+ * First Attempt to cleanup dead-code to reduce code-size; Included debug
+ * scheme in place
+ *
+ * Revision 1.3 1997/08/16 04:52:53 pparthas
+ * For now, got rid of 'Privilege Levels' in 'enable' command
+ *
+ * Revision 1.2 1997/05/14 22:12:08 pparthas
+ * Removed test_* files. Included some files for Show routines
+ * and cleaned-up file structure ( not source code ;-) )
+ *
+ *------------------------------------------------------------------
+ * $Endlog$
+ */
+/****************************************************************
+ * enable
+ */
+EOLI (enable_endline, enable_command, CMD_ENABLE);
+KEYWORD_ID(enable, enable_endline, ALTERNATE,
+ OBJ(int,1), PRIV_MAX,
+ "enable", "Turn on privileged commands",
+ PRIV_MIN | PRIV_INTERACTIVE);
+
+#undef ALTERNATE
+#define ALTERNATE enable
diff --git a/data/mnet/Common/cli/include/exec_exit.h b/data/mnet/Common/cli/include/exec_exit.h
new file mode 100644
index 0000000..9aa900e
--- /dev/null
+++ b/data/mnet/Common/cli/include/exec_exit.h
@@ -0,0 +1,45 @@
+/* $Id: exec_exit.h,v 10.1 1998/06/10 20:42:04 sutton Exp $
+ * $Source: /export/sbcc/cepro/os/parser/src/exec_exit.h,v $
+ *------------------------------------------------------------------
+ * Cisco MicroWeb Server Version 2
+ *
+ * File: exec_exit.h
+ * Description: exit, quit - exit from the EXEC
+ * Owner: Prasanna Parthasarathy
+ * Notes:
+ *
+ * Copyright (c) 1997 by cisco Systems, Inc.
+ * All rights reserved.
+ *------------------------------------------------------------------
+ * $Log: exec_exit.h,v $
+ * Revision 10.1 1998/06/10 20:42:04 sutton
+ * code merge
+ *
+ * Revision 1.3 1998/03/18 04:34:54 sutton
+ * Initial release of CLI/TCL integration.
+ * Still missing -- sysconf commit, sysconf abort,
+ * and interrupt character processing.
+ * Also changed the output pager (More processing) to
+ * be much simpler and universal for all commands.
+ * CSCdj89287: make the CLI callable from TCL
+ *
+ * Revision 1.2 1997/05/14 22:12:09 pparthas
+ * Removed test_* files. Included some files for Show routines
+ * and cleaned-up file structure ( not source code ;-) )
+ *
+ *------------------------------------------------------------------
+ * $Endlog$
+ */
+/******************************************************************
+ * exit, quit - exit from the EXEC
+ */
+extern void Logout(parseinfo *csb);
+EOLI (exec_quit_eol, exit_exec_command, CMD_QUIT);
+EOLI (exec_exit_eol, Logout, CMD_EXIT);
+KEYWORD (exec_quit, exec_quit_eol, ALTERNATE,
+ "quit", "Exit from the EXEC", PRIV_MIN | PRIV_HIDDEN | PRIV_INTERACTIVE);
+KEYWORD (exec_exit, exec_exit_eol, exec_quit,
+ "exit", "Exit from the EXEC", PRIV_MIN | PRIV_INTERACTIVE);
+
+#undef ALTERNATE
+#define ALTERNATE exec_exit
diff --git a/data/mnet/Common/cli/include/exec_help.h b/data/mnet/Common/cli/include/exec_help.h
new file mode 100644
index 0000000..8226936
--- /dev/null
+++ b/data/mnet/Common/cli/include/exec_help.h
@@ -0,0 +1,44 @@
+/* $Id: exec_help.h,v 10.2 1998/12/30 18:13:02 sundars Exp $
+ * $Source: /export/sbcc/cepro/os/parser/src/exec_help.h,v $
+ *------------------------------------------------------------------
+ * Cisco MicroWeb Server Version 2
+ *
+ * File: exec_help.h
+ * Description: help command
+ * Owner: Prasanna Parthasarathy
+ * Notes:
+ *
+ * Copyright (c) 1997 by cisco Systems, Inc.
+ * All rights reserved.
+ *------------------------------------------------------------------
+ * $Log: exec_help.h,v $
+ * Revision 10.2 1998/12/30 18:13:02 sundars
+ * Fix help texts for CLI commands
+ * CSCdk69292: CLI Command Descriptions When Entering a ?-Part 2
+ *
+ * Revision 10.1 1998/06/10 20:42:04 sutton
+ * code merge
+ *
+ * Revision 1.3 1997/10/09 18:14:18 pparthas
+ * First Attempt to cleanup dead-code to reduce code-size; Included debug
+ * scheme in place
+ *
+ * Revision 1.2 1997/05/14 22:12:09 pparthas
+ * Removed test_* files. Included some files for Show routines
+ * and cleaned-up file structure ( not source code ;-) )
+ *
+ *------------------------------------------------------------------
+ * $Endlog$
+ */
+
+/******************************************************************
+ * help
+ */
+
+EOLNS (exec_help_eol, exec_help_command);
+KEYWORD (exec_help, exec_help_eol, ALTERNATE,
+ "help", "Assistance for command line interface",
+ PRIV_MIN );
+
+#undef ALTERNATE
+#define ALTERNATE exec_help
diff --git a/data/mnet/Common/cli/include/exec_show.h b/data/mnet/Common/cli/include/exec_show.h
new file mode 100644
index 0000000..6dbb727
--- /dev/null
+++ b/data/mnet/Common/cli/include/exec_show.h
@@ -0,0 +1,35 @@
+/* $Id: exec_show.h,v 10.1 1998/06/10 20:42:06 sutton Exp $
+ * $Source: /export/sbcc/cepro/os/parser/src/exec_show.h,v $
+ *------------------------------------------------------------------
+ * Cisco MicroWeb Server Version 2
+ *
+ * File: exec_show.h
+ * Description: show command
+ * Owner: Prasanna Parthasarathy
+ * Notes:
+ *
+ * Copyright (c) 1997 by cisco Systems, Inc.
+ * All rights reserved.
+ *------------------------------------------------------------------
+ * $Log: exec_show.h,v $
+ * Revision 10.1 1998/06/10 20:42:06 sutton
+ * code merge
+ *
+ * Revision 1.2 1997/05/14 22:12:10 pparthas
+ * Removed test_* files. Included some files for Show routines
+ * and cleaned-up file structure ( not source code ;-) )
+ *
+ *------------------------------------------------------------------
+ * $Endlog$
+ */
+
+/******************************************************************/
+EOLNS (exec_show_help_eol, show_help_command);
+PRIV_TEST(exec_show_help, no_alt, no_alt,
+ exec_show_commands, PRIV_MIN);
+
+KEYWORD (exec_show, exec_show_help, ALTERNATE,
+ "show", "Show running system information", PRIV_MIN);
+
+#undef ALTERNATE
+#define ALTERNATE exec_show
diff --git a/data/mnet/Common/cli/include/exec_undebug.h b/data/mnet/Common/cli/include/exec_undebug.h
new file mode 100644
index 0000000..623e37c
--- /dev/null
+++ b/data/mnet/Common/cli/include/exec_undebug.h
@@ -0,0 +1,33 @@
+/* $Id: exec_undebug.h,v 10.1 1998/06/10 20:42:17 sutton Exp $
+ * $Source: /export/sbcc/cepro/os/parser/src/exec_undebug.h,v $
+ *------------------------------------------------------------------
+ * Cisco MicroWeb Server Version 2
+ *
+ * File: exec_undebug.h
+ * Description: undebug command support
+ * Owner: Prasanna Parthasarathy
+ * Notes:
+ *
+ * Copyright (c) 1997 by cisco Systems, Inc.
+ * All rights reserved.
+ *------------------------------------------------------------------
+ * $Log: exec_undebug.h,v $
+ * Revision 10.1 1998/06/10 20:42:17 sutton
+ * code merge
+ *
+ * Revision 1.1 1998/04/21 01:57:17 pparthas
+ * CLI Changes
+ * CSCdj68847: CLI changes
+ *
+ *------------------------------------------------------------------
+ * $Endlog$
+ */
+
+/******************************************************************/
+KEYWORD_ID(exec_undebug, exec_debug_commands, ALTERNATE,
+ sense, FALSE,
+ "undebug", "Disable debugging functions (see also 'debug')",
+ PRIV_OPR);
+
+#undef ALTERNATE
+#define ALTERNATE exec_undebug
diff --git a/data/mnet/Common/cli/include/imc.h b/data/mnet/Common/cli/include/imc.h
new file mode 100644
index 0000000..ad6b5a0
--- /dev/null
+++ b/data/mnet/Common/cli/include/imc.h
@@ -0,0 +1,538 @@
+#ifndef _IMC_H_
+#define _IMC_H_
+
+/*
+===============================================================================
+
+ Modules have a request, indication, management queues that are anchored
+ in the IMC Queue Anchor.
+
+ IMC Q anchor block
+ ________
+ | |
+ | |------> MgmtQ
+ | |------> Expedited IndQ
+ | |------> Expedited ReqQ
+ | |------> ReqQ
+ | |------> IndQ
+ | |--|
+ |________| |
+ |
+ \|/ Next Module Anchor block
+
+===============================================================================
+*/
+
+#define MAX_IMC_COUNT 32
+
+
+
+struct imc_qanchor { /* IMC queue anchor */
+
+ NODE imc_element; /* List Element */
+ tSEMAPHORE semId; /* Couting Semaphore task is waiting on */
+ tUOCTET4 taskId; /* Task requesting IMC Services */
+ tOCTET4 workCount; /* Number of elements in Queues */
+ LIST pimc_mgmt; /* Management request queue */
+ LIST pimc_exp_ind; /* Expedited Indication queue */
+ LIST pimc_exp_req; /* Expedited request queue */
+ LIST pimc_ind; /* Normal Indication queue */
+ LIST pimc_req; /* Normal request queue */
+} ;
+
+typedef struct imc_qanchor tIMC_QANCHOR, *tpIMC_QANCHOR;
+
+/*
+ * Global Count Macro
+*/
+
+#define INCREMENT 1
+#define DECREMENT 2
+
+
+typedef enum IMC_QUEUE_TYPE {
+ MGMT_QUEUE = 0,
+ NREQ_QUEUE,
+ EREQ_QUEUE,
+ NIND_QUEUE,
+ EIND_QUEUE
+} IMC_QUEUE_TYPE;
+
+
+/* Convenience macro for mid queues */
+/* Use with caution by checking for NULL */
+
+#define mMID2Q(mid) pimcglp[(mid)]
+#define mMID2MGMT(mid) (&(mMID2Q((mid))->pimc_mgmt))
+#define mMID2EREQ(mid) (&(mMID2Q((mid))->pimc_exp_req))
+#define mMID2NREQ(mid) (&(mMID2Q((mid))->pimc_req))
+#define mMID2EIND(mid) (&(mMID2Q((mid))->pimc_exp_ind))
+#define mMID2NIND(mid) (&(mMID2Q((mid))->pimc_ind))
+#define mMID2SEM(mid) (mMID2Q((mid))->semId)
+
+#ifdef USE_IMC_MACROS
+
+#define mCHANGEGLOBALCOUNT(action) \
+ {\
+ if ( action == INCREMENT ) \
+ ++imc_global_count; \
+ else if ( action == DECREMENT ) {\
+ --imc_global_count; \
+ if ( imc_global_count < 0 ) { \
+ PSpanic("mCHANGEGLOBALCOUNT: Negative Count\n"); \
+ }\
+ }\
+ else { \
+ trace_Msg("\n%s: ", taskName( taskIdSelf() ));\
+ trace_Msg("mCHANGEGLOBALCOUNT:Invalid Action\n"); \
+ } \
+ }
+
+#define mTAKEINDEXSEM(which, rc ) \
+ { \
+ if ( PSsemTake( freeIndexSemId,WAIT_FOREVER ) == ERROR) { \
+ PSpanic("Could not Take freeIndex Semaphore\n"); \
+ rc = RC_ERR; \
+ } else \
+ rc = RC_OK; \
+ }
+
+#define mGIVEINDEXSEM( which ) \
+ { \
+ if ( PSsemGive( freeIndexSemId) == ERROR) { \
+ PSpanic("Could not Give freeIndex Semaphore\n"); \
+ } \
+ }
+
+#define mCHECKMODULEIMC( which, mid,rc) \
+ { \
+ if (pimcglp[(mid)] == NULL ) { \
+ trace_Msg("NULL IMC Anchor for Destination %ld\n", \
+ mid ); \
+ rc = RC_ERR; \
+ } else \
+ rc = RC_OK; \
+ }
+
+
+
+/*
+ * POST service interaction macros
+ * Interaction post Failed if rc != RC_OK
+ * pComSim->destid is module id of destination
+ */
+
+#define mPOST_SIM_NREQ(pComSim, rc) \
+ { \
+ if ( PSsemTake( freeIndexSemId,WAIT_FOREVER ) == ERROR) { \
+ PSpanic("mPOST_SIM_NREQ:Could not get semaphore\n"); \
+ rc = RC_ERR; \
+ } \
+ else if (pimcglp[(pComSim)->destid] == NULL ) { \
+ trace_Msg("NULL IMC Anchor for Destination %ld", \
+ (pComSim)->destid ); \
+ rc = RC_ERR; \
+ } \
+ else if ( (rc=lstAdd((mMID2NREQ((pComSim)->destid)), \
+ &(pComSim)->simq)) == RC_OK ) { \
+ ++((pimcglp[(pComSim)->destid])->workCount); \
+ mCHANGEGLOBALCOUNT( INCREMENT ); \
+ if ( PSsemGive(mMID2SEM((pComSim)->destid)) == ERROR ) { \
+ PSpanic("mPOST_SIM_NREQ:Could not give Task semaphore\n"); \
+ rc = RC_ERR; \
+ } \
+ } \
+ if ( PSsemGive( freeIndexSemId ) == ERROR) { \
+ PSpanic("mPOST_SIM_NREQ:Could not give Index semaphore\n"); \
+ rc = RC_ERR; \
+ } \
+ }
+
+#define mPOST_SIM_MGMT(pComSim, rc) \
+ { \
+ if ( PSsemTake( freeIndexSemId,WAIT_FOREVER ) == ERROR) { \
+ PSpanic("mPOST_SIM_MGMT:Could not get semaphore\n"); \
+ rc = RC_ERR; \
+ } \
+ else if ( (pimcglp[(pComSim)->destid] == NULL ) ) { \
+ trace_Msg("%s: ", taskName( taskIdSelf() ));\
+ trace_Msg("NULL IMC Anchor for Destination %ld" \
+ ,(pComSim)->destid ); \
+ rc = RC_ERR; \
+ } \
+ else if ( (rc=lstAdd((mMID2MGMT((pComSim)->destid)), \
+ &(pComSim)->simq)) == RC_OK ) { \
+ mCHANGEGLOBALCOUNT( INCREMENT ); \
+ ++((pimcglp[(pComSim)->destid])->workCount); \
+ if ( PSsemGive( mMID2SEM((pComSim)->destid))== ERROR ) { \
+ PSpanic("mPOST_SIM_MGMT:Could not give Task semaphore\n"); \
+ rc = RC_ERR; \
+ } \
+ } \
+ if ( PSsemGive( freeIndexSemId ) == ERROR) { \
+ PSpanic("mPOST_SIM_MGMT:Could not give Index semaphore\n"); \
+ rc = RC_ERR; \
+ } \
+ }
+
+/* Post Normal Indication Failed if rc != RC_OK */
+#define mPOST_SIM_NIND(pComSim, rc) \
+ { \
+ if (PSsemTake( freeIndexSemId,WAIT_FOREVER ) == ERROR) { \
+ PSpanic("mPOST_SIM_NIND:Could not get semaphore\n"); \
+ rc = RC_ERR; \
+ } \
+ else if (pimcglp[(pComSim)->destid] == NULL ) { \
+ trace_Msg("%s: ", taskName( taskIdSelf() ));\
+ trace_Msg("NULL IMC Anchor for Destination %ld", \
+ (pComSim)->destid ); \
+ rc = RC_ERR; \
+ } \
+ else if ( (rc=lstAdd((mMID2NIND((pComSim)->destid)), \
+ &((pComSim)->simq))) == RC_OK ) { \
+ ++((pimcglp[(pComSim)->destid])->workCount); \
+ mCHANGEGLOBALCOUNT( INCREMENT ); \
+ if ( PSsemGive( mMID2SEM((pComSim)->destid)) == ERROR ) { \
+ PSpanic("mPOST_SIM_NIND:Could not give Task semaphore\n"); \
+ rc = RC_ERR; \
+ } \
+ } \
+ if ( PSsemGive( freeIndexSemId ) == ERROR) { \
+ PSpanic("mPOST_SIM_NIND:Could not give Index semaphore\n"); \
+ rc = RC_ERR; \
+ } \
+ }
+
+/* Post Expedited Request Failed if rc != RC_OK */
+#define mPOST_SIM_EREQ(pComSim, rc) \
+ { \
+ if ( PSsemTake( freeIndexSemId,WAIT_FOREVER ) == ERROR) { \
+ PSpanic("mPOST_SIM_EREQ:Could not get semaphore\n"); \
+ rc = RC_ERR; \
+ } \
+ else if ( (pimcglp[(pComSim)->destid] == NULL ) ) { \
+ trace_Msg("%s: ", taskName( taskIdSelf() ));\
+ trace_Msg("NULL IMC Anchor for Destination %ld", \
+ (pComSim)->destid ); \
+ rc = RC_ERR; \
+ } \
+ else if ( (rc=lstAdd(mMID2EREQ((pComSim)->destid), \
+ &(pComSim)->simq)) == RC_OK ) { \
+ mCHANGEGLOBALCOUNT( INCREMENT ); \
+ ++((pimcglp[(pComSim)->destid])->workCount); \
+ if ( PSsemGive( mMID2SEM((pComSim)->destid)) == ERROR ) { \
+ PSpanic("mPOST_SIM_EREQ:Could not give Task semaphore\n"); \
+ rc = RC_ERR; \
+ } \
+ } \
+ if ( PSsemGive( freeIndexSemId ) == ERROR) { \
+ PSpanic("mPOST_SIM_EREQ:Could not give semaphore\n"); \
+ rc = RC_ERR; \
+ } \
+ }
+
+/* Post Expedited Indication Failed if rc != RC_OK */
+#define mPOST_SIM_EIND(pComSim, rc) \
+ { \
+ if ( PSsemTake( freeIndexSemId,WAIT_FOREVER ) == ERROR) { \
+ PSpanic("mPOST_SIM_EIND:Could not get semaphore\n"); \
+ rc = RC_ERR; \
+ } \
+ else if (pimcglp[(pComSim)->destid] == NULL ) { \
+ trace_Msg("%s: ", taskName( taskIdSelf() ));\
+ trace_Msg("NULL IMC Anchor for Destination %ld", \
+ (pComSim)->destid ); \
+ rc = RC_ERR; \
+ } \
+ if ( (rc=lstAdd(mMID2EIND((pComSim)->destid), \
+ &(pComSim)->simq)) == RC_OK ) { \
+ mCHANGEGLOBALCOUNT( INCREMENT ); \
+ ++((pimcglp[(pComSim)->destid])->workCount); \
+ if ( PSsemGive( mMID2SEM((pComSim)->destid)) == ERROR ) { \
+ PSpanic("mPOST_SIM_EIND:Could not give semaphore\n"); \
+ rc = RC_ERR; \
+ } \
+ } \
+ if ( PSsemGive( freeIndexSemId ) == ERROR) { \
+ PSpanic("mPOST_SIM_EIND:Could not give semaphore\n"); \
+ rc = RC_ERR; \
+ } \
+ }
+
+/*
+ * GET Service interactions for a module, Indications first
+ */
+
+
+/* Call with pComSim == NULLP , mid == module id */
+/* get Management requests, expedited indications and requests first,
+ * then the normal indications and requests */
+
+/* Get Management work only */
+#define mGET_MGMT_WORK_SIM(pComSim, mid) \
+ { \
+ if (PSsemTake(freeIndexSemId, WAIT_FOREVER ) == ERROR) { \
+ PSpanic("mGET_MGMT_WORK_SIM:Could not get semaphore\n"); \
+ } \
+ else if (pimcglp[(mid)] == NULL) { \
+ trace_Msg("mGET_MGMT_WORK_SIM:NULL IMC Anchor for Module %ld", \
+ (tUOCTET4)mid); \
+ pComSim = NULL; \
+ } \
+ else if (mMID2Q(mid)->workCount > 0 ) { \
+ tOCTET2 count = lstCount(mMID2MGMT(mid)); \
+ if (count < 0 ) { \
+ PSpanic("mGET_MGMT_WORK_SIM:Could not get count\n"); \
+ } \
+ else if ( count > 0 ){ \
+ pComSim = (tpCOMSIM)lstGet(mMID2MGMT(mid)); \
+ if (pComSim == NULL) { \
+ PSpanic("mGET_MGMT_WORK_SIM:NULL Sim Dequeued\n"); \
+ } \
+ mCHANGEGLOBALCOUNT( DECREMENT ); \
+ --((pimcglp[mid])->workCount); \
+ } \
+ } \
+ else { \
+ pComSim = NULL; \
+ } \
+ if ( PSsemGive( freeIndexSemId ) == ERROR) { \
+ PSpanic("mGET_MGMT_WORK_SIM:Could not give semaphore\n"); \
+ } \
+ }
+
+
+/* Get Normal Indication work only */
+
+#define mGET_NIND_WORK_SIM(pComSim, mid) \
+ { \
+ if ( PSsemTake(freeIndexSemId,WAIT_FOREVER ) == ERROR) { \
+ PSpanic("mGET_NIND_WORK_SIM:Could not get semaphore\n"); \
+ } \
+ else if ( mIS_THERE_WORK( (mid) ) ) { \
+ tOCTET2 count=lstCount(mMID2NIND((mid))); \
+ if (count < 0 ) { \
+ PSpanic("mGET_NIND_WORK_SIM:Could not get count\n"); \
+ }\
+ else if ( count > 0 ){ \
+ pComSim = (tpCOMSIM)lstGet(mMID2NIND(mid)); \
+ if (pComSim == NULL) { \
+ PSpanic("mGET_NIND_WORK_SIM:NULL Sim Dequeued\n"); \
+ } \
+ --((pimcglp[mid])->workCount); \
+ mCHANGEGLOBALCOUNT( DECREMENT ); \
+ } \
+ } else { \
+ pComSim = NULL; \
+ } \
+ if ( PSsemGive( freeIndexSemId ) == ERROR) { \
+ PSpanic("mGET_NIND_WORK_SIM:Could not give semaphore\n"); \
+ } \
+ }
+
+/* Get Expedited Indication work only */
+
+#define mGET_EIND_WORK_SIM(pComSim, mid) \
+ { \
+ if ( PSsemTake( freeIndexSemId,WAIT_FOREVER ) == ERROR) { \
+ PSpanic("mGET_EIND_WORK_SIM:Could not get semaphore\n"); \
+ } \
+ else if ( mIS_THERE_WORK( (mid) ) ) { \
+ tOCTET2 count=lstCount(mMID2EIND((mid))); \
+ if (count < 0 ) { \
+ PSpanic("mGET_EIND_WORK_SIM:Could not get count\n"); \
+ }\
+ else if ( count > 0 ){ \
+ pComSim = (tpCOMSIM)lstGet(mMID2EIND(mid)); \
+ if (pComSim == NULL) { \
+ trace_Msg("mGET_EIND_WORK_SIM:NULL Sim Dequeued\n"); \
+ } \
+ mCHANGEGLOBALCOUNT( DECREMENT ); \
+ --((pimcglp[mid])->workCount); \
+ } \
+ } else{ \
+ pComSim = NULL; \
+ } \
+ if ( PSsemGive( freeIndexSemId ) == ERROR) { \
+ PSpanic("mGET_EIND_WORK_SIM:Could not give semaphore\n"); \
+ } \
+ }
+
+/* Get Normal Request work only */
+
+#define mGET_NREQ_WORK_SIM(pComSim, mid) \
+ { \
+ if ( PSsemTake( freeIndexSemId,WAIT_FOREVER ) == ERROR) { \
+ PSpanic("mGET_NREQ_WORK_SIM:Could not get semaphore\n"); \
+ } \
+ else if ( mIS_THERE_WORK((mid))) { \
+ tOCTET2 count=lstCount(mMID2NREQ((mid))); \
+ if (count < 0 ) { \
+ PSpanic("mGET_NREQ_WORK_SIM:Could not get count\n"); \
+ } \
+ else if ( count > 0 ){ \
+ pComSim = (tpCOMSIM)lstCount(mMID2NREQ(mid)); \
+ if (pComSim == NULL) { \
+ PSpanic("mGET_NREQ_WORK_SIM:NULL Sim Dequeued\n"); \
+ } \
+ mCHANGEGLOBALCOUNT( DECREMENT ); \
+ --((pimcglp[mid])->workCount); \
+ } \
+ } else { \
+ pComSim = NULL; \
+ } \
+ if ( PSsemGive( freeIndexSemId ) == ERROR) { \
+ PSpanic("mGET_NREQ_WORK_SIM:Could not give semaphore\n"); \
+ } \
+ }
+
+/* Get Expedited Request work only */
+
+#define mGET_EREQ_WORK_SIM(pComSim, mid) \
+ { \
+ if ( PSsemTake( freeIndexSemId,WAIT_FOREVER ) == ERROR) { \
+ PSpanic("mGET_EREQ_WORK_SIM:Could not get semaphore\n"); \
+ } \
+ else if ( mIS_THERE_WORK((mid))) { \
+ tOCTET2 count=lstCount(mMID2EREQ((mid))); \
+ if (count < 0 ) { \
+ PSpanic("mGET_EREQ_WORK_SIM:Could not get count\n"); \
+ }\
+ else if ( count > 0 ){ \
+ pComSim = (tpCOMSIM)lstGet(mMID2EREQ(mid)); \
+ if (pComSim == NULL) { \
+ PSpanic("mGET_EREQ_WORK_SIM:NULL Sim Dequeued\n"); \
+ } \
+ mCHANGEGLOBALCOUNT( DECREMENT ); \
+ --((pimcglp[mid])->workCount); \
+ } \
+ } \
+ else { \
+ pComSim = NULL; \
+ } \
+ if ( PSsemGive( freeIndexSemId ) == ERROR) { \
+ PSpanic("mGET_EREQ_WORK_SIM:Could not give semaphore\n"); \
+ } \
+ }
+
+
+#else /* USE_IMC_MACROS */
+
+#define mCHANGEGLOBALCOUNT(action) \
+ imc_change_global_count( (action))
+
+#define mPOST_SIM_NREQ(pComSim, rc) \
+ rc = imc_post_sim( (pComSim), NREQ_QUEUE)
+
+#define mPOST_SIM_MGMT(pComSim, rc) \
+ rc = imc_post_sim( (pComSim), MGMT_QUEUE)
+
+/* Post Expedited Indication Failed if rc != RC_OK */
+#define mPOST_SIM_EIND(pComSim, rc) \
+ rc = imc_post_sim( (pComSim), EIND_QUEUE)
+
+/* Post Expedited Request Failed if rc != RC_OK */
+#define mPOST_SIM_EREQ(pComSim, rc) \
+ rc = imc_post_sim( (pComSim), EREQ_QUEUE)
+
+/* Post Normal Indication Failed if rc != RC_OK */
+#define mPOST_SIM_NIND(pComSim, rc) \
+ rc = imc_post_sim( (pComSim), NIND_QUEUE)
+
+/* Get Management work only */
+#define mGET_MGMT_WORK_SIM(pComSim, mid) \
+ imc_get_sim( &(pComSim), (mid), MGMT_QUEUE );
+
+/* Get Normal Indication work only */
+#define mGET_NIND_WORK_SIM(pComSim, mid) \
+ imc_get_sim( &(pComSim), (mid), NIND_QUEUE );
+
+/* Get Expedited Indication work only */
+#define mGET_EIND_WORK_SIM(pComSim, mid) \
+ imc_get_sim( &(pComSim), (mid), EIND_QUEUE );
+
+/* Get Normal Request work only */
+#define mGET_NREQ_WORK_SIM(pComSim, mid) \
+ imc_get_sim( &(pComSim), (mid), NREQ_QUEUE );
+
+/* Get Expedited Request work only */
+#define mGET_EREQ_WORK_SIM(pComSim, mid) \
+ imc_get_sim( &(pComSim), (mid), EREQ_QUEUE );
+
+
+#endif /* USE_IMC_MACROS */
+
+
+/* Get Request work only */
+
+#define mGET_REQ_WORK_SIM(pComSim, mid) \
+ { \
+ mGET_EREQ_WORK_SIM( pComSim, mid ); \
+ if ( pComSim == NULL ) { \
+ mGET_NREQ_WORK_SIM( pComSim, mid ); \
+ } \
+ }
+
+/* Get indication work only */
+
+#define mGET_IND_WORK_SIM(pComSim, mid) \
+ { \
+ mGET_EIND_WORK_SIM( pComSim, mid ); \
+ if ( pComSim == NULL ) { \
+ mGET_NIND_WORK_SIM( pComSim, mid ); \
+ } \
+ }
+
+
+
+/* Get Any work. Enforces a policy of servicing order */
+/* Management, Expedited Indication, Expedited Requests */
+/* Normal Indications, Normal Requests. The order given */
+/* is also exhaustive and hence can starve other queues */
+
+#define mGET_WORK_SIM(pComSim, mid) \
+ { \
+ mGET_MGMT_WORK_SIM( pComSim, mid ); \
+ if ( pComSim == NULL ) { \
+ mGET_EIND_WORK_SIM( pComSim, mid ); \
+ } \
+ if ( pComSim == NULL ){ \
+ mGET_EREQ_WORK_SIM( pComSim, mid ); \
+ } \
+ if ( pComSim == NULL ){ \
+ mGET_NREQ_WORK_SIM( pComSim, mid ); \
+ } \
+ if ( pComSim == NULL ){ \
+ mGET_NIND_WORK_SIM( pComSim, mid ); \
+ } \
+ }
+
+/* mIS_THERE_WORK(mid) returns TRUE or FALSE depending on whether there
+ is work for this module or not */
+
+#define mIS_THERE_WORK(mid) \
+ ( ( \
+ (mMID2Q((mid)) == NULL ) ? FALSE : \
+ (mMID2Q((mid))->workCount > 0 ) ? \
+ TRUE : FALSE ) )
+
+/* checks if there is work in any of the imc queues */
+
+#define mANY_WORK imc_global_count
+
+/* exported by imc.c */
+extern tOCTET4 imc_global_count; /* keeps track of the TOTAL number
+ of entries in the imc facility */
+extern LIST *pimcListHead; /* Pointer to IMC ListHead */
+extern tpIMC_QANCHOR pimcglp[MAX_IMC_COUNT];
+/* Global MUTEX Semaphores */
+extern tSEMAPHORE freeIndexSemId; /* Protect freeIndex and hence IMC */
+extern boolean imcInited;
+extern void imc_term(void);
+extern tOCTET2 imc_init( void );
+extern tOCTET2 imc_add( tpOCTET4 index, tSEMAPHORE semId, tTASKID taskId );
+extern tOCTET2 imc_remove( tUOCTET4 index );
+extern tOCTET2 imc_post_sim(tpCOMSIM , IMC_QUEUE_TYPE);
+extern void imc_get_sim( tpCOMSIM *, tUOCTET4 , IMC_QUEUE_TYPE);
+
+#endif /* _IMC_H_ */
diff --git a/data/mnet/Common/cli/include/imsg.h b/data/mnet/Common/cli/include/imsg.h
new file mode 100644
index 0000000..45f3cc2
--- /dev/null
+++ b/data/mnet/Common/cli/include/imsg.h
@@ -0,0 +1,179 @@
+#ifndef _IMSG_H_
+#define _IMSG_H_
+/*
+-------------------------------------------------------------------------------
+ The common service interaction header
+-------------------------------------------------------------------------------
+*/
+
+struct com_sim {
+ NODE simq; /* queue element */
+ tUOCTET4 ownership; /* if 0, it can be freed */
+ tUOCTET4 origid; /* originators module id */
+ tUOCTET4 destid; /* destination module id */
+ tUOCTET4 requestid; /* request id generated by orig.*/
+ tUOCTET4 serviceid; /* service interaction id */
+ tUOCTET4 status; /* carries return codes */
+ SEM_ID ownerSemId; /* Semaphore for ownership */
+ void *pLayerSim; /* pointer to module-specific sim */
+} ;
+
+typedef struct com_sim tCOMSIM, *tpCOMSIM;
+
+struct idval {
+ tOCTET4 id; /* Identifier */
+ void* value; /* Value */
+};
+
+typedef struct idval tIDVAL, *tpIDVAL;
+
+#define MAX_CFG_ID_VAL 5
+
+struct mgmt_sim {
+ tCOMSIM comsim; /* Common SIM */
+ tUOCTET4 nid;
+ tIDVAL idvals[MAX_CFG_ID_VAL];
+ boolean sense;
+ SEM_ID configSemId;
+ int inFd;
+ int outFd;
+};
+
+#define mGETID(pSim,index) (pSim)->idvals[(index)-1].id
+#define mGETVAL(pSim,index) (pSim)->idvals[(index)-1].value
+
+#define mSETID( pSim,index,id ) mID((pSim),(index)) = (id)
+#define mSETVAL( pSim,index,val ) mID((pSim),(index)) = (val)
+
+typedef struct mgmt_sim tMGMTSIM, *tpMGMTSIM;
+
+/*
+------------------------------------------------------------------------------
+ SIM manipulation macros
+------------------------------------------------------------------------------
+*/
+#define IMCcalloc(nelem, elemSize) PScalloc((nelem), (elemSize))
+#define IMCmalloc(elemSize) PSmalloc((elemSize))
+#define IMCrealloc(elemPtr, elemSize) PSrealloc((elemPtr), (elemSize))
+#define IMCfree(elemPtr) PSfree((elemPtr))
+
+
+
+#define mGETSIM(size) imsg_getsim( (size) )
+
+#define mFREEMGMTSIM(pSim) \
+ { \
+ mFREESIM( &(pSim->comsim) ); \
+ }
+#ifndef USE_IMC_MACROS
+#define mFREESIM(pSim) imsg_freesim( (pSim))
+#else
+#define mFREESIM(pSim) \
+ { \
+ if ( PSsemTake(((tpCOMSIM)(pSim))->ownerSemId,\
+ WAIT_FOREVER ) == ERROR ) { \
+ PSpanic("Could not Take Ownership Semaphore "); \
+ }\
+ else if ( ((tpCOMSIM)(pSim))->ownership == 0) { \
+ if( ((tpCOMSIM)(pSim))->pLayerSim ) \
+ PSfree(((tpCOMSIM)(pSim))->pLayerSim); \
+ PSsemDelete(((tpCOMSIM)(pSim))->ownerSemId); \
+ PSfree((tpCOMSIM)pSim);\
+ } else {\
+ --((tpCOMSIM)(pSim))->ownership;\
+ if (PSsemGive(((tpCOMSIM)(pSim))->ownerSemId) == ERROR ) {\
+ PSpanic("mFREESIM:Could not Give Ownership Semaphore\n"); \
+ }\
+ }\
+ }
+#endif /* USE_IMC_MACROS */
+
+#define mSIMCOPY(pDestsim, pSrcSim) \
+ { \
+ PSsemTake(((tpCOMSIM)(pSrcSim))->ownerSemId, WAIT_FOREVER ); \
+ ((tpCOMSIM)(pSrcSim))->ownership++; \
+ pDestSim = pSrcSim; \
+ PSsemGive(((tpCOMSIM)(pSrcSim))->ownerSemId); \
+ }
+
+#define mZEROSIM(pSim) imsg_zerosim( (pSim) )
+
+#define mFILL_COM_SIM( pComSim, origin, dest, service, request, pLayer,owner, \
+ moreStatus )\
+ { \
+ if ( !pComSim ) { \
+ PSpanic("NULL SIM in mFILL_COM_SIM\n"); \
+ } \
+ else { \
+ pComSim->ownership = owner; \
+ pComSim->origid = origin; \
+ pComSim->destid = dest; \
+ pComSim->requestid = request; \
+ pComSim->serviceid = service; \
+ pComSim->pLayerSim = pLayer; \
+ pComSim->status = moreStatus; \
+ } \
+ }
+
+#define mSIM_ORIG(pGsim) ((pGsim)->origid)
+#define mSIM_DEST(pGsim) ((pGsim)->destid)
+#define mSIM_REQ(pGsim) ((pGsim)->requestid)
+#define mSIM_SERV(pGsim) ((pGsim)->serviceid)
+
+
+
+/*
+-------------------------------------------------------------------------------
+ Service interaction codes for the various modules, bottom up
+ Recomended convention for 4 byte service code:
+
+ [0][1][2][3]
+
+ byte 0: service provider id
+ byte 1: direction 1: request, 2 indication
+ byte 2, 3 service class
+
+-------------------------------------------------------------------------------
+*/
+
+#define MODULE_MASK 0xF000
+#define DIRECTION_MASK 0x0200
+#define SERVICE_CLASS_MASK 0x00FF
+ /* service to module */
+
+#define REQ_MASK 0x0100 /* Request Mask */
+#define IND_MASK 0x0200 /* Indication Mask*/
+
+#define IS_REQUEST(serviceid) ((serviceid) & REQ_MASK )
+#define IS_INDICATION(serviceid) ((serviceid) & IND_MASK )
+
+
+/* Get moduleid from service id */
+#define S2L(serviceid) ( ((serviceid)&LAYER_MASK) >> 12 )
+
+/* Service interaction codes */
+#define TEST_MODULE 0x00 /* Test Module */
+#define SMTPCL_MODULE 0x01 /* SMTP Client Module */
+#define HTTP_MODULE 0x02 /* Http Module */
+#define PARSER_MODULE 0x03 /* Parser Module */
+#define TIMER_MODULE 0x04 /* timer service */
+#define ACL_MODULE 0x05 /* ACL Module */
+#define CAPS_MODULE 0x06 /* CAPS Module */
+
+#define LAST_MODULE CAPS_MODULE
+
+#define ASSIGN_MODULE_ID -1
+
+/*
+**
+** Intermodule service access points
+**
+*/
+/* exported by imsg.c */
+#ifndef USE_IMC_MACROS
+extern void imsg_freesim( tpCOMSIM );
+#endif
+extern tpCOMSIM imsg_getsim (tOCTET4 );
+extern void imsg_zerosim (tpCOMSIM );
+
+#endif /* _IMSG_H_ */
diff --git a/data/mnet/Common/cli/include/macros.h b/data/mnet/Common/cli/include/macros.h
new file mode 100644
index 0000000..8b7d73b
--- /dev/null
+++ b/data/mnet/Common/cli/include/macros.h
@@ -0,0 +1,652 @@
+#ifndef __MACROS_H
+#define __MACROS_H
+
+/*
+ * Common help strings
+ */
+extern const char parser_help_default_keyword[];
+extern const char parser_help_no_keyword[];
+extern const char parser_default_keyword[];
+extern const char parser_no_keyword[];
+
+
+#ifdef BOOT
+#define PHELP(str) NULL
+#else BOOT
+#define PHELP(str) str
+#endif BOOT
+
+#define OBJ(type,num) PTYPE_ ## type ## ( ## num ## )
+
+#define pfdecl(x) extern void x (parseinfo *)
+
+#define TRANS_PRIV(name, priv)\
+ static trans_priv P ## name =\
+ {\
+ (priv),\
+ (priv),\
+ TRANS_PRIV_FLAGS_SET(priv),\
+ 0\
+ }
+
+
+#define NOP(name, acc, alt)\
+ static transition pname(name) = {&pname(acc), &pname(alt),\
+ (trans_func) NOP_action, NULL}
+
+#define LINK_POINT(name, acc)\
+ static dynamic_transition pname(name) =\
+ {\
+ (dynamic_transition *)&pname(acc),\
+ (dynamic_transition *)&pname(link_point),\
+ (trans_func) NOP_action,\
+ NULL\
+ }
+
+#define LINK_TRANS(name, acc)\
+ static dynamic_transition pname(L ## name) =\
+ {\
+ (dynamic_transition *)&pname(NONE),\
+ (dynamic_transition *)&pname(link_trans),\
+ (trans_func) NOP_action,\
+ NULL\
+ };\
+ static transition pname(name) = {(transition *) &pname(L ## name),\
+ &pname(acc),\
+ (trans_func) NOP_action, NULL}
+
+#define LINK_EXIT(name, acc)\
+ LINK_TRANS(name, acc)
+
+#define NVGENS(name, acc, func, subfunc)\
+ pfdecl(func);\
+ static nvgens_struct L ## name = {func, subfunc};\
+ static transition pname(name) = {&pname(acc), NULL,\
+ (trans_func) nvgens_action, & L ## name}
+
+#define NVGENNS(name, acc, func)\
+ pfdecl(func);\
+ static transition pname(name) =\
+ {\
+ &pname(acc),\
+ NULL,\
+ (trans_func) nvgenns_action,\
+ func\
+ }
+
+#define EOLNS(name,func)\
+ pfdecl(func);\
+ static transition pname(name) =\
+ {\
+ NULL,\
+ NULL,\
+ (trans_func) eolns_action,\
+ func\
+ }
+
+#define EOLS(name,func,subfunc)\
+ pfdecl(func);\
+ static eols_struct L ## name = {func, subfunc};\
+ static transition pname(name) = {NULL, NULL, (trans_func) eols_action, & L ## name}
+
+#define EOLI(name,func,subfunc)\
+ pfdecl(func);\
+ static eols_struct L ## name = {func, subfunc};\
+ static transition pname(name) = {NULL, NULL, (trans_func) eoli_action, & L ## name}
+
+#define HELP(name,alt,str)\
+ static help_struct L ## name = {PHELP(str), NULL};\
+ static transition pname(name) = {NULL, &pname(alt), (trans_func) help_action, & L ## name}
+
+#define GENERAL_STRING(name, acc, alt, str, help, flags)\
+ static general_string_struct L ## name =\
+ {\
+ CSBOFF(str),\
+ PHELP(help),\
+ flags\
+ };\
+ static transition pname(name) =\
+ {\
+ &pname(acc),\
+ &pname(alt),\
+ (trans_func) general_string_action,\
+ & L ## name\
+ }
+
+/* A string delimited by whitespace. */
+#define STRING(name, acc, alt, str, help)\
+ GENERAL_STRING(name, acc, alt, str, help,\
+ STRING_QUOTED | STRING_HELP_CHECK)
+
+/* A string delimited by EOL. */
+#define TEXT(name, acc, alt, str, help)\
+ GENERAL_STRING(name, acc, alt, str, help,\
+ STRING_WS_OK | STRING_HELP_CHECK)
+
+/*
+ * Testing Macros
+ */
+
+/* ASSERT - assert that a C expression is true */
+
+#define TEST_EXPR(name, true, false, alt, expr)\
+ static boolean F ## name (parseinfo *csb, transition *mine)\
+ {\
+ return((expr) != 0);\
+ }\
+ static testexpr_struct L ## name = {&pname(false), F ## name};\
+ static transition pname(name) = {&pname(true), &pname(alt),\
+ (trans_func) testexpr_action, & L ## name}
+
+#define ASSERT(name, acc, alt, expr)\
+ TEST_EXPR(name, acc, NONE, alt, expr)
+
+#define IFELSE(name, if, else, expr)\
+ TEST_EXPR(name, if, else, NONE, expr)
+
+/* EVAL - always accept, and evaluate a C expression */
+
+#define EVAL(name,acc,expr)\
+ static void F ## name (parseinfo *csb, transition *mine)\
+ { expr;push_node(csb, mine->accept); }\
+ static transition pname(name) = {&pname(acc), NULL, (trans_func) F ## name, NULL}
+
+/* TESTVAR - test a variable relative to a constant value */
+
+#define TESTVAR(name, equal, notequal, lt, gt, alt, var, val)\
+ static test_struct L ## name = {CSBOFF(var), (uint) val,\
+ &pname(equal), &pname(notequal),\
+ &pname(lt), &pname(gt)};\
+ static transition pname(name) = {NULL, &pname(alt),\
+ (trans_func) test_action, & L ## name}
+
+
+/* Relations simpler than TESTVAR in its entirity */
+
+#define EQUAL(name, acc, alt, var, val)\
+ TESTVAR(name, acc, NONE, NONE, NONE, alt, var, val)
+#define NEQ(name, acc, alt, var, val)\
+ TESTVAR(name, NONE, acc, NONE, NONE, alt, var, val)
+#define SPLIT(name, acc, alt, var, val)\
+ TESTVAR(name, acc, alt, NONE, NONE, NONE, var, val)
+
+/* SET - always accept, setting a variable to a constant value */
+
+#define SET(name, acc, var, val)\
+ static set_struct L ## name = {CSBOFF(var), (uint) val};\
+ static transition pname(name) = {&pname(acc), NULL,\
+ (trans_func) set_action, & L ## name}
+
+/*
+ * KEYWORD is a complete token, with help, error handling and whitespace.o
+ * KEYWORD_OPTWS has optional trailing white-space.
+ * KEYWORD_NOWS has no trailing white-space.
+ * KEYWORD_MM takes an extra argument for the minimum number of chars required
+ * to match.
+ */
+
+#define GENERAL_KEYWORD(name,acc,alt,str,help,priv,var,val,match,flags)\
+ TRANS_PRIV(name, priv);\
+ static general_keyword_struct L ## name = {str, PHELP(help), & P ## name,\
+ var, val, match, flags};\
+ static transition pname(name) = {&pname(acc),&pname(alt),\
+ (trans_func) general_keyword_action, & L ## name}
+
+#define KEYWORD(name, acc, alt, str, help, priv)\
+ TRANS_PRIV(name, priv);\
+ static keyword_struct L ## name = {str, PHELP(help), & P ## name};\
+ static transition pname(name) = {&pname(acc), &pname(alt),\
+ (trans_func) keyword_action, & L ## name}
+
+#define KEYWORD_OPTWS(name,acc,alt,str,help, priv)\
+ TRANS_PRIV(name, priv);\
+ static keyword_struct L ## name = {str, PHELP(help), & P ## name};\
+ static transition pname(name) = {&pname(acc), &pname(alt),\
+ (trans_func) keyword_optws_action, & L ## name}
+
+#define KEYWORD_OPTIONS(name, acc, alt, options, var, priv, flags)\
+ TRANS_PRIV(name, priv);\
+ static keyword_option_struct L ## name =\
+ {\
+ options,\
+ CSBOFF(var),\
+ & P ## name,\
+ flags\
+ };\
+ static transition pname(name) =\
+ {\
+ &pname(acc),\
+ &pname(alt),\
+ (trans_func) keyword_option_action,\
+ & L ## name\
+ }
+
+#define KEYWORD_MM(name,acc,alt,str,help, priv, count)\
+ TRANS_PRIV(name, priv);\
+ static keyword_mm_struct L ## name = {str, PHELP(help), & P ## name, count};\
+ static transition pname(name) = {&pname(acc), &pname(alt),\
+ (trans_func) keyword_mm_action, & L ## name}
+
+#define KEYWORD_ID(name, acc, alt, var, val, str, help, priv)\
+ TRANS_PRIV(name, priv);\
+ static keyword_id_struct L ## name = {str,PHELP(help),&P##name,CSBOFF(var),val};\
+ static transition pname(name) = {&pname(acc), &pname(alt),\
+ (trans_func) keyword_id_action, & L ## name}
+/*
+ * If parse keyword
+ * var |= val
+ */
+#define KEYWORD_OR(name, acc, alt, var, val, str, help, priv)\
+ TRANS_PRIV(name, priv);\
+ static keyword_id_struct L ## name = {str,PHELP(help),&P##name,CSBOFF(var),val};\
+ static transition pname(name) = {&pname(acc), &pname(alt),\
+ (trans_func) keyword_orset_action, & L ## name}
+
+/*
+ * Number macros
+ */
+
+#define GENERAL_NUMBER(name,acc,alt,var,lower,upper,help,flags)\
+ static number_struct L ## name = {CSBOFF(var), lower, upper, PHELP(help), flags};\
+ static transition pname(name) =\
+ {&pname(acc), &pname(alt), (trans_func) general_number_action, & L##name}
+
+#define NUMBER(name, acc, alt, var, lower, upper, help)\
+ GENERAL_NUMBER(name, acc, alt, var, lower, upper, help,\
+ (NUMBER_HEX | HEX_ZEROX_OK | NUMBER_OCT | OCT_ZERO_OK |\
+ NUMBER_DEC | NUMBER_WS_OK | NUMBER_HELP_CHECK))
+
+#define DECIMAL(name, acc, alt, var, lower, upper, help)\
+ GENERAL_NUMBER(name, acc, alt, var, lower, upper, help,\
+ (NUMBER_DEC | NUMBER_WS_OK | NUMBER_HELP_CHECK))
+
+/* HEXADECIMAL matches an unsigned hex number, minimum one
+ * digit, and assigns it to a int. This function works on numbers
+ * which don't begin with '0x'. */
+
+#define HEXADECIMAL(name,acc,alt,var)\
+ GENERAL_NUMBER(name, acc, alt, var, 0, -1, NULL,\
+ (NUMBER_HEX | HEX_NO_ZEROX_OK | NUMBER_NO_WS_OK))
+
+#define HEXNUM(name, acc, alt, var, help)\
+ GENERAL_NUMBER(name, acc, alt, var, 0, -1, help,\
+ (NUMBER_HEX | HEX_NO_ZEROX_OK | NUMBER_WS_OK | NUMBER_HELP_CHECK))
+
+
+/*
+ * This is an OCTAL number, with help, error handling and
+ * whitespace
+ */
+#define OCTAL(name,acc,alt,var,help)\
+ GENERAL_NUMBER(name, acc, alt, var, 0, -1, help,\
+ (NUMBER_OCT | OCT_ZERO_OK | OCT_NO_ZERO_OK |\
+ NUMBER_WS_OK | NUMBER_HELP_CHECK))
+
+#define SIGNED_DEC(name,acc,alt,var,lower,upper,help)\
+ static signed_number_struct L ## name = {CSBOFF(var), lower, upper, PHELP(help)};\
+ static transition pname(name) =\
+ {&pname(acc), &pname(alt), (trans_func) signed_number_action, & L##name}
+
+/* NOPREFIX
+ * Go to 'accept' if there isn't a 'no' prefix.
+ * Consume the remainder of the input and go to 'alt' if there
+ * was a 'no' prefix. This is somewhat backwards from other macros
+ * in that the major action takes place before going to the alternate
+ * state, but it keeps the major thread of the command token chains
+ * similar to other tokens.
+ */
+#define NOPREFIX(name, acc, alt)\
+ static transition pname(name) = {&pname(acc), &pname(alt),\
+ (trans_func) noprefix_action, NULL}
+
+
+/* IPADDR gets an IP address and stores it in addr.
+ * IPADDR_NAME gets an IP address or hostname and
+ * converts to an address stored in addr.
+ */
+#define IPADDR_NAME(name, acc, alt, addr, help)\
+ static addrparse_struct L ## name = {CSBOFF(addr), PHELP(help), ADDR_IP,\
+ ADDR_NAME_LOOKUP};\
+ static transition pname(name) = {& pname(acc), & pname(alt),\
+ (trans_func) generic_addr_action, & L ## name}
+
+#define IPADDR(name,acc,alt,addr, help)\
+ static addrparse_nf_struct L ## name = {CSBOFF(addr), PHELP(help), ADDR_IP};\
+ static transition pname(name) = {& pname(acc), & pname(alt),\
+ (trans_func) generic_addr_noflag_action, & L ## name}
+
+
+/* DAY - A day of the week */
+
+#define DAY(name,acc,alt,var,help) \
+ static day_struct L ## name = {CSBOFF(var), PHELP(help)};\
+ static transition pname(name) =\
+ {&pname(acc), &pname(alt), (trans_func) day_action, & L##name}
+
+/* MONTH - A month of the year */
+
+#define MONTH(name,acc,alt,var,help) \
+ static month_struct L ## name = {CSBOFF(var), PHELP(help)};\
+ static transition pname(name) =\
+ {&pname(acc), &pname(alt), (trans_func) month_action, & L##name}
+
+#define GENERAL_TIME(name, acc, alt, var1, var2, var3, help)\
+ static timesec_struct L ## name =\
+ {\
+ var1,\
+ var2,\
+ var3,\
+ help\
+ };\
+ static transition pname(name) =\
+ {\
+ &pname(acc),\
+ &pname(alt),\
+ (trans_func) timesec_action,\
+ & L ## name\
+ }
+
+/* TIME - A time (24 hours, without seconds) */
+#define ATIME(name, acc, alt, var1, var2, help)\
+ GENERAL_TIME(name, acc, alt, CSBOFF(var1),\
+ CSBOFF(var2), MAXUINT, help)
+
+/* TIMESEC - A time (24 hours, with seconds) */
+#define TIMESEC(name, acc, alt, var1, var2, var3, help)\
+ GENERAL_TIME(name, acc, alt, CSBOFF(var1),\
+ CSBOFF(var2), CSBOFF(var3), help)
+
+#define TEST_MULTIPLE_FUNCS(name, equal, notequal, alt)\
+ static test_struct L ## name = {0, 0, &pname(equal), &pname(notequal), NULL, NULL};\
+ static transition pname(name) = {NULL, &pname(alt),\
+ (trans_func) multiple_funcs_action, & L ## name}
+
+#define PRIV_TEST(name, acc, fail, alt, priv)\
+ TRANS_PRIV(name, priv);\
+ static priv_struct L ## name = {& P ## name, &pname(fail)};\
+ static transition pname(name) = {&pname(acc), &pname(alt),\
+ (trans_func) priv_action, & L ## name}
+
+#define NVCOMMENT(name, acc)\
+ static transition pname(name) =\
+ {\
+ &pname(acc),\
+ &pname(NONE),\
+ (trans_func) comment_action,\
+ NULL\
+ }
+
+#define NO_OR_DEFAULT(name, acc, flags) \
+ SET (name ## setsense, acc, sense, FALSE); \
+ KEYWORD (name, name ## setsense, acc, \
+ parser_no_keyword, parser_help_no_keyword, flags);
+
+
+
+#define IPADDR_MASK(name, acc, alt, addr, mask, help)\
+ static ipaddrmask_struct L ## name = { CSBOFF(addr), CSBOFF(mask), help};\
+ static transition pname(name) = {& pname(acc), & pname(alt),\
+ (trans_func) ipaddrmask_action, & L ## name}
+
+#define IPMASK(name,acc,alt,mask, help)\
+ static ipmask_struct L ## name = {CSBOFF(mask), PHELP(help)};\
+ static transition pname(name) = {& pname(acc), & pname(alt),\
+ (trans_func) ipmask_action, & L ## name}
+
+#define FUNC(name, acc, func)\
+ pfdecl(func);\
+ static transition pname(name) = {&pname(acc), NULL, (trans_func) func_action, func}
+
+#ifdef IOS_PARSER
+
+#define WHITESPACE(name,acc,alt)\
+ static transition pname(name) = {&pname(acc), &pname(alt),\
+ (trans_func) whitespace_action, NULL}
+
+#define PRINT(name,acc,str)\
+ static print_struct L ## name = {str};\
+ static transition pname(name) = {&pname(acc), NULL, (trans_func) print_action, & L ## name}
+
+#define DISPLAY(name,acc,str)\
+ static help_struct L ## name = {PHELP(str), NULL};\
+ static transition pname(name) = {NULL, &pname(acc),\
+ (trans_func) display_action, & L ## name}
+
+#define VAR_STRING(name, acc, alt, str) \
+ GENERAL_STRING(name, acc, alt, str, NULL, STRING_QUOTED)
+
+#define CHARACTER(name,acc,alt,character)\
+ static char_struct L ## name = {character};\
+ static transition pname(name) = {&pname(acc), &pname(alt),\
+ (trans_func) char_action, & L ## name}
+
+#define CHAR8_NUMBER(name, acc, alt, var, help)\
+ static number_struct L ## name = {CSBOFF(var), 0, 255, PHELP(help), 0};\
+ static transition pname(name) = \
+ {&pname(acc), &pname(alt), (trans_func) char_number_action, & L ## name}
+
+#define FUNC(name, acc, func)\
+ pfdecl(func);\
+ static transition pname(name) = {&pname(acc), NULL, (trans_func) func_action, func}
+
+
+#define TXT_LINE(name, acc, alt, str)\
+ GENERAL_STRING(name, acc, alt, str, NULL, STRING_WS_OK)
+
+#define CHAR_NUMBER(name, acc, alt, var, help)\
+ static number_struct L ## name = {CSBOFF(var), 0, 127, PHELP(help), 0};\
+ static transition pname(name) = \
+ {&pname(acc), &pname(alt), (trans_func) char_number_action, & L ## name}
+
+#define TEST_BOOLEAN(name, nonzero, zero, alt, var)\
+ static test_bool_struct L ## name = {&var, &pname(zero), &pname(nonzero)};\
+ static transition pname(name) = {NULL, &pname(alt),\
+ (trans_func) test_boolean_action, & L ## name}
+
+#define TEST_INT(name, nonzero, zero, alt, var)\
+ static test_int_struct L ## name = {&var, &pname(zero), &pname(nonzero)};\
+ static transition pname(name) = {NULL, &pname(alt),\
+ (trans_func) test_int_action, & L ## name}
+
+#define TEST_FUNC(name, nonzero, zero, alt, func)\
+ static test_func_struct L ## name = {func, &pname(zero), &pname(nonzero)};\
+ static transition pname(name) = {NULL, &pname(alt),\
+ (trans_func) test_func_action, & L ## name}
+
+#define TEST_IDBSTATUS(name, true, false, alt, val)\
+ static test_idbstatus_struct L ## name = {&pname(false), val};\
+ static transition pname(name) = {&pname(true), &pname(alt),\
+ (trans_func) test_idbstatus_action, & L ## name}
+
+#define KEYWORD_DEBUG(name, acc, alt, var, val, str, help, priv)\
+ KEYWORD_ID(name, acc, alt, var, (uint) val, str, help, priv)
+
+#define KEYWORD_ID_MM(name, acc, alt, var, val, str, help, priv, count)\
+ TRANS_PRIV(name, priv);\
+ static keyword_id_mm_struct L ## name = {str,PHELP(help),&P##name,CSBOFF(var),val,count};\
+ static transition pname(name) = {&pname(acc), &pname(alt),\
+ (trans_func) keyword_id_mm_action, & L ## name}
+
+#define KEYWORD_TRANS(name, link, acc, alt, str, help, priv)\
+ LINK_TRANS(link, acc);\
+ TRANS_PRIV(name, priv);\
+ static keyword_struct L ## name =\
+ {\
+ str,\
+ PHELP(help),\
+ & P ## name\
+ };\
+ static transition pname(name) =\
+ {\
+ &pname(link),\
+ &pname(alt),\
+ (trans_func) keyword_trans_action,\
+ & L ## name\
+ }
+
+/*
+ * If !(var & val) and parse keyword
+ * var |= val
+ */
+#define KEYWORD_ORTEST(name, acc, alt, var, val, str, help, priv)\
+ TRANS_PRIV(name, priv);\
+ static keyword_id_struct L ## name = {str,PHELP(help),&P##name,CSBOFF(var),val};\
+ static transition pname(name) = {&pname(acc), &pname(alt),\
+ (trans_func) keyword_ortest_action, & L ## name}
+
+#define KEYWORD_OPTIONS(name, acc, alt, options, var, priv, flags)\
+ TRANS_PRIV(name, priv);\
+ static keyword_option_struct L ## name =\
+ {\
+ options,\
+ CSBOFF(var),\
+ & P ## name,\
+ flags\
+ };\
+ static transition pname(name) =\
+ {\
+ &pname(acc),\
+ &pname(alt),\
+ (trans_func) keyword_option_action,\
+ & L ## name\
+ }
+
+#define KEYWORD_NOWS(name,acc,alt,str,help, priv)\
+ TRANS_PRIV(name, priv);\
+ static keyword_struct L ## name = {str, PHELP(help), & P ## name};\
+ static transition pname(name) = {&pname(acc), &pname(alt),\
+ (trans_func) keyword_nows_action, & L ## name}
+
+
+#define PERMIT_DENY(name, acc, alt, var, priv)\
+ KEYWORD_OPTIONS(name, acc, alt, permitdeny_options, var, priv, 0);
+
+#define NUMBER_NV(name, acc, alt, var, lower, upper, help)\
+ GENERAL_NUMBER(name, acc, alt, var, lower, upper, help,\
+ (NUMBER_HEX | HEX_ZEROX_OK | NUMBER_OCT | OCT_ZERO_OK |\
+ NUMBER_DEC | NUMBER_WS_OK | NUMBER_HELP_CHECK |\
+ NUMBER_NV_RANGE))
+
+/* Handle a decimal number, without help and whitespace. */
+#define IDECIMAL(name,acc,alt,var,lower,upper)\
+ GENERAL_NUMBER(name, acc, alt, var, lower, upper, NULL,\
+ (NUMBER_DEC | NUMBER_NO_WS_OK))
+
+/* Handle a decimal number, without help and whitespace. */
+#define INUMBER(name,acc,alt,var,lower,upper)\
+ GENERAL_NUMBER(name, acc, alt, var, lower, upper, NULL,\
+ (NUMBER_HEX | HEX_ZEROX_OK | NUMBER_OCT | OCT_ZERO_OK |\
+ NUMBER_DEC | NUMBER_NO_WS_OK))
+
+/* HEXADECIMAL matches an unsigned hex number, minimum one
+ * digit, and assigns it to a int. This function works on numbers
+ * which don't begin with '0x'. */
+
+#define HEXADECIMAL(name,acc,alt,var)\
+ GENERAL_NUMBER(name, acc, alt, var, 0, -1, NULL,\
+ (NUMBER_HEX | HEX_NO_ZEROX_OK | NUMBER_NO_WS_OK))
+
+#define HEXNUM(name, acc, alt, var, help)\
+ GENERAL_NUMBER(name, acc, alt, var, 0, -1, help,\
+ (NUMBER_HEX | HEX_NO_ZEROX_OK | NUMBER_WS_OK | NUMBER_HELP_CHECK))
+
+#define HEXDIGIT(name, acc, alt, var, lower, upper, help)\
+ GENERAL_NUMBER(name, acc, alt, var, lower, upper, help,\
+ (NUMBER_HEX | HEX_NO_ZEROX_OK | NUMBER_WS_OK | NUMBER_HELP_CHECK))
+
+#define OPT_HEXNUM(name, acc, alt, var, help)\
+ GENERAL_NUMBER(name, acc, alt, var, 0, -1, help,\
+ (NUMBER_HEX | HEX_NO_ZEROX_OK | HEX_ZEROX_OK |\
+ NUMBER_WS_OK | NUMBER_HELP_CHECK))
+
+#define OPT_HEXDIGIT(name, acc, alt, var, lower, upper, help)\
+ GENERAL_NUMBER(name, acc, alt, var, lower, upper, help,\
+ (NUMBER_HEX | HEX_NO_ZEROX_OK | HEX_ZEROX_OK |\
+ NUMBER_WS_OK | NUMBER_HELP_CHECK))
+
+#define ZEROXHEXNUM(name, acc, alt, var, help)\
+ GENERAL_NUMBER(name, acc, alt, var, 0, -1, help,\
+ (NUMBER_HEX | HEX_ZEROX_OK | NUMBER_WS_OK | NUMBER_HELP_CHECK))
+
+/*
+ * IOCTAL matches an unsigned octal number, minimum one
+ * digit, and assigns it to a int
+ */
+#define IOCTAL(name,acc,alt,var)\
+ GENERAL_NUMBER(name, acc, alt, var, 0, -1, NULL,\
+ (NUMBER_OCT | OCT_ZERO_OK | OCT_NO_ZERO_OK |\
+ NUMBER_NO_WS_OK))
+
+#define NUMBER_FUNC(name, acc, alt, var, func, help)\
+ static number_func_struct L ## name =\
+ {CSBOFF(var), func, PHELP(help)};\
+ static transition pname(name) =\
+ {&pname(acc), &pname(alt), (trans_func) number_func_action, & L ## name}
+
+#define NUMBER_HELP_FUNC(name, acc, alt, var, func)\
+ static number_help_func_struct L ## name =\
+ {CSBOFF(var), func};\
+ static transition pname(name) =\
+ {&pname(acc), &pname(alt), (trans_func) number_help_func_action, & L ## name}
+
+
+#define GENERAL_PARAMS(name, alt, keyword, var, lower, upper, func, subfunc, keyhelp, varhelp, priv, flags)\
+ pfdecl(func);\
+ TRANS_PRIV(name, priv);\
+ static params_struct L ## name = {keyword, CSBOFF(var), lower, upper,\
+ func, subfunc, PHELP(keyhelp),\
+ PHELP(varhelp),\
+ & P ## name, flags};\
+ static transition pname(name) = {NULL, & pname(alt),\
+ (trans_func) params_action, & L ## name}
+
+#define PARAMS(name, alt, keyword, var, lower, upper, func, subfunc, keyhelp,varhelp,priv)\
+ GENERAL_PARAMS(name, alt, keyword, var, lower, upper, func,\
+ subfunc, keyhelp, varhelp, priv,\
+ (KEYWORD_WS_OK | KEYWORD_HELP_CHECK | NUMBER_DEC |\
+ NUMBER_WS_OK | NUMBER_HELP_CHECK))
+
+#define PARAMS_KEYONLY(name, alt, keyword, var, lower, upper, func, subfunc, keyhelp, varhelp, priv)\
+ GENERAL_PARAMS(name, alt, keyword, var, lower, upper, func,\
+ subfunc, keyhelp, varhelp, priv,\
+ (KEYWORD_WS_OK | KEYWORD_HELP_CHECK | NUMBER_DEC |\
+ NUMBER_WS_OK | NUMBER_HELP_CHECK | NO_NUMBER))
+
+#define IPMASK(name,acc,alt,mask, help)\
+ static ipmask_struct L ## name = {CSBOFF(mask), PHELP(help)};\
+ static transition pname(name) = {& pname(acc), & pname(alt),\
+ (trans_func) ipmask_action, & L ## name}
+
+#define IPADDR_MASK(name, acc, alt, addr, mask, help)\
+ static ipaddrmask_struct L ## name = { CSBOFF(addr), CSBOFF(mask), help};\
+ static transition pname(name) = {& pname(acc), & pname(alt),\
+ (trans_func) ipaddrmask_action, & L ## name}
+
+/* Negative 1 (-1), used as the wild-card in many protocols */
+#define NEG1(name, acc, alt, net, help)\
+ KEYWORD_ID(name, acc, alt, net, -1L, "-1", help, PRIV_MIN)
+
+
+#define ALT_HELPS(name,func,subfunc)\
+ pfdecl(func);\
+ static eols_struct L ## name = {func, subfunc};\
+ static transition pname(name) = {NULL, NULL, (trans_func) alt_helps_action, & L ## name}
+
+/*
+ * Hexadecimal data stream. Used in 'llc2 send' command.
+ */
+
+#define HEXDATA(name, acc, alt, buf, count, help, bufmax)\
+ static hexdata_struct L ## name = {CSBOFF(buf), CSBOFF(count),\
+ PHELP(help), bufmax};\
+ static transition pname(name) = {&pname(acc), &pname(alt),\
+ (trans_func) hexdata_action, & L ## name}
+
+#define KEYWORD_NEG(name,acc, alt,str,help, priv)\
+ SET(name ## setsense, acc , sense, FALSE); \
+ KEYWORD(name, name ## setsense, alt, str, help, priv)
+
+
+#endif /* IOS_PARSER */
+
+#endif /* __MACROS_H__ */
diff --git a/data/mnet/Common/cli/include/mutex.h b/data/mnet/Common/cli/include/mutex.h
new file mode 100644
index 0000000..2362fd9
--- /dev/null
+++ b/data/mnet/Common/cli/include/mutex.h
@@ -0,0 +1,23 @@
+
+#ifndef MUTEX_HEADER
+#define MUTEX_HEADER
+
+enum mutex_types {
+ USYNC_THREAD,
+ USYNC_PROCESS
+};
+
+#define USYNC_THREAD 0
+
+typedef struct semaphore mutex_t;
+
+mutex_t * MUTEX_CREATE(enum mutex_types a2, void * a3);
+int MUTEX_LOCK(mutex_t * pMutex);
+int MUTEX_UNLOCK(mutex_t * pMutex);
+
+#define mutex_create MUTEX_CREATE
+#define mutex_lock MUTEX_LOCK
+#define mutex_unlock MUTEX_UNLOCK
+
+#endif /* MUTEX_HEADER */
+
diff --git a/data/mnet/Common/cli/include/nv.h b/data/mnet/Common/cli/include/nv.h
new file mode 100644
index 0000000..40b927f
--- /dev/null
+++ b/data/mnet/Common/cli/include/nv.h
@@ -0,0 +1,21 @@
+#if !defined(__NV_H__)
+#define __NV_H__
+
+
+
+extern void nv_init(void);
+
+extern void nv_configure(uchar);
+extern int nv_current_to_nv (boolean vocal);
+extern char* nv_current_to_buffer(boolean, uchar, boolean);
+extern void nv_review(parseinfo *);
+
+extern STATUS write_nv_config_from_fd( int );
+
+extern void nv_add (boolean , char *, ...);
+extern void nv_write (boolean , char *, ...);
+extern int nv_erase(boolean);
+
+extern boolean ok_to_write_nv(void);
+
+#endif /* !defined(__NV_H__) */
diff --git a/data/mnet/Common/cli/include/parser.h b/data/mnet/Common/cli/include/parser.h
new file mode 100644
index 0000000..2037210
--- /dev/null
+++ b/data/mnet/Common/cli/include/parser.h
@@ -0,0 +1,263 @@
+#ifndef __PARSER_H__
+#define __PARSER_H__
+
+
+
+enum {
+ STACKMAKER_NAME =0,
+ STACKMAKER_MEMBER,
+};
+
+typedef struct parsenode_ {
+ struct parsenode_ *next; /* Next stack entry */
+ transition *node; /* The node */
+ int line_index; /* Where we are in the input buffer */
+ char nv_command[PARSEBUF]; /* The command generated to this point */
+ char visible_ambig[PARSEBUF]; /* Visible command ambiguity detection */
+ char hidden_ambig[PARSEBUF]; /* Hidden command Ambiguity detection */
+ boolean command_visible; /* TRUE if current keyword is visible */
+ boolean unsupported; /* TRUE if current keyword is unsupp. */
+ parser_mode *pmp; /* Parser mode */
+ boolean sense; /* FALSE if 'no' parsed. Also FALSE if 'default'
+ * parsed because the off state is the default for
+ * most commands. */
+ boolean set_to_default; /* TRUE if 'default' parsed */
+ boolean leave_subcommand;
+
+#ifdef BOOMERANG
+ /* save string info from csb into sub-mode csb's */
+ char save_txt[PARSEBUF];
+#endif /* BOOMERANG */
+ int interface;
+
+} parsenode;
+
+typedef struct callbackMsg {
+ parseinfo *csb;
+ tpPARSERSIM pSim;
+} tCALLBACKMSG, *tpCALLBACKMSG;
+
+/* extern chunk_type *parseinfo_chunks;*/
+
+extern parseinfo *get_csb(const char *);
+extern void free_csb(parseinfo **csb);
+struct idbtype_ *findidb(parseinfo *csb);
+extern void set_multiple_funcs(parseinfo *csb, int value);
+extern void increment_multiple_funcs(parseinfo *csb, char *str);
+extern int test_multiple_funcs(parseinfo *csb, char test, int value);
+extern int test_visible_multiple_funcs(parseinfo *csb, char test, int value);
+extern int test_invisible_multiple_funcs(parseinfo *csb, char test, int value);
+extern void print_multiple_funcs(parseinfo *csb);
+extern void report_error(parseinfo *, int, boolean);
+extern tOCTET2 parser_send_response( tpCOMSIM , char *, tUOCTET4 );
+extern void ParserCallbackInit( void );
+
+/* Return values from parse_cmd() used by report_error() */
+#define PARSE_ERROR_NOERR 0x0 /* Success */
+#define PARSE_ERROR_AMBIG 0x1 /* Ambiguous command */
+#define PARSE_ERROR_NOMATCH 0x2 /* True error; didn't match any command */
+#define PARSE_ERROR_UNKNOWN 0x4 /* Didn't match anything while doing help */
+#define PARSE_ERROR_ALIAS 0x8 /* Didn't match expanded alias */
+
+#define RC_CONT 1
+#define RC_MORE 2
+#define RC_NO_MORE 3
+#define RC_CANT_MORE 4
+#define RC_WAIT 5
+#define RC_BREAK 6
+#define RC_CFG_BREAK 7
+#define RC_TIMEOUT 8
+
+#define MORE_BUFFER 1
+#define MORE_FILE 2
+
+#define NON_UNIQUE 1 /* Non-unique token in help */
+#define PARSE_FAIL 2 /* Parse failed */
+
+/*
+ * Values for csb->in_help
+ */
+#define PARSER_NO_HELP 0
+#define PARSER_HELP 1<<0
+#define PARSER_COMMAND_COMPLETION 1<<1
+
+/*
+ * Values for mode volume
+ */
+#define MODE_VERBOSE 1
+#define MODE_SILENT 2
+
+/*
+ * Type of parser
+ */
+#define PARSER_CLI_DEFAULT 0
+#define PARSER_CLI_TCL 1
+#define PARSER_CLI_OVERRIDE 2
+
+
+#ifdef USE_PARSER_KMEM
+
+#define PARSERcalloc(nelem, elemSize) PSkcalloc((nelem), (elemSize), \
+ M_PARSER, M_WAITOK)
+#define PARSERmalloc(elemSize) PSkmalloc((elemSize), \
+ M_PARSER, M_WAITOK)
+#define PARSERrealloc(elemPtr, elemSize) PSkrealloc((elemPtr), (elemSize), \
+ M_PARSER, M_WAITOK)
+#define PARSERfree( elemPtr ) PSkfree( (elemPtr), M_PARSER )
+
+#else
+
+#define PARSERcalloc(nelem, elemSize) PScalloc((nelem), (elemSize))
+#define PARSERmalloc(elemSize) PSmalloc((elemSize))
+#define PARSERrealloc(elemPtr, elemSize) PSrealloc((elemPtr), (elemSize))
+#define PARSERfree(elemPtr) PSfree((elemPtr))
+
+#endif
+
+
+#define PARSER_ENTRY_LINK_POINT 1
+#define PARSER_EXIT_LINK_POINT 2
+
+/*
+ * Uncomment this define to add parser link point names for debugging
+ */
+/*#define PARSER_DEBUG_LINKS*/
+
+typedef struct chain_link_ {
+ uint id;
+#ifdef PARSER_DEBUG_LINKS
+ const char *name;
+#endif /* PARSER_DEBUG_LINKS */
+ dynamic_transition *link_point;
+ uint type;
+} chain_link;
+
+typedef struct chain_list_ {
+ struct chain_list_ *next;
+ chain_link cp;
+} chain_list;
+
+extern chain_link chain_gang[];
+extern SEM_ID parse_chain_sem;
+
+typedef void * (*mode_save_var_func)(parseinfo *);
+typedef void (*mode_reset_var_func)(parseinfo *, void *);
+typedef boolean (*mode_http_init_func)(parseinfo *);
+
+
+extern parser_mode *parser_add_mode(const char *, const char *, const char *,
+ boolean, boolean, const char *,
+ mode_save_var_func, mode_reset_var_func,
+ transition *,
+ mode_http_init_func);
+
+extern parser_mode *get_mode_tmp(const char *, const char *, const char *,
+ boolean, boolean,
+ transition *);
+extern void free_mode(parser_mode *);
+extern parser_mode *get_alt_mode(parser_mode *);
+extern void *mode_save_vars(parseinfo *);
+extern void mode_reset_vars(parseinfo *, void *);
+extern boolean priv_changed_in_mode(parser_mode *);
+extern void set_priv_changed_in_mode(parser_mode *, boolean);
+extern boolean mode_http_init(parseinfo *);
+extern int print_debug(char *, ... );
+
+/*
+ * The big well known parser modes
+ */
+extern parser_mode *exec_mode;
+extern parser_mode *config_mode;
+
+/*extern BOOT_PARAMS sysBootParams;*/
+
+/*
+ * Some extern declarations for variables
+ * defined in parser.c / parser_init.c
+ */
+extern SEM_ID systemloadingSemId;
+extern int terminalLength;
+extern int parserNullFd;
+extern FILE* parserNullFp;
+
+/*
+ * Miscellaneous routine declarations.
+ */
+void parse_token(parseinfo *);
+void push_node(parseinfo *, transition *);
+int parse_cmd(parseinfo *, tpPARSERSIM);
+boolean batch_input(parseinfo *, char *, int, char *, char *);
+void print_caret(int);
+void save_line_init(save_buf*);
+void save_line(parseinfo *, save_buf*, const char*, ...);
+int print_buf(save_buf, boolean, boolean, int *, long);
+extern void bad_parser_subcommand(parseinfo *, uint);
+char *last_config_time_string(void);
+char *last_write_mem_time_string(void);
+void note_write_mem_time(void);
+void free_csb_mem(parseinfo *);
+extern int cliShell_sync(void);
+
+/*
+ * Parser Mode functions
+ */
+extern void parser_modes_init(void);
+extern parser_mode *get_mode_byname(const char *, uint);
+extern boolean set_mode_byname(parser_mode **, const char *, uint);
+extern queuetype *get_mode_aliases(parser_mode *);
+extern queuetype *get_mode_defaliases(parser_mode *);
+extern const char *get_mode_prompt(parseinfo *);
+extern boolean test_mode_config_subcommand(parseinfo *);
+extern transition *get_mode_nv(parseinfo *);
+extern transition *get_mode_top(parser_mode *);
+extern const char *get_mode_name(parser_mode *);
+extern void display_mode_aliases(parseinfo *, parser_mode *);
+extern void parser_add_main_modes(void);
+
+/*
+ * Global parser debug variables
+ */
+extern boolean parser_help_debug;
+extern boolean parser_ambig_debug;
+extern boolean parser_mode_debug;
+extern boolean parser_priv_debug;
+
+/*
+ * Should we have a prompt in config mode.
+ */
+extern boolean config_prompt;
+extern char *nomemory;
+
+extern int doprnt (char *, tt_soc *, const char *, va_list , boolean );
+extern void printVersion( void );
+extern int getTftpInput( char *pTftpServer, char *pFileName );
+
+extern boolean queueempty_inline (queuetype *q);
+extern void enqueue(queuetype *, void *);
+extern void unqueue(queuetype *, void *);
+extern void queue_init(queuetype *, int);
+extern void *dequeue(queuetype *);
+extern void requeue(queuetype *, void *);
+extern void *peekqueuehead (queuetype* q);
+extern int queryqueuedepth(queuetype *);
+extern void insqueue(queuetype *, void *, void *);
+extern ushort ipcrc (ushort *p, int count);
+extern boolean name_verify( char *);
+#ifdef IOS_PARSER
+/*
+ * Global parser debug variables
+ */
+extern boolean parser_alias_debug;
+extern boolean parser_http_debug;
+
+extern boolean parser_link_point_exists(uint);
+
+void recurse_node(parseinfo *, transition *);
+extern void *p_dequeue(queuetype *);
+extern void p_enqueue (queuetype *, void *);
+extern void p_unqueue (queuetype *, void *);
+extern void *remqueue(queuetype *, void *, void *);
+#endif
+
+
+#endif /* __PARSER_H_ */
diff --git a/data/mnet/Common/cli/include/parser_ModNum.h b/data/mnet/Common/cli/include/parser_ModNum.h
new file mode 100644
index 0000000..ac5b812
--- /dev/null
+++ b/data/mnet/Common/cli/include/parser_ModNum.h
@@ -0,0 +1,13 @@
+/*
+ * vxWorks errno module number for parser
+ * See man pages: makeStatTbl(3), errnoLib(1), printErrno(2)
+ */
+#ifndef _PARSER_MODNUM_H
+#define _PARSER_MODNUM_H
+
+/*
+ * Module numbers 1-500 are reserved to vxWorks
+ */
+#define M_parser (501 << 16)
+
+#endif /* _PARSER_MODNUM_H */
diff --git a/data/mnet/Common/cli/include/parser_actions.h b/data/mnet/Common/cli/include/parser_actions.h
new file mode 100644
index 0000000..296be88
--- /dev/null
+++ b/data/mnet/Common/cli/include/parser_actions.h
@@ -0,0 +1,591 @@
+#ifndef __PARSER_ACTIONS_H__
+#define __PARSER_ACTIONS_H__
+
+/******************************************************************
+ * Macros
+ ******************************************************************/
+
+#define SHORTHELP_LEN 32
+
+#define isodigit(c) (((c) >= '0') && ((c) <= '7'))
+#define is_terminator(c) (((c)=='\0') || ((c)=='!') || ((c)==';'))
+#define CVHTOB(c) ((int) c - \
+ (((c >= '0') && (c <= '9')) ? \
+ '0' : \
+ (((c >= 'a') && (c <= 'f')) ? \
+ 'a'-10 : \
+ 'A'-10)))
+
+#define INVALID_NVGEN_CHECK\
+ if (csb->nvgen) {\
+ if (!csb->priv_set) {\
+ printf("ERROR:INVALID_NVGEN_CHECK\n");\
+ }\
+ return;\
+ }
+
+
+/******************************************************************
+ * Defines
+ ******************************************************************/
+
+/* Command completion flags */
+#define NO_COMMAND_COMPLETION 0
+#define SUPPORT_COMMAND_COMPLETION 1
+
+#define ADDR_PARSE(n) 0xf000+n
+
+#define ADDR_NAME_LOOKUP 0x00000001
+#define ADDR_LIL_ENDIAN 0x00000002
+#define ADDR_HOST_ADDR_ONLY 0x00000004
+#define ADDR_HOST_NET_ONLY 0x00000008
+#define ADDR_PROTO_ADDR 0x00000010
+#define ADDR_NO_SHORT_HELP 0x80000000
+#define ADDR_ALL 0xffffffff
+
+/* Flag values for number_struct types field. */
+
+#define NUMBER_HEX 0x00000001 /* hexadecimal number */
+#define NUMBER_OCT 0x00000002 /* octal number */
+#define NUMBER_DEC 0x00000004 /* decimal number */
+#define NO_NUMBER 0x00000008 /* don't parse number if !sense */
+#define HEX_ZEROX_OK 0x00000010 /* hex number can have '0x000' */
+#define HEX_NO_ZEROX_OK 0x00000020 /* hex number can have no '0x000' */
+#define HEX_ZEROX_MATCHED 0x00000040 /* hex number matched '0x000' */
+#define HEX_ZEROX_NOT_MATCHED 0x00000080 /* hex number didn't match '0x000'*/
+#define OCT_ZERO_OK 0x00000100 /* oct number can have '0' */
+#define OCT_NO_ZERO_OK 0x00000200 /* oct number can have no '0' */
+#define OCT_ZERO_MATCHED 0x00000400 /* oct number matched '0' */
+#define OCT_ZERO_NOT_MATCHED 0x00000800 /* oct number didn't match '0' */
+
+#define SIGNED_NUMBER 0x00001000 /* parse signed number */
+
+#define NUMBER_WS_OK 0x00100000 /* number can have whitespace */
+#define NUMBER_NO_WS_OK 0x00200000 /* number can have no whitespace */
+#define KEYWORD_WS_OK 0x00400000 /* keyword can have whitespace */
+#define KEYWORD_NO_WS_OK 0x00800000 /* keyword can have no whitespace */
+
+#define NUMBER_HELP_CHECK 0x01000000 /* give help */
+#define KEYWORD_HELP_CHECK 0x02000000 /* give help */
+
+#define KEYWORD_OR_SET 0x04000000 /* OR value instead of set */
+#define KEYWORD_TEST 0x08000000 /* Test value before parsing */
+#define NUMBER_NV_RANGE 0x10000000 /* Do NV of number range */
+
+#define STRING_WS_OK NUMBER_WS_OK /* Whitespace allowed in string */
+#define STRING_HELP_CHECK NUMBER_HELP_CHECK /* Provide help for string */
+#define STRING_QUOTED 0x20000000 /* Quotes aren't included */
+
+/*
+ * Command privileges. The privilege levels can be 1-255 (stored
+ * as uchar). Privilege level 0 is reserved
+ * to indicate that normal processing of keywords should
+ * be done. If 'priv_set' is non-zero, then the keywords which match
+ * should copy 'priv_set' into their 'priv' variable.
+ *
+ */
+
+/*
+ * Privilege level is stored in a unsigned integer broken
+ * down like the following.
+ *
+ * bits 0-3 current privilege level
+ * bits 4-7 original privilege level when privilege level has been changed
+ * bits 8 indicates current privilege level has changed
+ * bits 9-22 unused
+ * bits 23 indicate distilled configuration
+ * bits 24-31 privilege modification flags
+ *
+ */
+
+#define PRIV_MIN 0x0
+#define PRIV_NULL 0x0 /* PRIV level means nothing. */
+#define PRIV_USER 0x1 /* No special privileges */
+#define PRIV_OPR 0xf /* Operator */
+#define PRIV_CONF 0xf /* Allowed to do configuration */
+#define PRIV_ROOT 0xf /* The Supreme Administrator */
+#define PRIV_MAX 0xf
+#define PRIV_INTERACTIVE 0x00400000 /* Interactive command */
+#define PRIV_CHANGED 0x00000100 /* Privilege level has changed */
+#define PRIV_DISTILLED 0x00800000 /* Configuration to be distilled */
+#define PRIV_INTERNAL 0x01000000 /* Command "for internal use only" */
+#define PRIV_UNSUPPORTED 0x02000000 /* Hidden unsupported command */
+#define PRIV_USER_HIDDEN 0x04000000 /* Hidden command from disabled user */
+#define PRIV_SUBIF 0x08000000 /* Allowed on subinterfaces */
+#define PRIV_HIDDEN 0x10000000 /* Hidden commands. Subtree rooted at
+ * this keyword is not searched. */
+#define PRIV_DUPLICATE 0x20000000 /* Keyword is a duplicate for
+ * split parse chains */
+#define PRIV_NONVGEN 0x40000000 /* Keywords that do not NVGEN */
+#define PRIV_NOHELP 0x80000000 /* Keywords that do not provide help */
+#define DEFAULT_PRIV PRIV_USER /* Default user privilege level */
+
+#define PRIV_PSYNALC 0x00200000 /* Keywords that are not used by synalc */
+
+#define TRANS_PRIV_PRIV_MASK 0xf
+#define TRANS_PRIV_FLAGS_OFFSET 9
+#define TRANS_PRIV_FLAGS_GET(priv) ((priv) << TRANS_PRIV_FLAGS_OFFSET)
+#define TRANS_PRIV_FLAGS_SET(priv) ((priv) >> TRANS_PRIV_FLAGS_OFFSET)
+
+/*
+ *
+ */
+#define RMATCH_IP 0x00100000
+#define RMATCH_OSI 0x00200000
+#define RMATCH_NOVELL 0x00400000
+#define RMATCH_NONE 0x80000000
+
+#define RMATCH_ARGS 0x01000000
+#define RMATCH_NO_ARGS 0x02000000
+#define RMATCH_TAG_REQUIRED 0x04000000
+#define RMATCH_NO_TAG 0x08000000
+#define RMATCH_NO_KEY_HELP 0x10000000
+
+/******************************************************************
+ * Data Structures
+ ******************************************************************/
+
+
+typedef struct trans_priv_ {
+ uint cur_priv : 4;
+ uint def_priv : 4;
+ uint PACKED(flags : 23);
+ uint PACKED(priv_changed : 1);
+#ifdef OBJECT_4K
+ uint pad; /* see CSCdi32916, before eliminating this pad */
+#endif
+} trans_priv;
+
+typedef const struct general_keyword_struct_ {
+ const char *str; /* The string to match */
+ const char *help; /* Help string */
+ trans_priv *priv; /* Privilege and flags of this keyword */
+ int offset; /* CSB offset to store value if keyword matches */
+ uint val; /* Value to store */
+ int minmatch; /* min number of chars required to match */
+ uint flags; /* white space and help flags */
+} general_keyword_struct;
+
+typedef const struct keyword_struct_ {
+ const char *str;
+ const char *help;
+ trans_priv *priv;
+} keyword_struct;
+
+typedef const struct keyword_mm_struct_ {
+ const char *str;
+ const char *help;
+ trans_priv *priv;
+ int minmatch;
+} keyword_mm_struct;
+
+typedef const struct keyword_id_struct_ {
+ const char *str; /* The keyword */
+ const char *help; /* Help string for this keyword */
+ trans_priv *priv; /* Privilege of this keyword */
+ int offset; /* CSB offset to store value if keyword matches */
+ uint val; /* Value to store */
+} keyword_id_struct;
+
+typedef struct dynamic_number_struct_ {
+ int offset; /* CSB offset to store parsed number */
+ uint lower; /* Lower limit we'll accept */
+ uint upper; /* Upper limit */
+ const char *help; /* The long help string */
+ uint flags; /* flags: hex, octal, decimal allowed,
+ whitespace allowed, to help or not to help */
+} dynamic_number_struct;
+
+typedef const struct dynamic_number_struct_ number_struct;
+
+typedef const struct signed_number_struct_ {
+ int offset; /* CSB offset to store parsed number */
+ signed int lower; /* Lower limit we'll accept */
+ signed int upper; /* Upper limit */
+ const char *help; /* The long help string */
+} signed_number_struct;
+
+typedef void (*parser_number_func)(parseinfo *, uint *, uint *);
+
+
+
+
+
+typedef const struct keyword_id_mm_struct_ {
+ const char *str; /* The keyword */
+ const char *help; /* Help string for this keyword */
+ trans_priv *priv; /* Privilege of this keyword */
+ int offset; /* CSB offset to store value if keyword matches */
+ uint val; /* Value to store */
+ int minmatch; /* minimum number of char to match */
+} keyword_id_mm_struct;
+
+typedef const struct keyword_options_ {
+ const char *keyword;
+ const char *help;
+ uint val;
+} keyword_options;
+
+extern keyword_options permitdeny_options[];
+
+typedef const struct keyword_option_struct_ {
+ keyword_options *options;
+ uint offset;
+ trans_priv *priv;
+ uint flags;
+} keyword_option_struct;
+
+
+#ifdef IOS_PARSER
+
+typedef const struct number_func_struct_ {
+ int offset; /* CSB offset to store parsed number */
+ parser_number_func func; /* Function to call to set range */
+ const char *help; /* The long help string */
+} number_func_struct;
+
+typedef void (*parser_number_help_func)(parseinfo *, uint *, uint *,const char **);
+typedef const struct number_help_func_struct_ {
+ int offset; /* CSB offset to store parsed number */
+ parser_number_help_func func; /* Function to set range and help string */
+} number_help_func_struct;
+
+
+#define PARAMS_STRUCT_COMMON \
+ const char *str; /* Keyword to match */ \
+ int offset; /* CSB offset to store parsed number */ \
+ uint lower; /* Lower range of parsed number */ \
+ uint upper; /* Upper range of parsed number */ \
+ void *func; /* func to call if parse is successful */ \
+ int subfunc; /* Subfunction code */ \
+ const char *keyhelp;/* Keyword help string */ \
+ const char *varhelp;/* Variable help string */ \
+ trans_priv *priv; /* Privilege of the keyword */ \
+ uint flags; /* Look for trailing whitespace, no whitespace, etc */
+
+typedef const struct params_struct_ {
+ PARAMS_STRUCT_COMMON
+} params_struct;
+
+typedef const struct params_struct_alist {
+ PARAMS_STRUCT_COMMON
+ uint lower2; /* Lower range of alternate parsed number */
+ uint upper2; /* Upper range of alternate parsed number */
+} params_struct_alist;
+
+typedef const struct print_struct_ {
+ const char * str;
+} print_struct;
+
+typedef const struct char_struct_ {
+ const character;
+} char_struct;
+
+typedef const struct string_struct_ {
+ int offset; /* CSB offset to store parsed string */
+ const char *help; /* Help message for this string */
+} string_struct;
+
+typedef const struct test_bool_struct_ {
+ boolean *var; /* Pointer to the variable to be tested */
+ transition *zero; /* Go here if variable == NULL */
+ transition *nonzero; /* Go here if variable != NULL */
+} test_bool_struct;
+
+typedef const struct test_int_struct_ {
+ int *var; /* Pointer to the variable to be tested */
+ transition *zero; /* Go here if variable == NULL */
+ transition *nonzero; /* Go here if variable != NULL */
+} test_int_struct;
+
+typedef const struct test_func_struct_ {
+ boolean (* func)(void);
+ transition *zero; /* Go here if variable == NULL */
+ transition *nonzero; /* Go here if variable != NULL */
+} test_func_struct;
+
+typedef const struct test_line_struct_ {
+ uint type; /* bit field of valid line types */
+ transition *zero; /* Go here if line range is valid */
+ transition *nonzero; /* Go here if line range is invalid */
+} test_line_struct;
+
+typedef const struct hexdata_struct_ {
+ int bufoffset; /* CSB offset to store parsed hex bytes */
+ int numoffset; /* CSB offset for number of bytes stored */
+ const char *help; /* Help string for this address */
+ uint bufmax; /* number of bytes in output buffer */
+} hexdata_struct;
+
+typedef const struct char_struct2_ {
+ const char character;
+ const char *help;
+} char_struct2;
+
+/* TCP & UDP port information */
+
+typedef const struct portinfo_ {
+ ushort port; /* port number */
+ const char *str; /* port name */
+ const char *help; /* help string */
+ uchar minmatch; /* min match */
+} portinfo;
+
+typedef const struct portparse_struct_ {
+ int offset; /* CSB offset to store parsed port */
+} portparse_struct;
+
+/* New protocol name/address parsing scheme
+ *
+ * The specification of which protocols are valid for parsing is done
+ * using a string, interpreted as a series of two-character codes.
+ * My convension is that protocol groups are named with two capital
+ * letters, and individual protocols are named with a capital and
+ * a lowercase letter. However, this convension is nowhere enforced
+ * or relied on by code. It serves mearly to help me keep these
+ * names unique.
+ *
+ * Any changes to this list should be reflected in the link_names
+ * table in actions.c that maps codes (both individual and group)
+ * to names and LINK_... macros.
+ */
+
+#define PMATCH_EXCLUDE "E:" /* Exclude following protocols */
+#define PMATCH_INCLUDE "I:" /* Include following protocols */
+
+#define PMATCH_ALL "AL" /* All protocols */
+#define PMATCH_DGRAM "DG" /* All datagram protocols */
+
+#define PMATCH_CDP "Cd"
+#define PMATCH_IP "Ip"
+
+
+typedef const struct protoname_struct_ {
+ int variable; /* CSB offset to store parsed link type */
+ const char *match_spec; /* Specification of acceptable protocols */
+} protoname_struct;
+
+typedef const struct protoaddr_struct_ {
+ int num_offset;
+ int addr_offset;
+ const char *match_spec;
+} protoaddr_struct;
+
+
+#endif /* IOS_PARSER */
+
+
+
+
+
+typedef const struct help_struct_ {
+ const char *str;
+ transition *eol;
+} help_struct;
+
+typedef const struct general_string_struct_ {
+ int offset; /* CSB offset to store parsed string */
+ const char *help; /* Help message for this string */
+ uint flags; /* Flags affecting how string is parsed */
+} general_string_struct;
+
+typedef const struct set_struct_ {
+ int offset; /* CSB offset to store value */
+ uint val; /* Value to store */
+} set_struct;
+
+typedef const struct test_struct_ {
+ int offset; /* CSB offset to numeric variable to test */
+ uint val; /* The value to test it against */
+ transition *equal; /* Go here if == */
+ transition *notequal; /* Go here if != */
+ transition *lt; /* Go here if < */
+ transition *gt; /* Go here if > */
+} test_struct;
+
+typedef const struct eols_struct_ {
+ void *func;
+ int subfunc;
+} eols_struct;
+
+typedef const struct nvgens_struct_ {
+ void *func;
+ int subfunc;
+} nvgens_struct;
+
+typedef const struct addrparse_struct_ {
+ int offset; /* CSB offset to store parsed address */
+ const char *help; /* Help string for this address */
+ uint type; /* Type of addres to parse */
+ uint flag; /* How to parse (e.g. addr only, addr or hostname) */
+} addrparse_struct;
+
+
+/* Same thing as an addrparse_struct, except without the flag */
+typedef const struct addrparse_nf_struct_ {
+ int offset; /* CSB offset to store parsed address */
+ const char *help; /* Help string for this address */
+ uint type; /* Type of addres to parse */
+} addrparse_nf_struct;
+
+
+typedef const struct ipaddrparse_struct_ {
+ int offset; /* CSB offset to store parsed address */
+ const char *help; /* Help string for this address */
+ int host;
+ int flag;
+} ipaddrparse_struct;
+
+typedef const struct ipmask_struct_ {
+ int mask; /* CSB offset to store parsed mask */
+ const char *help; /* Help string */
+} ipmask_struct;
+
+typedef const struct ipaddrmask_struct_ {
+ int addr; /* CSB offset to store parsed address */
+ int mask; /* CSB offset to store parsed mask */
+ const char *help; /* Help string */
+} ipaddrmask_struct;
+
+
+/* Month of the year */
+
+typedef const struct month_struct_ {
+ int offset; /* CSB offset */
+ const char *help;
+} month_struct;
+
+/* Day of the week */
+
+typedef const struct day_struct_ {
+ int offset; /* CSB offset */
+ const char *help;
+} day_struct;
+
+typedef const struct timesec_struct_ {
+ int var1;
+ int var2;
+ int var3;
+ const char *help;
+} timesec_struct;
+
+typedef boolean (* testexpr_func)(parseinfo *, transition *);
+typedef const struct testexpr_struct_ {
+ transition *fal;
+ const testexpr_func func;
+} testexpr_struct;
+
+typedef struct addr_func_ {
+ uint addr_type;
+ short_help_func get_short_help;
+ match_gen_func func;
+} addr_func;
+
+typedef struct priv_struct_ {
+ trans_priv *priv;
+ transition *fail;
+} priv_struct;
+
+typedef const struct mode_struct_ {
+ int offset;
+ uint flags;
+} mode_struct;
+
+
+extern addr_func *addr_funcs;
+
+/******************************************************************
+ * Function prototypes
+ ******************************************************************/
+
+extern void nvgen_token(parseinfo *, transition *, const char *);
+boolean help_check(parseinfo *);
+void help_or_error(parseinfo *, int, const char *, boolean);
+boolean match_whitespace2(char *, int *, boolean);
+boolean match_number(parseinfo *, uint, uint, int *, uint *, uint, const char *);
+boolean match_decimal(char *, uint, uint, int *, ushort *);
+boolean match_hexadecimal(char *, int *, ushort *);
+boolean match_ulong_decimal(char *, ulong, ulong, int *, ulong *);
+boolean match_ulong_octal(char *, ulong, ulong, int *, ulong *);
+boolean match_ulong_hexadecimal(char *, ulong, ulong, int *, ulong *);
+boolean match_char(char *, int *, char);
+boolean get_name(char *buf, char *name, int *pi, int buflen);
+void save_ambig_string(parseinfo *, const char *, const char *);
+void save_help_long(parseinfo *, const char *, const char *, uint);
+uint copy_varstring(char *, char *, uint, uint);
+void multiple_funcs_action(parseinfo *, transition *, test_struct * const);
+void display_action(parseinfo *, transition *, help_struct * const);
+void NONE_action(parseinfo *);
+void no_alt_action(parseinfo *);
+void link_point_action(parseinfo *);
+void NOP_action(parseinfo *, transition *);
+void general_number_short_help_http(uint *, uint, uint, char *, boolean);
+void general_keyword_action(parseinfo *, transition *, general_keyword_struct * const);
+void keyword_action(parseinfo *, transition *, keyword_struct * const);
+void keyword_mm_action(parseinfo *, transition *, keyword_mm_struct * const);
+void keyword_id_action(parseinfo *, transition *, keyword_id_struct * const);
+void keyword_orset_action(parseinfo *, transition *, keyword_id_struct * const);
+void keyword_ortest_action(parseinfo *, transition *, keyword_id_struct * const);
+void keyword_optws_action(parseinfo *, transition *, keyword_struct * const);
+void eol_action(parseinfo *, transition *, void (*)(parseinfo *));
+void eols_action(parseinfo *, transition *, eols_struct * const);
+void eoli_action(parseinfo *, transition *, eols_struct * const);
+void eolns_action(parseinfo *, transition *, void (*)(parseinfo *));
+void help_action(parseinfo *, transition *, help_struct * const);
+void func_action(parseinfo *, transition *, void (*)(parseinfo *));
+void set_action(parseinfo *, transition *, set_struct * const);
+void test_action(parseinfo *, transition *, test_struct * const);
+void ipmask_action (parseinfo *, transition *, ipmask_struct * const);
+void ipaddrmask_action (parseinfo *, transition *, ipaddrmask_struct * const);
+void day_action(parseinfo *, transition *, day_struct * const);
+void month_action(parseinfo *, transition *, month_struct * const);
+void timesec_action(parseinfo *, transition *, timesec_struct * const);
+void nvgens_action(parseinfo *, transition *, nvgens_struct * const);
+void nvgenns_action(parseinfo *, transition *, void (*)(parseinfo *));
+void noprefix_action(parseinfo *, transition *);
+void general_number_action(parseinfo *, transition *, number_struct * const);
+void signed_number_action(parseinfo *, transition *, signed_number_struct * const);
+void generic_addr_action(parseinfo *, transition *, addrparse_struct * const);
+void generic_addr_noflag_action(parseinfo *, transition *, addrparse_nf_struct * const);
+boolean eol_check(parseinfo *);
+void priv_action(parseinfo *, transition *, priv_struct * const);
+void mode_action(parseinfo *, transition *, mode_struct *const);
+void comment_action(parseinfo *, transition *);
+void testexpr_action(parseinfo *, transition *, testexpr_struct * const);
+void general_string_action(parseinfo *, transition *, general_string_struct * const);
+boolean match_partial_keyword(parseinfo *, const char *, int *pi,
+ const char *, int, uint, uint);
+void keyword_option_action(parseinfo *, transition *, keyword_option_struct * const);
+
+#ifdef IOS_PARSER
+
+boolean match_octal(char *, uint, uint, int *, ushort *);
+boolean match_minusone(char *, int *);
+void general_number_short_help(uint *, uint, uint, char *);
+void whitespace_action(parseinfo *, transition *);
+void print_action(parseinfo *, transition *, print_struct * const);
+void char_action(parseinfo *, transition *, char_struct * const);
+void char_number_action(parseinfo *, transition *, number_struct * const);
+void test_boolean_action(parseinfo *, transition *, test_bool_struct * const);
+void test_int_action(parseinfo *, transition *, test_int_struct * const);
+void test_func_action(parseinfo *, transition *, test_func_struct * const);
+void number_func_action(parseinfo *, transition *, number_func_struct * const);
+void number_help_func_action(parseinfo *, transition *, number_help_func_struct * const);
+void hexdata_action(parseinfo *, transition *, hexdata_struct * const);
+void keyword_id_mm_action(parseinfo *, transition *, keyword_id_mm_struct * const);
+void alt_help_action(parseinfo *, transition *, void (*)(parseinfo *));
+void alt_helps_action(parseinfo *, transition *, eols_struct * const);
+void params_action(parseinfo *, transition *, params_struct * const);
+void params_action_alist(parseinfo *, transition *, params_struct_alist * const);
+void keyword_nows_action(parseinfo *, transition *, keyword_struct * const);
+
+void keyword_trans_action(parseinfo *, transition *, keyword_struct *const);
+
+#endif /* IOS_PARSER */
+#endif /* __PARSER_ACTIONS_H__ */
+
+
+
+
+
+
diff --git a/data/mnet/Common/cli/include/parser_api.h b/data/mnet/Common/cli/include/parser_api.h
new file mode 100644
index 0000000..de5dd96
--- /dev/null
+++ b/data/mnet/Common/cli/include/parser_api.h
@@ -0,0 +1,13 @@
+#ifndef __PARSER_ACTIONS_H__
+#define __PARSER_ACTIONS_H__
+
+
+/*
+ * parser_init.cpp exported routines
+ */
+extern void cli_parser_init (void);
+
+
+
+#endif /* __PARSER_ACTIONS_H__ */
+
diff --git a/data/mnet/Common/cli/include/parser_commands.h b/data/mnet/Common/cli/include/parser_commands.h
new file mode 100644
index 0000000..356c8b7
--- /dev/null
+++ b/data/mnet/Common/cli/include/parser_commands.h
@@ -0,0 +1,27 @@
+#ifndef __PARSER_COMMANDS_H__
+#define __PARSER_COMMANDS_H__
+
+extern boolean cfg_dirty( void );
+extern void write_memory( parseinfo *);
+extern void reload_command( parseinfo *);
+extern void exit_config_command( parseinfo *);
+extern void parser_help(parseinfo *);
+
+extern void capsGetIPAddress( char * );
+extern void capsGetIPGateway( char * );
+extern void capsGetIPNetmask( char * );
+extern void capsGetIPBroadcast( char * );
+
+
+extern int isTelnetdEnabled( void );
+extern int isHttpEnabled( void );
+extern int isFtpdEnabled( void );
+extern int isTftpdEnabled( void );
+extern int isCronEnabled( void );
+extern int isSyslogdEnabled( void );
+extern int isBootpdEnabled( void );
+extern int isRcpdEnabled( void );
+extern int getHttpPort( void );
+
+#endif /* __PARSER_COMMANDS_H_ */
+
diff --git a/data/mnet/Common/cli/include/parser_debug.h b/data/mnet/Common/cli/include/parser_debug.h
new file mode 100644
index 0000000..b6e1f3a
--- /dev/null
+++ b/data/mnet/Common/cli/include/parser_debug.h
@@ -0,0 +1,36 @@
+/* $Id: parser_debug.h,v 10.1 1998/06/11 22:03:31 sutton Exp $
+ * $Source: /export/sbcc/cepro/os/parser/src/parser_debug.h,v $
+ *------------------------------------------------------------------
+ * Cisco MicroWeb Server Version 2
+ *
+ * File: parser_debug.h
+ * Description: Parser Debug macros
+ * Owner: Prasanna Parthasarathy
+ * Notes:
+ *
+ * Copyright (c) 1997 by cisco Systems, Inc.
+ * All rights reserved.
+ *------------------------------------------------------------------
+ * $Log: parser_debug.h,v $
+ * Revision 10.1 1998/06/11 22:03:31 sutton
+ * code merge
+ *
+ * Revision 1.2 1997/05/14 22:12:19 pparthas
+ * Removed test_* files. Included some files for Show routines
+ * and cleaned-up file structure ( not source code ;-) )
+ *
+ *------------------------------------------------------------------
+ * $Endlog$
+ */
+
+/* Function to fire up parser debugging */
+extern void debug_parser_init(void);
+
+/*
+ * The actual debugging flags are defined in parser_debug_flags.h.
+ * We include that file twice, once to define the flags themselves
+ * and once to define the indices that the parser uses.
+ */
+#include "parser_debug_flags.h"
+#define __DECLARE_DEBUG_NUMS__
+#include "parser_debug_flags.h"
diff --git a/data/mnet/Common/cli/include/parser_debug_flags.h b/data/mnet/Common/cli/include/parser_debug_flags.h
new file mode 100644
index 0000000..7f7cecf
--- /dev/null
+++ b/data/mnet/Common/cli/include/parser_debug_flags.h
@@ -0,0 +1,13 @@
+#include <../include/debug_macros.h>
+
+/* Now define the actual flags and the array that points to them */
+DEBUG_ARRDECL(parser_debug_arr)
+
+DEBUG_FLAG(parser_ambig_debug,DEBUG_PARSER_AMBIG,"Parser ambiguity")
+DEBUG_FLAG(parser_help_debug,DEBUG_PARSER_HELP,"Help message")
+DEBUG_FLAG(parser_mode_debug,DEBUG_PARSER_MODE,"Parser mode")
+DEBUG_FLAG(parser_alias_debug,DEBUG_PARSER_ALIAS,"Parser aliases")
+DEBUG_FLAG(parser_priv_debug,DEBUG_PARSER_PRIV,"Privilege level")
+DEBUG_FLAG(parser_http_debug,DEBUG_PARSER_HTTP,"Parser HTTP processing")
+
+DEBUG_ARRDONE
diff --git a/data/mnet/Common/cli/include/parser_defs_config.h b/data/mnet/Common/cli/include/parser_defs_config.h
new file mode 100644
index 0000000..4d7aa2b
--- /dev/null
+++ b/data/mnet/Common/cli/include/parser_defs_config.h
@@ -0,0 +1,28 @@
+/* Terminal and line parameter defines */
+enum TERM_LINE_PARAMS {
+ TERM_LENGTH,
+ TERM_WIDTH,
+ TERM_MONITOR,
+};
+
+/* Configuration sources */
+#define PARSER_CONF_NONE 0 /* No source identified */
+#define PARSER_CONF_TERM 1 /* Config from terminal */
+#define PARSER_CONF_MEM 2 /* Config from NV memory */
+#define PARSER_CONF_NET 3 /* Config from a TFTP host */
+#define PARSER_CONF_OVERWRITE_NET 4 /* Config from a TFTP host and o
+verwrite config */
+#define PARSER_CONF_BATCH 5 /* Not from terminal */
+#define PARSER_CONF_HTTP 6 /* Config from HTTP server */
+
+
+/* Enable defines */
+#define ENABLE_PASSWORD 1
+#define ENABLE_SECRET 2
+
+/* How many characters to save at the end of config buffers to guarantee
+ * that "\nend" gets written.
+ */
+#define ENDSTRLEN 5
+
+#define MAXTTYLENGTH 512
diff --git a/data/mnet/Common/cli/include/parser_defs_exec.h b/data/mnet/Common/cli/include/parser_defs_exec.h
new file mode 100644
index 0000000..8c57b49
--- /dev/null
+++ b/data/mnet/Common/cli/include/parser_defs_exec.h
@@ -0,0 +1,86 @@
+/* Global commands */
+#define HISTORY 0
+#define HISTORY_ON 1
+#define HISTORY_OFF 2
+#define HISTORY_PRINT 3
+#define HISTORY_SIZE 4
+#define DUMP 5
+
+/* Exec and privileged command function defines */
+
+#define CMD_CONNECT_DEFAULT 1
+#define CMD_CONNECT_RLOGIN 2
+#define CMD_CONNECT_TELNET 3
+#define CMD_CONNECT_TN3270 4
+#define CMD_DISABLE 5
+#define CMD_ENABLE 6
+#define CMD_END 7 /* Analogous to exit, but is NVGEN'ed */
+#define CMD_EXIT 8
+#define CMD_QUIT 9
+
+/* Write command destinations */
+#define WRITE_UNUSED 0
+#define WRITE_CORE 1
+#define WRITE_ERASE 2
+#define WRITE_MEMORY 3
+#define WRITE_NETWORK 4
+#define WRITE_TERMINAL 5
+
+
+
+/* BEGIN FROM parser_defs_flash.h */
+
+/* Copy command defines */
+/* Source and destinations for copy command */
+#define COPY_UNUSED 0
+#define COPY_FLASH_TFTP 1
+#define COPY_TFTP_FLASH 2
+#define COPY_TFTP_BOOTFLASH 3
+#define COPY_BOOTFLASH_TFTP 4
+#define COPY_RUNNING_CONFIG_TFTP 5
+#define COPY_STARTUP_CONFIG_TFTP 6
+#define COPY_TFTP_RUNNING_CONFIG 7
+#define COPY_TFTP_STARTUP_CONFIG 8
+#define COPY_FFFFFFFF_FLASH 9 /* OBSOLETE */
+#define COPY_VERIFY_FLASH 10
+#define COPY_SSE_MEMORY 11
+#define COPY_ERASE_FLASH 12
+#define COPY_ERASE_BOOTFLASH 13
+#define COPY_VERIFY_BOOTFLASH 14
+#define COPY_MOP_FLASH 15
+#define COPY_MOP_BOOTFLASH 16
+#define COPY_FLASH_RCP 17
+#define COPY_RCP_FLASH 18
+#define COPY_RCP_BOOTFLASH 19
+#define COPY_BOOTFLASH_RCP 20
+#define COPY_RUNNING_CONFIG_RCP 21
+#define COPY_STARTUP_CONFIG_RCP 22
+#define COPY_RCP_RUNNING_CONFIG 23
+#define COPY_RCP_STARTUP_CONFIG 24
+#define COPY_RUNNING_CONFIG 25
+#define COPY_STARTUP_CONFIG 26
+#define COPY_TFTP 27
+#define COPY_RCP 28
+#define COPY_FLHLOG 29
+#define COPY_RUNNING_CONFIG_DISK 30
+#define COPY_STARTUP_CONFIG_DISK 31
+#define COPY_DISK_STARTUP_CONFIG 32
+#define COPY_DISK_FLASH 33
+#define COPY_FLASH_DISK 34
+#define COPY_DISK_TFTP 35
+#define COPY_TFTP_DISK 46
+#define COPY_DISK_DISK 47
+#define COPY_TECHSUPPORT_DISK 48
+#define COPY_TECHSUPPORT_TFTP 49
+
+#define COPY_DISK_BIOS 50
+
+/* END FROM parser_defs_flash.h */
+
+
+#define DEFAULT_PING_PACKETS 5
+
+#define SHOW_MEM_TERSE 1
+#define SHOW_MEM_FREE 2
+#define SHOW_MEM_PAGES 3
+
diff --git a/data/mnet/Common/cli/include/parser_errno.h b/data/mnet/Common/cli/include/parser_errno.h
new file mode 100644
index 0000000..bb25ccf
--- /dev/null
+++ b/data/mnet/Common/cli/include/parser_errno.h
@@ -0,0 +1,53 @@
+#ifndef _PARSER_ERRNO_H
+#define _PARSER_ERRNO_H
+
+#define S_parser_PROGRAMMING_ERROR (M_parser | 1)
+#define S_parser_NVRAM_WRITE_ERROR (M_parser | 2)
+#define S_parser_NVRAM_NULL_WRITE (M_parser | 3)
+#define S_parser_NVRAM_READ_ERROR (M_parser | 4)
+#define S_parser_NVRAM_BAD (M_parser | 5)
+#define S_parser_NVRAM_CRC_FAIL (M_parser | 6)
+#define S_parser_SYNTAX_AMBIGUOUS (M_parser | 7)
+#define S_parser_SYNTAX_UNKNOWN (M_parser | 8)
+#define S_parser_SYNTAX_INCOMPLETE (M_parser | 9)
+#define S_parser_SYNTAX_INVALID (M_parser | 10)
+#define S_parser_SYNTAX_NULL_STRING (M_parser | 11)
+#define S_parser_SYNTAX_INVALID_IPADDR_FORMAT (M_parser | 12)
+#define S_parser_SYNTAX_INVALID_HOSTNAME_FORMAT (M_parser | 13)
+#define S_parser_IPADDR_RESERVED (M_parser | 14)
+#define S_parser_IPADDR_NO_NAME_SERVER (M_parser | 15)
+#define S_parser_IPADDR_HOSTNAME_LOOKUP_FAILED (M_parser | 16)
+#define S_parser_RESOURCE_ALLOCATION_ERROR (M_parser | 17)
+
+#define S_parser_SYNTAX_INVALID_NETMASK_FORMAT (M_parser | 18)
+#define S_parser_SYNTAX_INVALID_NETMASK_CONTIGUOUS (M_parser | 19)
+#define S_parser_SYNTAX_INVALID_NETMASK_IPADDR_MISMATCH (M_parser | 20)
+
+/**************** ERROR CODE DOCUMENTATION ********************************
+
+S_parser_SYNTAX_NULL_STRING - input string is null
+S_parser_SYNTAX_INVALID_IPADDR_FORMAT - invalid dotted-decimal notation
+S_parser_SYNTAX_INVALID_HOSTNAME_FORMAT - invalid string for a hostname
+
+For parser_ipaddr_or_hostname() api, if the input flag had
+IPADDR_MARTIAN_TEST_REQUIRED as TRUE, the following error code
+is also possible.
+
+S_parser_IPADDR_RESERVED - the IP address is one of the reserved IP addresses
+
+For parser_ipaddr_or_hostname(0 api, if input flag had
+IPADDR_HOSTNAME_ALLOWED as TRUE, the folllowing error codes are also possible.
+
+S_parser_IPADDR_NO_NAME_SERVER - no ip name servers configured to do DNS lookup
+S_parser_IPADDR_HOSTNAME_LOOKUP_FAILED - DNS resolver failed on hostname lookup
+
+S_parser_RESOURCE_ALLOCATION_ERROR - internal error - unable to acquire resource
+
+
+S_parser_SYNTAX_INVALID_NETMASK_FORMAT - Netmask is malformed
+S_parser_SYNTAX_INVALID_NETMASK_CONTIGUOUS - Netmask binary format should
+ have contiguous 1
+
+******************************************************************************/
+
+#endif /* _PARSER_ERRNO_H */
diff --git a/data/mnet/Common/cli/include/parser_if.h b/data/mnet/Common/cli/include/parser_if.h
new file mode 100644
index 0000000..1a10371
--- /dev/null
+++ b/data/mnet/Common/cli/include/parser_if.h
@@ -0,0 +1,135 @@
+#ifndef __PARSER_IF_H__
+#define __PARSER_IF_H__
+
+
+#define CLI_MODULE_ID 100
+#define CLI_MAX_STRING_LEN 128
+
+#include <vxworks.h>
+#include <stdioLib.h>
+#include <tyLib.h>
+#include <taskLib.h>
+#include <errnoLib.h>
+#include <lstLib.h>
+#include <inetLib.h> /* for INET_ADDR_LEN */
+#include <timers.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <msgQLib.h>
+#include <sigLib.h>
+
+
+#include <../include/cli_parser_private.h>
+#include <../include/pstypes.h>
+#include <../include/psvxif.h>
+#include <../include/imsg.h>
+#include <../include/imc.h>
+#include <../include/address.h>
+#include <../include/parsertypes.h>
+#include <../include/config.h>
+#include <../include/parser_sim.h>
+#include <../include/parser.h>
+#include <../include/parser_defs_exec.h>
+#include <../include/parser_input.h>
+#include <../include/parser_sim.h>
+#include <../include/parser_util.h>
+#include <../include/parser_commands.h>
+#include <../include/nv.h>
+#include <../include/parser_errno.h>
+#include <../include/parser_ModNum.h>
+#include <../include/defs.h>
+#include <../include/parser_init.h>
+#include <../include/macros.h>
+#include <../include/parser_actions.h>
+
+static long nvgen_int;
+static char nvgen_string[CLI_MAX_STRING_LEN+1];
+
+#define SET_INT_MIB(mibtag,obj,def,string) if (csb->sense) {\
+ if (oam_setMibIntVar(CLI_MODULE_ID,mibtag,obj) !=STATUS_OK)\
+ printf(string);\
+ } else {\
+ if (oam_setMibIntVar(CLI_MODULE_ID,mibtag,def) !=STATUS_OK)\
+ printf(string);\
+ }
+
+#define NVGEN_INT_MIB(mibtag,string) if (csb->nvgen) {\
+ if (oam_getMibIntVar(mibtag,&nvgen_int) !=STATUS_OK) {\
+ printf(string);\
+ } else {\
+ printf("\n %s %d",csb->nv_command,nvgen_int);\
+ }\
+ return;\
+ }
+
+#define NVGEN_IP_MIB(mibtag,string) if (csb->nvgen) {\
+ if (oam_getMibIntVar(mibtag,&nvgen_int) !=STATUS_OK) {\
+ printf(string);\
+ } else {\
+ address_string(nvgen_int,nvgen_string);\
+ printf("\n %s %s",csb->nv_command,nvgen_string);\
+ }\
+ return;\
+ }
+
+#define NVADDGEN_INT_MIB(mibtag,string,first,last) if (csb->nvgen) {\
+ if (oam_getMibIntVar(mibtag,&nvgen_int) !=STATUS_OK) {\
+ printf(string);\
+ } else {\
+ if (first)\
+ printf("\n %s %d",csb->nv_command,nvgen_int);\
+ else\
+ printf(" %d",nvgen_int);\
+ }\
+ if (last)\
+ return;\
+ }
+
+#define NVGEN_STRING_MIB(mibtag,string) if (csb->nvgen) {\
+ if (oam_getMibByteAry(mibtag,nvgen_string,CLI_MAX_STRING_LEN) !=STATUS_OK) {\
+ printf(string);\
+ } else {\
+ printf("\n %s %s",csb->nv_command,nvgen_string);\
+ }\
+ return;\
+ }
+
+#define NVADDGEN_STRING_MIB(mibtag,string,first,last) if (csb->nvgen) {\
+ if (oam_getMibByteAry(mibtag,nvgen_string,CLI_MAX_STRING_LEN) !=STATUS_OK) {\
+ printf(string);\
+ } else {\
+ if (first)\
+ printf("\n %s %s",csb->nv_command,nvgen_string);\
+ else\
+ printf(" %s",nvgen_string);\
+ }\
+ if (last)\
+ return;\
+ }
+
+
+#define NVGEN_BOOL_MIB(mibtag,string) if (csb->nvgen) {\
+ if (oam_getMibIntVar(mibtag,&nvgen_int) !=STATUS_OK) {\
+ printf(string);\
+ } else {\
+ if (nvgen_int)\
+ printf("\n %s enable",csb->nv_command);\
+ else\
+ printf("\n no %s enable",csb->nv_command);\
+ }\
+ return;\
+ }
+
+#define NVGEN_TIMER_MIB(mibtag,timer) if (csb->nvgen) {\
+ oam_getMibIntVar(mibtag,&nvgen_int);\
+ printf("\n\t %s %s %d",csb->nv_command,timer,nvgen_int);\
+ return;\
+ }
+
+#define NVADDGEN_TIMER_MIB(mibtag,timer) if (csb->nvgen) {\
+ oam_getMibIntVar(mibtag,&nvgen_int);\
+ printf("\n\t %s %s %d",csb->nv_command,timer,nvgen_int);\
+ }
+
+#endif
diff --git a/data/mnet/Common/cli/include/parser_init.h b/data/mnet/Common/cli/include/parser_init.h
new file mode 100644
index 0000000..6da3562
--- /dev/null
+++ b/data/mnet/Common/cli/include/parser_init.h
@@ -0,0 +1,38 @@
+#ifndef __PARSER_INIT_H
+#define __PARSER_INIT_H
+
+
+
+#define MAXCSB 32
+
+/*
+ * Externals
+ */
+extern parser_mode *exec_mode;
+extern parser_mode *config_mode;
+
+extern void test_parser_init(void);
+extern void parser_pipe_init(void);
+extern void show_os_chain_init(void);
+extern void parser_modes_init(void);
+extern void command_parser_init(void);
+extern void exec_parser_init(void);
+extern void parse_pager_init(void);
+extern void parser_sema_init(void);
+extern void parser_task_init(void);
+extern void parser_iowork_init(void);
+extern void parser_configure(void);
+extern parseinfo* get_csb(const char*);
+extern void BuildPrompt(parseinfo *, tt_soc*);
+
+extern void console_main(void);
+extern void parser_init(void);
+extern void getPrompt( parseinfo*, char*, char* );
+extern void processCommand( tpPARSERSIM );
+
+extern boolean config_prompt;
+extern int consoleFd;
+extern void parser_check();
+
+extern tBSEMAPHORE configSemId;
+#endif __PARSER_INIT_H
diff --git a/data/mnet/Common/cli/include/parser_input.h b/data/mnet/Common/cli/include/parser_input.h
new file mode 100644
index 0000000..3faf1e1
--- /dev/null
+++ b/data/mnet/Common/cli/include/parser_input.h
@@ -0,0 +1,84 @@
+#ifndef __PARSER_INPUT_H__
+#define __PARSER_INPUT_H__
+
+
+/* This should be >= MAX_TELNET_SESSIONS in telnetLib.c
+ * so that all telnet sessions can monitor
+ */
+#define MAX_FDS 5
+
+#define LINES 24
+#define LENGTH_DEFAULT LINES
+
+#define MAX_USERNAME_LEN 256
+#define MAX_PASSWD_LEN 256
+#define MAX_RETRIES 3
+#define MAXHOSTNAMELEN 64
+
+
+#define DEFAULT_EXEC_TIMEOUT ( 10 * 60 )
+
+#define IO_SIGINT 0x01
+#define IO_EXEC_TIMEOUT 0x02
+#define IO_SIGFLAGS_DELETED 0x00001000
+#define MAX_HISTORY 5
+
+typedef struct ioInfo {
+ parseinfo *csb;
+ tCSEMAPHORE ioSemId;
+ tUOCTET4 ioModuleId;
+ tUOCTET4 requestId;
+ tUOCTET4 flags;
+ tUOCTET4 sockFd;
+ tpOCTET execHistory[MAX_HISTORY];
+ tpOCTET configHistory[MAX_HISTORY];
+} tIOINFO,*tpIOINFO;
+
+typedef enum {
+ IO_RAW_MODE = 0,
+ IO_LINE_MODE,
+ IO_ECHO_MODE
+} tTERMINALMODE;
+
+/* Extern Declarations */
+extern tCSEMAPHORE initSemId;
+extern int consoleFd;
+extern tINT fdArray[MAX_FDS];
+extern boolean cgipipeDone;
+extern tINT cgiStatus;
+extern tINT cgiMode;
+/*extern tUID cgiUid;*/
+extern char usrPrompt[];
+extern char passwdPrompt[];
+extern char loginErrMsg[];
+
+extern tOCTET2 registerFd( tINT );
+extern tOCTET2 unregisterFd( tINT );
+/*extern void io_work(tINT, tINT, boolean, tUID, SEM_ID, boolean );*/
+extern void cgi_io_work(tINT, tINT );
+extern tOCTET2 io_more_buffer( tINT, char *, time_t );
+extern void moreFileOrBuffer( int , parseinfo *, int, boolean , time_t );
+
+extern tINT ioSetTerminalMode( int, tTERMINALMODE ) ;
+extern void show_techsupport( parseinfo *) ;
+extern void startIOTimer( parseinfo *csb );
+extern void stopIOTimer( parseinfo *csb );
+extern STATUS setExecTimeout(parseinfo *csb );
+
+
+extern FUNCPTR cli_logoutf;
+extern int cli_logVar;
+extern int ShellTask;
+extern int SSHTask;
+extern int installedVxShell;
+extern int TelnetTask;
+extern int ConsoleTask;
+extern boolean ExitFlag;
+extern int infd;
+extern int outfd;
+extern BOOL defaultUserInUse;
+
+#define PARSE_ADD_BOOT_PARAM 50
+#define PARSE_ADD_VXSH_CHAIN 51
+
+#endif /* __PARSER_INPUT_H_ */
diff --git a/data/mnet/Common/cli/include/parser_modes.h b/data/mnet/Common/cli/include/parser_modes.h
new file mode 100644
index 0000000..e51bc99
--- /dev/null
+++ b/data/mnet/Common/cli/include/parser_modes.h
@@ -0,0 +1,8 @@
+#ifndef __PARSER_MODES_H
+#define __PARSER_MODES_H
+
+#define PARSER_MODE_NONE 0x0001
+#define PARSER_MODE_ALIASES 0x0002
+#define PARSER_MODE_PRIVILEGE 0x0004
+
+#endif
diff --git a/data/mnet/Common/cli/include/parser_privilege.h b/data/mnet/Common/cli/include/parser_privilege.h
new file mode 100644
index 0000000..fef59b7
--- /dev/null
+++ b/data/mnet/Common/cli/include/parser_privilege.h
@@ -0,0 +1,19 @@
+#ifndef __PARSER_PRIVILEGE_H__
+#define __PARSER_PRIVILEGE_H__
+
+typedef struct privq_ {
+ struct privq_ *next; /* Next queue entry */
+ trans_priv *priv; /* Priv pointer */
+} privq;
+
+typedef struct priv_nvgenq_ {
+ struct priv_nvgenq_ *next; /* Next queue entry */
+ uint level; /* Priv level */
+ char command[PARSEBUF]; /* Current command */
+} priv_nvgenq;
+
+
+extern void priv_push(parseinfo *, trans_priv *);
+extern boolean nvgen_privilege (parseinfo *, trans_priv *, const char *);
+
+#endif /* __PARSER_PRIVILEGE_H__ */
diff --git a/data/mnet/Common/cli/include/parser_sim.h b/data/mnet/Common/cli/include/parser_sim.h
new file mode 100644
index 0000000..66b6d5f
--- /dev/null
+++ b/data/mnet/Common/cli/include/parser_sim.h
@@ -0,0 +1,33 @@
+#ifndef __PARSER_SIM_H
+#define __PARSER_SIM_H
+
+typedef struct parser_sim {
+ tCOMSIM comsim; /* Generic Interaction Module */
+ tOCTET command[PARSEBUF]; /* Command to be processed */
+ tOCTET lastchar; /* For Help Processing */
+ void *index; /* For More Processing */
+ tOCTET4 maxCount; /* For More Processing */
+ parseinfo *csb; /* CSB of I/O Task */
+} tPARSERSIM, *tpPARSERSIM;
+
+
+#define mFILL_PARSER_SIM( pParserSim, Csb, origin, dest, service, request, \
+ cmd, Lastchar, Index, MaxCount ) \
+ { \
+ tpCOMSIM pComSim = &(pParserSim->comsim); \
+ strcpy( (pParserSim->command), cmd ); \
+ pParserSim->csb = Csb; \
+ pParserSim->lastchar = Lastchar; \
+ pParserSim->index = Index; \
+ pParserSim->maxCount = MaxCount; \
+ mFILL_COM_SIM( pComSim, origin, dest, service, request, NULL, 0, 0); \
+ }
+
+
+#define PARSER_CMD_PROC_REQ 0x3100
+#define PARSER_CMD_PROC_IND 0x3200
+
+#define IO_WAIT_COMPLETE_IND 0xF2FE
+#define IO_CMD_COMPLETE_IND 0xF2FF
+
+#endif /* __PARSER_SIM_H */
diff --git a/data/mnet/Common/cli/include/parser_util.h b/data/mnet/Common/cli/include/parser_util.h
new file mode 100644
index 0000000..0f3b306
--- /dev/null
+++ b/data/mnet/Common/cli/include/parser_util.h
@@ -0,0 +1,21 @@
+#ifndef __PARSER_UTIL_H__
+#define __PARSER_UTIL_H__
+
+#define FUNCARGS0(argArray)
+#define FUNCARGS1(argsArray) argsArray[0]
+#define FUNCARGS2(argsArray) FUNCARGS1((argsArray)) ## , ## \
+ argsArray[1]
+#define FUNCARGS3(argsArray) FUNCARGS2((argsArray)) ## , ## argsArray[2]
+#define FUNCARGS4(argsArray) FUNCARGS3((argsArray)) ## , ## argsArray[3]
+#define FUNCARGS5(argsArray) FUNCARGS4((argsArray)) ## , ## argsArray[4]
+
+#define ARGS(argsArray,numArgs) FUNCARGS##numArgs(argsArray)
+
+extern boolean null (const char *s);
+extern char *deblank( const char *);
+extern boolean yes_or_no( const char *, boolean, boolean );
+extern boolean confirm( char *);
+
+extern void parser_return(parseinfo *, int errno_val);
+
+#endif /* __PARSER_UTIL_H_ */
diff --git a/data/mnet/Common/cli/include/parsertypes.h b/data/mnet/Common/cli/include/parsertypes.h
new file mode 100644
index 0000000..fc05d4e
--- /dev/null
+++ b/data/mnet/Common/cli/include/parsertypes.h
@@ -0,0 +1,145 @@
+#ifndef __PARSERTYPES_H__
+#define __PARSERTYPES_H__
+
+/* A BIG KLUDGE */
+
+typedef void tt_soc;
+
+#define NULLTTY (( void *) -1 )
+
+/* Check parser_util.c */
+/* A BIG KLUDGE */
+
+#define SCREEN_WIDTH 80
+
+#define sstrncpy strncpy
+
+/* FROM parser_defbreaksets.h */
+
+/* Break character set for the exec and config command levels.
+ */
+#define EXEC_BREAKSET "\r\n?\t"
+#define CONFIG_BREAKSET "\r\n\032?\t"
+#define NVCONFIG_BREAKSET "\r\n"
+
+/* FROM parser_defbreaksets.h */
+
+
+/* FROM sys/h/globs.h */
+
+/*
+ * define data structure for named things.
+ * NAMEDTHINGMACRO defines those fields common to all named things.
+ * This allows common code to find named things in queues, and so on.
+ */
+
+#define NAMEDTHINGNAMELEN 20
+#define NAMEDTHINGMACRO \
+ char name[NAMEDTHINGNAMELEN+1];
+/* FROM sys/h/globs.h */
+
+
+#define NULLFUNC ((void *) 0)
+
+#define EXEC_MODE 1
+#define CONFIG_MODE 2
+/*
+ * Define forward references to major system types
+ */
+
+#define STRUCTURE_REF(str) typedef struct str ## _ str
+
+STRUCTURE_REF(nvtype); /* h/config.h */
+STRUCTURE_REF(nvtype_private); /* h/config.h */
+STRUCTURE_REF(parseinfo); /* h/config.h */
+STRUCTURE_REF(parser_mode); /* h/config.h */
+STRUCTURE_REF(parser_alias); /* h/config.h */
+
+/*
+ * Can't use STRUCTURE_REF for transition because
+ * it is a constant.
+ */
+typedef const struct transition_ transition; /* h/config.h */
+
+/*
+ * Type Definitions -- note that these are really compiler specific
+ */
+
+#if !defined(_SIZE_T) && !defined(_GCC_SIZE_T)
+#define _SIZE_T
+
+#ifdef __GNUC__
+#define _GCC_SIZE_T
+/*
+ typedef __typeof__ (sizeof (0)) size_t;
+*/
+#else
+typedef unsigned int size_t;
+#endif /* __GNUC__ */
+
+#endif /* _SIZE_T */
+
+#ifdef caddr_t
+#undef caddr_t
+typedef unsigned char *caddr_t;
+#endif
+
+/*
+ * Size specific defines
+ */
+typedef signed char int8;
+typedef signed short int16;
+typedef signed long int32;
+typedef signed long long int64;
+typedef unsigned char uint8;
+typedef unsigned short uint16;
+typedef unsigned long uint32;
+typedef unsigned long long uint64;
+typedef unsigned char tinybool;
+typedef void forktype;
+
+/*
+ * Queuetype data structure
+ */
+typedef struct queuetype_ {
+ void *qhead; /* head of queue */
+ void *qtail; /* tail of queue */
+ int count; /* possible count */
+ int maximum; /* maximum entries */
+} queuetype;
+
+
+#define QUEUESIZE(q) queuesize_inline(q)
+#define QUEUEFULL(q) queuefull_inline(q)
+#define QUEUEFULL_RESERVE(q, reserve) \
+ queuefull_reserve_inline(q, reserve)
+#define QUEUEEMPTY(q) queueempty_inline(q)
+#define QUEUEMAXIMUM(q) queuemax_inline(q)
+
+
+typedef struct nexthelper_ {
+ struct nexthelper_ *next;
+ unsigned char data[0];
+} nexthelper;
+
+
+/*
+ * Define the PACKED macro
+ */
+#if defined(__mips) || defined(__mc68000) || defined(__PPC__)
+#define PACKED(item) item __attribute__ ((packed))
+#else
+#define PACKED(item) item
+#endif
+
+#define MIN(a,b) (((a) < (b)) ? (a) : (b))
+#define MAX(a,b) (((a) > (b)) ? (a) : (b))
+
+#ifdef NOTHING
+#define max(a,b) (((a) > (b)) ? (a) : (b))
+#define min(a,b) (((a) < (b)) ? (a) : (b))
+#endif
+
+
+#endif __PARSERTYPES_H__
+
diff --git a/data/mnet/Common/cli/include/platdef.h b/data/mnet/Common/cli/include/platdef.h
new file mode 100644
index 0000000..1891efb
--- /dev/null
+++ b/data/mnet/Common/cli/include/platdef.h
@@ -0,0 +1,229 @@
+#ifndef _PLATDEF_H_
+#define _PLATDEF_H_
+
+#include <stddef.h> /* _LITTLE_ENDIAN, _BIG_ENDIAN */
+
+ /*
+ **
+ ** some basic defines
+ **
+ */
+
+#define NO_PROTECT 0
+#define PROTECT 1
+
+#define RC_NONE 0
+#define RC_OK OK
+#define RC_ERR ERROR
+
+#if 0
+#define _LITTLE_ENDIAN_ 1234
+#define _BIG_ENDIAN_ 4321
+#define LITTLE_ENDIAN _LITTLE_ENDIAN_
+#define BIG_ENDIAN _BIG_ENDIAN_
+
+#define BYTE_ORDER _BYTE_ORDER
+#endif
+#define LITTLE_ENDIAN _LITTLE_ENDIAN
+#define BIG_ENDIAN _BIG_ENDIAN
+
+#define _ASCII_CHAR_ abcd
+
+#define PRIVATE static /* local routines, can be changed to make some routines
+ visible for debugging */
+
+/*
+** INCLUDES
+*/
+
+/* common includes */
+
+
+
+/* system specific includes. They contain primitive data type definitions */
+
+
+#ifdef UNIX
+#ifdef SUNSOL24
+#define PStypeString ((tOCTET *) "Sun Solaris 2.4")
+#endif
+#include <psunif.h>
+#endif
+
+
+#ifdef VXWORKS
+#ifdef VXWORKS53
+#define PStypeString((tOCTET *) "vxWorks 5.3")
+#endif
+#endif
+
+ /*
+ **
+ ** Basic defines
+ **
+ */
+
+
+#ifndef BYTE_ORDER /* byte order should be defined in platform file */
+#error Unrecognized Platform
+#endif
+
+#ifndef CHAR_SET
+#error Unrecognized Platform
+#endif
+
+#define PSNONSTDIO 1
+#define PSSTDIO 0
+
+/*
+** Macros
+*/
+
+
+/* Data representation macros */
+
+ /*
+ **
+ ** Macros for data conversion are:
+ ** mPS_2OCTET_TO_NET: convert 2 octets to network format
+ ** mPS_4OCTET_TO_NET: convert 4 octets to network format
+ ** mPS_2OCTET_TO_HOST: convert 2 octets to host format
+ ** mPS_4OCTET_TO_HOST: convert 4 octets to host format
+ **
+ */
+
+#if (BYTE_ORDER == _BIG_ENDIAN_)
+
+#define mPS_2OCTET_TO_NET(pdest) \
+ (*(pdest))= ((*(pdest))<<8) \
+ | ( ((*(pdest))>>8) & 0x00ff)
+
+#define mPS_4OCTET_TO_NET(pdest) \
+ (*(pdest))= ( ((*(pdest))>>24) & 0x000000ff) \
+ | ((*(pdest))<<24) \
+ | (0x0000ff00 & ((*(pdest)) >> 8)) \
+ | ( 0x00ff0000 & ((*(pdest)) << 8))
+
+#define mPS_2OCTET_TO_HOST mPS_2OCTET_TO_NET
+
+#define mPS_4OCTET_TO_HOST mPS_4OCTET_TO_NET
+
+
+#else /* LITTLE_ENDIAN (this is the chosen network order) */
+
+#define mPS_2OCTET_TO_NET(pdest)
+#define mPS_4OCTET_TO_NET(pdest)
+#define mPS_2OCTET_TO_HOST(pdest)
+#define mPS_4OCTET_TO_HOST(pdest)
+
+#endif /* BIG_ENDIAN */
+
+
+#if (CHAR_SET == _ASCII_CHAR_SET_)
+
+#define mPS_OCTET_TO_HOST( pField, len)
+
+#define mPS_OCTET_TO_NET( pField, len)
+
+#else
+
+XXX not supported
+
+#endif /* CHAR_SET */
+
+
+
+/*
+** prototypes for remaining platform specific services
+*/
+
+
+/* Any platform specific initialization and auxilary functions */
+
+extern tOCTET2 PS_Init (tOCTET2 ioType, tOCTET4 hInst, tOCTET4 hPInst, void *cmdParam,
+ tOCTET2 nCmdShow);
+
+extern tOCTET2 PSWaitForEvent (tpEVENT pEvent, tOCTET4 *p1, tOCTET4 *p2, tOCTET4 *p3,
+ struct timeval *pTimeout);
+
+/* Timer Tic (hearbeat) Service Interface */
+
+
+extern tOCTET2 PS_TimerInit (void (*tickhandler)(tOCTET2 tick_gran));
+extern tOCTET2 PS_TimerTerm (void);
+extern tMSECTIME PS_MsecTime (void);
+extern tSECTIME PS_SecTime (void);
+extern char *PS_GetAscTime (void);
+
+ /*
+ **
+ ** Memory management and other macros defined in
+ ** platform specific include files
+ **
+ */
+
+
+ /*
+ **
+ ** Events
+ **
+ */
+
+extern tEVENT or_timer_event;
+extern tEVENT or_network_event;
+extern tEVENT ij_cr_event;
+extern tEVENT ij_cag_event;
+extern tEVENT ij_db_event;
+
+
+ /*
+ **
+ ** I/O, logging and tracing
+ **
+ */
+
+#ifndef PS_getopt
+extern int PS_getopt (int argc, tOCTET **argv, char *opts);
+#endif
+#ifndef PS_Printf
+extern void PS_Printf (char *lpszFormat);
+#endif
+extern void PS_ErrPrintf ( int errCode, const char *szFormat, ...);
+
+
+ /*
+ **
+ ** data buffer management
+ **
+ */
+
+tOCTET *PS_alloc_buf(tOCTET4 bufsz);
+tOCTET2 PS_Heap_Verify(char *pMem);
+void PS_free_buf(void *pBuf);
+
+
+/* Exit Function */
+
+void PS_AtExit(void (*func) (void));
+void PS_CleanUp(void);
+void PS_kickSched(void);
+
+/* Various status registration functions */
+
+void PS_Reg_Status(void (*func) (void));
+void PS_Reg_Trace(void (*func) (tOCTET2 type, tOCTET2 onOff));
+void PS_Rreg_GetNextServer(char * (*func) (char *server, tOCTET2 *selected));
+void PS_Rreg_SelectServer(tUOCTET2 (*func) (char *server));
+void PS_Reg_MaskFunc(void (*func) (void));
+
+#endif /* _PLATDEF_H */
+
+
+
+
+
+
+
+
+
+
diff --git a/data/mnet/Common/cli/include/pstypes.h b/data/mnet/Common/cli/include/pstypes.h
new file mode 100644
index 0000000..71ad0a2
--- /dev/null
+++ b/data/mnet/Common/cli/include/pstypes.h
@@ -0,0 +1,82 @@
+#ifndef _PSTYPES_H_
+#define _PSTYPES_H_
+
+
+typedef char tOCTET; /* signed octet */
+typedef unsigned char tUOCTET; /* unsigned octet */
+typedef int tINT; /* Integer */
+typedef short tOCTET2; /* signed 2 octets */
+typedef short s_size_t; /* signed size_t */
+typedef unsigned us_size_t; /* unsigned size_t */
+typedef long tOCTET4; /* signed 4 octets */
+typedef unsigned short tUOCTET2; /* unsigned 2 octets */
+typedef unsigned long tUOCTET4; /* unsigned 4 octets */
+typedef FILE tFILE;
+typedef int tTASKID;
+typedef int boolean;
+typedef uint32_t ipaddrtype;
+
+ /*
+ **
+ ** Basic data type pointers
+ **
+ */
+
+typedef char * tpOCTET;
+typedef unsigned char * tpUOCTET;
+typedef short * tpOCTET2;
+typedef long * tpOCTET4;
+typedef unsigned short * tpUOCTET2;
+typedef unsigned long * tpUOCTET4;
+
+/*
+ * libc data types
+ */
+typedef FILE * tpFILE;
+
+/*
+ * kernel data types
+ */
+typedef SEM_ID tSEMAPHORE; /* semaphore */
+typedef SEM_ID tCSEMAPHORE; /* counting semaphore */
+typedef SEM_ID tBSEMAPHORE; /* binary semaphore */
+typedef SEM_ID tMSEMAPHORE; /* mutex semaphore */
+
+/*
+ * missing from vxWorks' Posix types
+ */
+typedef long long int64_t;
+typedef unsigned long long uint64_t;
+
+/*
+ * Cisco IOS compatibility
+ */
+typedef long long longlong;
+typedef unsigned int uint;
+typedef unsigned char uchar;
+typedef unsigned long ulong;
+typedef unsigned long long ulonglong;
+typedef unsigned long long sys_timestamp;
+
+/*
+ * Special values for data types
+ */
+#ifndef NULLP
+#define NULLP ((void *) 0)
+#endif
+
+#ifndef TRUE
+#define TRUE 1
+#endif
+
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+#define PSmalloc(Size) malloc(Size)
+#define PScalloc(Num, Size) calloc(Num,Size)
+#define PSrealloc(Block,Size) realloc(Block,Size)
+#define PSfree(Block) free(Block)
+
+#endif
+
diff --git a/data/mnet/Common/cli/include/psvxif.h b/data/mnet/Common/cli/include/psvxif.h
new file mode 100644
index 0000000..360056e
--- /dev/null
+++ b/data/mnet/Common/cli/include/psvxif.h
@@ -0,0 +1,252 @@
+#ifndef _PSVXIF_H_
+#define _PSVXIF_H_
+
+
+ /*
+ **
+ ** Primitive data types and declarations
+ **
+ */
+
+
+#ifndef CHAR_SET
+#define CHAR_SET _ASCII_CHAR_
+#endif
+
+/*
+ * Borrowed from cdecl.h
+ */
+#if (defined(__STDC__) || defined(__cplusplus)) && !defined(__P)
+#define __P(x) x
+#endif
+
+/*
+ * Set BYTE_ORDER based on cpu family.
+ *
+ * This may need some adjustment if
+ * a cpu can do both byte orders.
+ */
+#ifndef BYTE_ORDER
+
+#if CPU_FAMILY == I80X86
+#define BYTE_ORDER LITTLE_ENDIAN
+
+#elif CPU_FAMILY == SIMNT
+#define BYTE_ORDER LITTLE_ENDIAN
+
+#elif CPU_FAMILY == PPC
+#define BYTE_ORDER BIG_ENDIAN
+
+#else
+#error Unrecognized Platform -- missing BYTE_ORDER
+#endif
+
+#endif /* BYTE_ORDER */
+
+
+/*
+** Make RC_OK and RC_ERROR to match vxworks OK and ERROR
+*/
+
+#ifdef RC_OK
+#undef RC_OK
+#endif
+#define RC_OK OK
+
+#ifdef RC_ERR
+#undef RC_ERR
+#endif
+#define RC_ERR ERROR
+
+#define SIGERR 0xFFFFFFFF
+
+ /*
+ **vxWorks data data types
+ **
+ */
+typedef SEM_B_STATE tSEMBSTAT;
+
+
+
+/*
+ * Task Stack Parameters
+ */
+
+typedef enum {
+ STACK_SIZE = 1,
+ STACK_MARGIN,
+ STACK_CURRENT
+} tSTACKPARAM;
+
+#define KERNEL_PID 1
+#define KERNEL_UID 1
+#define KERNEL_GID 1
+ /*
+ ** List Constant
+ */
+
+#define FIFO_LIST 1
+#define PRIORITY_LIST 2
+#define PROTECTED_LIST PROTECT
+#define UNPROTECTED_LIST NO_PROTECT
+#define BINARY_SEMAPHORE 1
+#define COUNT_SEMAPHORE 2
+#define MUTEX_SEMAPHORE 3
+
+ /*
+ ** vxWorks mutex semphore default flag
+ */
+#define PS_DEFAULT_MUTEX_SEM_FLAG \
+ (SEM_Q_PRIORITY | SEM_DELETE_SAFE | SEM_INVERSION_SAFE)
+#define PS_DEFAULT_BINARY_SEM_FLAG (SEM_Q_PRIORITY)
+#define PS_DEFAULT_COUNT_SEM_FLAG (SEM_Q_PRIORITY)
+#define PS_DEFAULT_BINARY_SEM_STAT (SEM_FULL)
+#define PS_DEFAULT_COUNT_SEM_COUNT 1
+
+
+/*
+ * Basic constants.
+ */
+#define MAXCHAR 0x7F /* largest positive 8-bit signed num */
+#define MAXUCHAR 0xFF /* largest positive 8-bit unsigned */
+#define MAXSHORT 0x7FFF /* largest positive 16-bit number */
+#define MAXUSHORT 0xFFFF /* largest positive 16-bit number */
+#define MAXINT 0x7FFFFFFFL /* largest positive 32-bit number */
+#define MAXUINT 0xFFFFFFFFL /* largest unsigned 32-bit number */
+#define MAXLONG MAXINT /* largest positive 32-bit number */
+#define MAXULONG MAXUINT /* largest unsigned 32-bit number */
+#define MINCHAR 0x80 /* smallest possible signed 8-bit */
+#define MINSHORT 0x8000 /* smallest possible signed 16-bit */
+#define MININT 0x80000000L /* smallest possible signed 32-bit */
+#define MINLONG MININT /* smallest possible signed 32-bit */
+
+
+ /*
+ ** vxWorks generic constants
+ */
+#define SEM_DEFAULT_TIMEOUT WAIT_FOREVER
+#define SEM_TIMEOUT_NOWAIT NO_WAIT
+ /*
+ **
+ ** Other data types
+ **
+ */
+
+#define tPROCID tOCTET4 /* process identifier */
+#define tPROCID tOCTET4 /* process identifier */
+#define tSEMTYPE tOCTET2 /* semaphore type */
+#define tEVENT tUOCTET2 /* event descriptor */
+#define tpEVENT tUOCTET2 * /* event pointer */
+#define tTIMER timer_t /* timer identifier */
+#define tTIME time_t
+#define tSECTIME tUOCTET4 /* time in seconds */
+#define tMSECTIME tUOCTET4 /* time in milliseconds */
+#define PS_TIMER_GRAN ( (tUOCTET4)50000 ) /* 50 msec */
+#define PS_MSECT_GRAN ( (PS_TIMER_GRAN)/( (tUOCTET4)1000 ) )/* gran in msec*/
+#define mMSEC_TO_TICKS(ms) ((ms)*sysClkRateGet()/1000)
+#define SOCKET int
+
+ /*
+ **
+ ** system resource limites
+ **
+ */
+
+#define MIN_SYS_MEM 25600 /* 25k */
+
+ /*
+ **normalized marcos
+ */
+
+#define PS_TASK_ARGS \
+(int a1,int a2,int a3,int a4,int a5,int a6,int a7,int a8,int a9,int a10)
+
+#define PStaskDelay taskDelay
+#define PStaskDelete taskDelete
+#define PStaskSuspend taskSuspend
+#define PStaskResume taskResume
+#define PStaskRestart taskRestart
+#define PStaskIdSelf taskIdSelf
+
+/*semphore stuff*/
+
+#define PSsemBCreate semBCreate
+#define PSsemCCreate semCCreate
+#define PSsemMCreate semMCreate
+#define PSsemGive semGive
+#define PSsemTake semTake
+#define PSsemGiveForce semGiveForce
+#define PSsemDelete semDelete
+#define PSsemInfo semInfo
+#define PSsemFlush semFlush
+
+/* Timer functions */
+
+#define PStimer_cancel timer_cancel
+#define PStimer_connect timer_connect
+#define PStimer_create timer_create
+#define PStimer_delete timer_delete
+#define PStimer_gettime timer_gettime
+#define PStimer_settime timer_settime
+#define PSclock_gettime clock_gettime
+
+#define PSprintf printf
+#define PS_Printf printf
+#define PSfprintf fprintf
+#define PSfopen fopen
+#define PSfclose fclose
+#define PSfputs fputs
+#define PSfgets fgets
+#define PSfscanf fscanf
+#define PSmemset(dest, val, len) memset(dest, val, len)
+#define PSmemcpy(dest, src, len) memcpy(dest, src, len)
+#define PSmemcmp(dest, src, len) memcmp(dest, src, len)
+#define PSmemmove(dest, src, len) memmove(dest, src, len)
+#define PSstrlen(src) strlen(src)
+#define PSstrrchr(dest, pat) strrchr(dest, pat)
+#define PSstrchr strchr
+#define PSstrdup strdup
+#define PSstrcmp(dest, src) strcmp(dest, src)
+#define PSstrncmp(dest, src, len) strncmp(dest, src, len)
+#define PSstrncasecmp(dest, src, len) strncasecmp(dest, src, len)
+#define PSstrstr strstr
+#define PSassert assert
+#define PStoupper toupper
+#define mPSATEXIT atexit
+
+#ifndef MEMCPY_DEBUG
+#define PSsprintf sprintf
+#define PSstrcat(dest, src) strcat(dest, src)
+#define PSstrncat(dest, src, len) strncat(dest, src, len)
+#define PSstrcpy(dest, src) strcpy(dest, src)
+#define PSstrncpy(dest, src, len) strncpy(dest, src, len)
+#endif /* MEMCPY_DEBUG */
+
+#define PSabs(x) ( ((x) < 0) ? -(x) : (x) )
+#define PSmin(x, y) ( ((x) < (y)) ? (x) : (y) )
+#define PSmax(x, y) ( ((x) < (y)) ? (y) : (x) )
+
+
+ /* For FileSystem / HTTPD
+ *
+ */
+
+#define mVOLNAME "/local"
+
+
+/*
+** more macros
+*/
+
+#define PS_MSEC_TO_TICK(sec) ( sec * sysClkRateGet() )
+#define PSabort() {abort_brp(); abort();}
+#define PSexit(i) {exit_brp();exit(i);}
+#define PSpanic(s) panic(s)
+#define mMYHOSTNAME
+
+
+typedef void (tFREEFUNC)(void *);
+typedef void (* tpFREEFUNC)(void *);
+
+#endif /* _PSVXIF_H_ */
+
diff --git a/data/mnet/Common/cli/include/sys_debug.h b/data/mnet/Common/cli/include/sys_debug.h
new file mode 100644
index 0000000..f0183b6
--- /dev/null
+++ b/data/mnet/Common/cli/include/sys_debug.h
@@ -0,0 +1,20 @@
+#ifndef __SYS_DEBUG_H
+#define __SYS_DEBUG_H
+
+typedef void (*DEBUG_ALL_FUNCTION_PTR)(boolean);
+typedef void (*DEBUG_SHOW_FUNCTION_PTR)(void);
+
+typedef struct {
+ NODE debugNode;
+ void *debugFunction;
+ debug_item_type *debug_items;
+ char *heading;
+} tDEBUG_FUNC_NODE;
+
+extern void sys_debug_init(void);
+extern void invoke_debug_all(boolean);
+extern void invoke_debug_show(void);
+extern STATUS add_debug_all(DEBUG_ALL_FUNCTION_PTR, const debug_item_type*);
+extern STATUS add_debug_show(DEBUG_SHOW_FUNCTION_PTR, const debug_item_type*,
+ const char*);
+#endif __SYS_DEBUG_H
diff --git a/data/mnet/Common/cli/include/ttyutil.h b/data/mnet/Common/cli/include/ttyutil.h
new file mode 100644
index 0000000..fc8bb64
--- /dev/null
+++ b/data/mnet/Common/cli/include/ttyutil.h
@@ -0,0 +1,88 @@
+#ifndef __TTYUTIL_H__
+#define __TTYUTIL_H__
+
+
+
+/* Special Characters Mapping */
+#define CH_NULL 0x00
+#define CH_SOH 0x01
+#define CH_STX 0x02
+#define CH_ETX 0x03
+#define CH_EOT 0x04
+#define CH_ENQ 0x05
+#define CH_ACK 0x06
+#define CH_BEL 0x07 /* the bell character */
+#define CH_BS 0x08
+#define CH_HT 0x09
+#define CH_NL 0x0A
+#define CH_VT 0x0B
+#define CH_NP 0x0C
+#define CH_CR 0x0D
+#define CH_SO 0x0E
+#define CH_SI 0x0F
+#define CH_DLE 0x10
+#define CH_DC1 0x11
+#define CH_DC2 0x12
+#define CH_DC3 0x13
+#define CH_DC4 0x14
+#define CH_NAK 0x15
+#define CH_SYN 0x16
+#define CH_ETB 0x17
+#define CH_CAN 0x18
+#define CH_EM 0x19
+#define CH_SUB 0x1A
+#define CH_ESC 0x1B
+#define CH_FS 0x1C
+#define CH_GS 0x1D
+#define CH_RS 0x1E
+#define CH_US 0x1F
+#define CH_SPC 0x20
+#define CH_DEL 0x7F
+
+#define CH_LT_SQ_BRACE 0x5B
+
+#define CH_EXT 0x80
+
+#define CH_CTRL_B 0x02
+#define CH_CTRL_C 0x03
+#define CH_CTRL_F 0x06
+#define CH_CTRL_N 0x0E
+#define CH_CTRL_P 0x10
+#define CH_CTRL_Z 0x1A
+
+typedef enum {
+ PRIMARY_TASK = 1,
+ SECONDARY_TASK
+} tTTYATTR;
+
+
+/*
+ * Primary/Secondary task abstraction
+ * for hierarchical distribution of signals.
+ */
+extern STATUS ttySignalSecondaryTasks(int fd, int signo);
+extern STATUS taskSetTtyAttr(int fd, tTTYATTR type, BOOL value);
+extern BOOL taskGetTtyAttr(int fd, tTTYATTR type);
+
+/*
+ * Manage list of control characters
+ */
+extern STATUS addSignalChar (int ch, int signo);
+extern STATUS removeSignalChar (int signo);
+
+/*
+ * Provides maintenance of per-task signal mask
+ */
+extern void defaultSignalHandler(int signo);
+
+extern STATUS setTaskSignalFlag (int tid, int signo, BOOL enable);
+extern BOOL isTaskSignalSet (int tid, int signo);
+extern uint32_t getTaskSignalMask (int tid);
+extern STATUS setTaskSignalMask (int tid, uint32_t sigMask);
+
+/*
+ * Quick check to see if a signal has been delivered to current task
+ */
+extern BOOL tty_signal(void);
+
+#endif
diff --git a/data/mnet/Common/cli/include/vxworks_cfg_chain.h b/data/mnet/Common/cli/include/vxworks_cfg_chain.h
new file mode 100644
index 0000000..55f8302
--- /dev/null
+++ b/data/mnet/Common/cli/include/vxworks_cfg_chain.h
@@ -0,0 +1,157 @@
+
+
+
+enum{
+ OTHER,
+ STARTUP_SCRIPT,
+ FLAGS,
+ TARGET_NAME,
+ FTP_PASSWD,
+ USER_NAME,
+ GATEWAY_IP,
+ HOST_IP,
+ BACK_IP,
+ ETHER_IP,
+ FILE_NAME,
+ HOST_NAME,
+ PROC_NUM,
+ UNIT_NUM,
+ BOOT_DEV,
+ EXIT_BOOT_MODE
+};
+
+/***********Boot change**********/
+
+EOLS (exec_bootparam_exit_eol,changeBootParams,EXIT_BOOT_MODE);
+KEYWORD (exec_bootparam_exit,exec_bootparam_exit_eol,no_alt,
+ "exit","Exit from boot param mode",PRIV_ROOT);
+
+EOLS (exec_bootparam_other_eol,changeBootParams,OTHER);
+STRING (exec_bootparam_other_string,exec_bootparam_other_eol,no_alt,OBJ(string,1),"Other");
+KEYWORD (exec_bootparam_other,exec_bootparam_other_string,exec_bootparam_exit,
+ "other","Other string used by applications",PRIV_ROOT);
+
+EOLS (exec_bootparam_script_name_eol,changeBootParams,STARTUP_SCRIPT);
+STRING (exec_bootparam_script_name,exec_bootparam_script_name_eol,no_alt,OBJ(string,1),"Script name");
+KEYWORD (exec_bootparam_script,exec_bootparam_script_name,exec_bootparam_other,
+ "startup_script","Start up script name with directory path",PRIV_ROOT);
+
+EOLS (exec_bootparam_flags_eol,changeBootParams,FLAGS);
+NUMBER (exec_bootparam_flags_number,exec_bootparam_flags_eol,no_alt,OBJ(int,1),0,100,"Flags");
+KEYWORD (exec_bootparam_flags,exec_bootparam_flags_number,exec_bootparam_script,
+ "flags","Flags (f)",PRIV_ROOT);
+
+
+EOLS (exec_bootparam_target_eol,changeBootParams,TARGET_NAME);
+STRING (exec_bootparam_target_name,exec_bootparam_target_eol,no_alt,OBJ(string,1),"Name");
+KEYWORD (exec_bootparam_target,exec_bootparam_target_name,exec_bootparam_flags,
+ "target_name","Target name (tn)",PRIV_ROOT);
+
+
+EOLS (exec_bootparam_ftp_passwd_eol,changeBootParams,FTP_PASSWD);
+STRING (exec_bootparam_ftp_passwd,exec_bootparam_ftp_passwd_eol,no_alt,OBJ(string,1),"Password");
+KEYWORD (exec_bootparam_ftp,exec_bootparam_ftp_passwd,exec_bootparam_target,
+ "ftp_password","Ftp password (pw)",PRIV_ROOT);
+
+EOLS (exec_bootparam_user_eol,changeBootParams,USER_NAME);
+STRING (exec_bootparam_user_name,exec_bootparam_user_eol,no_alt,OBJ(string,1),"Name");
+KEYWORD (exec_bootparam_user,exec_bootparam_user_name,exec_bootparam_ftp,
+ "user","User name",PRIV_ROOT);
+
+EOLS (exec_bootparam_gateway_inet_eol,changeBootParams,GATEWAY_IP);
+STRING (exec_bootparam_gateway_inet_ip,exec_bootparam_gateway_inet_eol,no_alt,OBJ(string,1),"Gateway inet (g)");
+KEYWORD (exec_bootparam_gateway_inet,exec_bootparam_gateway_inet_ip,exec_bootparam_user,
+ "gateway_inet","Gateway inet (g)",PRIV_ROOT);
+
+EOLS (exec_bootparam_host_inet_eol,changeBootParams,HOST_IP);
+STRING (exec_bootparam_host_inet_ip,exec_bootparam_host_inet_eol,no_alt,OBJ(string,1),"Host inet (h)");
+KEYWORD (exec_bootparam_host_inet,exec_bootparam_host_inet_ip,exec_bootparam_gateway_inet,
+ "host_inet","Host inet (h)",PRIV_ROOT);
+
+EOLS (exec_bootparam_inet_backplane_eol,changeBootParams,BACK_IP);
+STRING (exec_bootparam_inet_backplane_ip,exec_bootparam_inet_backplane_eol,no_alt,OBJ(string,1),"Inet on backplane (b)");
+KEYWORD (exec_bootparam_inet_backplane,exec_bootparam_inet_backplane_ip,exec_bootparam_host_inet,
+ "inet_on_backplane","Inet on backplane (b)",PRIV_ROOT);
+
+EOLS (exec_bootparam_inet_ethernet_eol,changeBootParams,ETHER_IP);
+STRING (exec_bootparam_inet_ethernet_ip,exec_bootparam_inet_ethernet_eol,no_alt,OBJ(string,1),"Inet on ethernet (e)");
+KEYWORD (exec_bootparam_inet_ethernet,exec_bootparam_inet_ethernet_ip,exec_bootparam_inet_backplane,
+ "inet_on_ethernet","Inet on ethernet (e)",PRIV_ROOT);
+
+EOLS (exec_boot_change_file_eol,changeBootParams,FILE_NAME);
+STRING (exec_bootparam_file_name,exec_boot_change_file_eol,no_alt,OBJ(string,1),"File name");
+KEYWORD (exec_bootparam_file,exec_bootparam_file_name,exec_bootparam_inet_ethernet,
+ "file_name","File name",PRIV_ROOT);
+
+EOLS (exec_boot_change_host_eol,changeBootParams,HOST_NAME);
+STRING (exec_bootparam_host_name,exec_boot_change_host_eol,no_alt,OBJ(string,1),"Host name");
+KEYWORD (exec_bootparam_host,exec_bootparam_host_name,exec_bootparam_file,
+ "host_name","Host name",PRIV_ROOT);
+
+EOLS (exec_boot_change_processor_eol,changeBootParams,PROC_NUM);
+NUMBER (exec_bootparam_processor_number,exec_boot_change_processor_eol,no_alt,OBJ(int,1),0,9,"Precessor number");
+KEYWORD (exec_bootparam_processor,exec_bootparam_processor_number,exec_bootparam_host,
+ "processor_number","Precessor number",PRIV_ROOT);
+
+EOLS (exec_bootparam_unit_eol,changeBootParams,UNIT_NUM);
+NUMBER (exec_bootparam_unit_number,exec_bootparam_unit_eol,no_alt,OBJ(int,1),0,9,"Unit number");
+KEYWORD (exec_bootparam_unit,exec_bootparam_unit_number,exec_bootparam_processor,
+ "unit_number","Unit number",PRIV_ROOT);
+
+EOLS (exec_bootparam_boot_device_eol,changeBootParams,BOOT_DEV);
+STRING (exec_bootparam_boot_device_name,exec_bootparam_boot_device_eol,no_alt,OBJ(string,1),"Device number");
+KEYWORD (exec_boot_change_boot_device,exec_bootparam_boot_device_name,exec_bootparam_unit,
+ "boot_device","Boot device",PRIV_ROOT);
+
+
+/*************** Boot change *********/
+
+/**************** Enable access to vxworks shell***************/
+EOLNS (cfg_vxsh_enable_eol,EnableVxsh);
+NVGENNS (cfg_vxsh_enable_nvgen,cfg_vxsh_enable_eol,EnableVxsh);
+KEYWORD (cfg_vxsh_enable,cfg_vxsh_enable_nvgen,no_alt,
+ "enable","Enable vxworks shell",PRIV_ROOT);
+
+KEYWORD (cfg_vxsh, cfg_vxsh_enable, no_alt,
+ "vxsh", "Enable vxworks shell", PRIV_ROOT | PRIV_HIDDEN);
+/************ Change password for existing user **********/
+EOLNS (cfg_change_passwd_eol,ChangePasswd);
+STRING (cfg_change_passwd_uname,cfg_change_passwd_eol,no_alt,OBJ(string ,1),"User name");
+NVGENNS (cfg_change_passwd_nvgen,cfg_change_passwd_uname,ChangePasswd);
+KEYWORD (cfg_change_passwd, cfg_change_passwd_nvgen, cfg_vxsh,
+ "change-passwd", "Change password for existing user", PRIV_ROOT);
+/******** Change boot parameters*****************/
+
+EOLNS (cfg_boot_change_eol,setBootParamsMode);
+NVGENNS (cfg_boot_change_nvgen,cfg_boot_change_eol,setBootParamsMode);
+KEYWORD (cfg_boot_change,cfg_boot_change_nvgen,cfg_change_passwd,
+ "boot-params","Change the boot parameters ",PRIV_ROOT);
+/******* Enable SSH access ***********/
+EOLNS (cfg_ssh_enable_eol, EnableSsh);
+NVGENNS (cfg_ssh_enable_nvgen,cfg_ssh_enable_eol,EnableSsh);
+KEYWORD (cfg_ssh_enable,cfg_ssh_enable_nvgen,no_alt,
+ "enable","Enable ssh",PRIV_ROOT);
+KEYWORD (cfg_ssh, cfg_ssh_enable, cfg_boot_change,
+ "ssh", "Enable SSH access", PRIV_ROOT );
+
+/******* Enable SSH access ***********/
+EOLNS (cfg_telnet_enable_eol, EnableTelnet);
+NVGENNS (cfg_telnet_enable_nvgen,cfg_telnet_enable_eol,EnableTelnet);
+KEYWORD (cfg_telnet_enable,cfg_telnet_enable_nvgen,no_alt,
+ "enable","Enable telnet",PRIV_ROOT);
+KEYWORD (cfg_telnet, cfg_telnet_enable, cfg_ssh,
+ "telnet", "Enable telnet access", PRIV_ROOT );
+
+
+
+/************* Add new system user ****************/
+
+EOLNS (cfg_user_name_eol, AddNewUser);
+NUMBER (cfg_user_name_level,cfg_user_name_eol,no_alt,OBJ(int,1),0,1,"User level(0 for super user and 1 for normal user,First user must be super user)");
+STRING (cfg_user_name_usrname,cfg_user_name_level,no_alt,OBJ(string,1),"User name");
+NVGENNS (cfg_user_name_usrname_nvgen,cfg_user_name_usrname,AddNewUser);
+KEYWORD (cfg_user_name, cfg_user_name_usrname_nvgen, cfg_telnet,
+ "username", "Add new system user", PRIV_ROOT);
+
+#undef ALTERNATE
+#define ALTERNATE cfg_user_name
diff --git a/data/mnet/Common/cli/include/vxworks_exec_chain.h b/data/mnet/Common/cli/include/vxworks_exec_chain.h
new file mode 100644
index 0000000..d425afd
--- /dev/null
+++ b/data/mnet/Common/cli/include/vxworks_exec_chain.h
@@ -0,0 +1,229 @@
+/************** Definitions ********************/
+#include "../include/macros.h"
+
+
+#define LongList 1
+#define NormalList 2
+extern BOOL vxsh_flag;
+
+ /*************** Definitions *********/
+
+
+keyword_options cli_month_options[] = {
+ {"january", "JANUARY", 1},
+ {"february", "FEBRUARY", 2},
+ {"march", "MARCH", 3},
+ {"april", "APRIL", 4},
+ {"may", "MAY", 5},
+ {"june", "JUNE", 6},
+ {"july", "JULY", 7},
+ {"august", "AUGUST", 8},
+ {"september", "SEPTEMBER", 9},
+ {"october", "OCTOBER", 10},
+ {"november", "NOVEMBER", 11},
+ {"december", "DECEMBER", 12},
+ { NULL, NULL, 0 }
+};
+
+
+keyword_options vxshell_options[]={
+ {"ldvxsh", "Load Vxworks shell",1 },
+ {"unldvxsh","Load Vxworks shell",2},
+ {"vxsh" ,"Invoke vxworks shell",3},
+ {NULL,NULL,0}
+};
+
+/*********************************/
+
+EOLNS(vxsh_command_string_eol,execVxshCommand);
+TEXT(vxsh_command_string,vxsh_command_string_eol,no_alt,OBJ(string,1),"Enter vxworks commands");
+/******************************* vxsh ************/
+EOLNS (exec_vxsh_eol, vxshCommand);
+STRING (exec_vxsh_string, exec_vxsh_eol, no_alt,OBJ(string,1), "file/env variable name");
+KEYWORD_ID (exec_vxsh_env, exec_vxsh_string, exec_vxsh_eol, OBJ(int,2), 2, "env","Environment variable",PRIV_ROOT);
+KEYWORD_ID (exec_vxsh_file, exec_vxsh_string, exec_vxsh_env,OBJ(int,2), 1, "file","File with directory path ", PRIV_ROOT);
+
+KEYWORD_OPTIONS (exec_vxsh, exec_vxsh_file,no_alt, vxshell_options,OBJ(int,1),PRIV_ROOT | PRIV_HIDDEN,0);
+
+ASSERT (exec_vxsh_option,exec_vxsh,no_alt,vxsh_flag);
+
+/******************/
+
+/************************ Load running configurations ****************************/
+EOLNS (exec_load_running_config_eol,loadRunning);
+KEYWORD (exec_load_running_config,exec_load_running_config_eol,exec_vxsh_option,
+ "load-runnning","Load running configurations", PRIV_ROOT);
+
+/************************ Save running configurations ****************************/
+EOLNS (exec_save_running_config_eol,saveRunning);
+KEYWORD (exec_save_running_config,exec_save_running_config_eol,exec_load_running_config,
+ "save-runnning","Save running configurations", PRIV_ROOT);
+
+/****************/
+/*****************/
+EOLNS (exec_print_file_eol,printFile);
+STRING (exec_print_file_name,exec_print_file_eol,no_alt,
+ OBJ(string,1),"Name of the file to be created");
+KEYWORD (exec_print_file,exec_print_file_name,exec_vxsh_option,
+ "print-file","Print the contents a file",PRIV_ROOT | PRIV_HIDDEN);
+
+/*********************/
+EOLNS (exec_create_eol,createFile);
+STRING (exec_create_file_name,exec_create_eol,no_alt,
+ OBJ(string,1),"Name of the file to be created");
+KEYWORD (exec_create_file,exec_create_file_name,exec_print_file,
+ "create-file","Create a file",PRIV_ROOT | PRIV_HIDDEN);
+
+/*************Set system clock ***********/
+EOLNS (cfg_clock_hour_min_secs_day_month_year_eol, ClockSet);
+NUMBER (cfg_clock_hour_min_secs_day_month_year,cfg_clock_hour_min_secs_day_month_year_eol,
+ no_alt,OBJ(int,6),2000,2050,"Year");
+KEYWORD_OPTIONS (cfg_clock_hour_min_secs_day_month, cfg_clock_hour_min_secs_day_month_year,
+ no_alt, cli_month_options, OBJ(int, 5),
+ PRIV_ROOT, 0);
+NUMBER (cfg_clock_hour_min_secs_day,cfg_clock_hour_min_secs_day_month,
+ cfg_clock_hour_min_secs_day_month_year_eol,OBJ(int,4),1,31,"Day of the month");
+NUMBER (cfg_clock_hour_min_secs,cfg_clock_hour_min_secs_day,no_alt,OBJ(int,3),0,59,"Seconds");
+
+NUMBER (cfg_clock_hour_min,cfg_clock_hour_min_secs,no_alt,OBJ(int,2),0,59,"Minutes");
+NUMBER (cfg_clock_hour,cfg_clock_hour_min,no_alt,OBJ(int,1),0,23,"Hour");
+KEYWORD (cfg_clock, cfg_clock_hour, exec_create_file,
+ "set-clock", "Configure clock", PRIV_ROOT);
+
+
+/*************Log out of shell ************/
+EOLNS (exec_logout_eol, Logout);
+KEYWORD (exec_logout, exec_logout_eol, cfg_clock,
+ "logout", "Log out of shell ", PRIV_ROOT | PRIV_HIDDEN);
+
+
+/************** Set an environment variable ***************/
+EOLNS (exec_setenv_eol, SetEnv);
+pdecl(exec_setenv_args_var_id);
+
+FUNC(exec_setenv_AcceptArg,exec_setenv_args_var_id, AcceptArg);
+
+STRING (exec_setenv_args_string,exec_setenv_AcceptArg,no_alt,OBJ(string,2),"String parameter(may be quoted)");
+KEYWORD_ID (exec_setenv_args_string_id, exec_setenv_args_string, exec_setenv_eol , OBJ(int,2), 3,
+ "string", "String parameter", PRIV_ROOT);
+
+STRING (exec_setenv_args_var,exec_setenv_AcceptArg,no_alt,OBJ(string,2),"variable name");
+KEYWORD_ID (exec_setenv_args_var_id, exec_setenv_args_var, exec_setenv_args_string_id, OBJ(int, 2),2,
+ "var", "Var parameter", PRIV_ROOT);
+
+STRING (exec_setenv_varname,exec_setenv_args_var_id,no_alt,OBJ(string,1),"Variable name");
+KEYWORD (exec_setenv, exec_setenv_varname, exec_logout,
+ "setenv", "Set an environment variable", PRIV_ROOT | PRIV_HIDDEN);
+
+/***********Invoke a function***********/
+
+EOLNS (exec_invoke_eol, Invoke);
+pdecl(exec_invoke_args_number_id);
+
+
+FUNC(exec_invoke_AcceptArg,exec_invoke_args_number_id, AcceptArg);
+
+
+STRING (exec_invoke_args_string,exec_invoke_AcceptArg,no_alt,OBJ(string,2),"String parameter(may be quoted)");
+KEYWORD_ID (exec_invoke_args_string_id, exec_invoke_args_string, exec_invoke_eol , OBJ(int,2), 3,
+ "string", "String parameter", PRIV_ROOT);
+
+STRING (exec_invoke_args_var,exec_invoke_AcceptArg,no_alt,OBJ(string,2),"Variable name");
+KEYWORD_ID (exec_invoke_args_var_id, exec_invoke_args_var, exec_invoke_args_string_id, OBJ(int, 2),2,
+ "var", "Variable parameter", PRIV_ROOT);
+
+NUMBER (exec_invoke_args_number,exec_invoke_AcceptArg,no_alt,OBJ(int,1),0,65256,"Int param value");
+KEYWORD_ID (exec_invoke_args_number_id, exec_invoke_args_number, exec_invoke_args_var_id, OBJ(int, 2),1,
+ "int", "Int parameter", PRIV_ROOT);
+
+STRING (exec_invoke_name,exec_invoke_args_number_id,no_alt,OBJ(string,1),"Function name");
+KEYWORD (exec_invoke, exec_invoke_name, exec_setenv,
+ "invoke", "Invoke a function ", PRIV_ROOT | PRIV_HIDDEN);
+
+/************** load an object module into memory ********************/
+EOLNS (exec_loadmodule_name_eol, LoadModule);
+STRING (exec_loadmodule_name,exec_loadmodule_name_eol,no_alt,OBJ(string,1),"Module name with correct directory path");
+KEYWORD (exec_loadmodule, exec_loadmodule_name, exec_invoke,
+ "load", "Load an object module into memory", PRIV_ROOT | PRIV_HIDDEN);
+
+
+/**************** Rename a file *************/
+EOLNS (exec_rename_command_eol, Rename);
+STRING (exec_rename_command_newfilename,exec_rename_command_eol,no_alt,OBJ(string,2),"New file name");
+STRING (exec_rename_command_filename,exec_rename_command_newfilename,no_alt,OBJ(string,1)," File name");
+KEYWORD (exec_rename_command, exec_rename_command_filename, exec_loadmodule,
+ "rename","Rename a file", PRIV_ROOT);
+
+/**************** copy a file *************/
+EOLNS (exec_copy_command_eol, Copy);
+STRING (exec_copy_command_destname,exec_copy_command_eol,no_alt,OBJ(string,2),"Destination file name");
+STRING (exec_copy_command_srcname,exec_copy_command_destname,no_alt,OBJ(string,1),"Source file name");
+KEYWORD (exec_copy_command, exec_copy_command_srcname, exec_rename_command,
+ "copy", "Copy a file", PRIV_ROOT);
+
+/**************** Delete a file *************/
+EOLNS (exec_delete_command_filename_eol, DeleteFile);
+STRING (exec_delete_command_filename,exec_delete_command_filename_eol,no_alt,OBJ(string,1),"Filename");
+KEYWORD (exec_delete_command, exec_delete_command_filename, exec_copy_command,
+ "delete", "Delete a file", PRIV_ROOT);
+
+/**************** Delete a directory *************/
+EOLNS (exec_rmdir_command_eol, RmDir);
+STRING (exec_rmdir_command_dirname,exec_rmdir_command_eol,no_alt,OBJ(string,1),"Directory name");
+KEYWORD (exec_rmdir_command, exec_rmdir_command_dirname, exec_delete_command,
+ "rmdir", "Delete a directory", PRIV_ROOT);
+
+/**************** Make a directory *************/
+EOLNS (exec_mkdir_command_eol, Mkdir);
+STRING (exec_mkdir_command_dirname,exec_mkdir_command_eol,no_alt,OBJ(string,1),"Directory name");
+KEYWORD (exec_mkdir_command, exec_mkdir_command_dirname, exec_rmdir_command,
+ "mkdir", "Make a directory", PRIV_ROOT);
+
+/**************** Reset network devices and transfer control to boot ROMs*************/
+EOLNS (exec_reload_command_eol, Reload);
+
+KEYWORD (exec_reload_command, exec_reload_command_eol, exec_mkdir_command,
+ "reload", "Reset network devices and transfer control to boot ROMs", PRIV_ROOT);
+
+
+/**************** Change directory *************/
+EOLNS (exec_cd_command_eol, ChangeDir);
+STRING (exec_cd_command_dirname,exec_cd_command_eol,no_alt,OBJ(string,1),"Directory name");
+KEYWORD (exec_cd_command, exec_cd_command_dirname, exec_reload_command,
+ "cd", "Change directory", PRIV_ROOT);
+
+
+/**************** List the contents of a directory ************/
+EOLS (exec_dir_command_eol, Dir,NormalList);
+
+EOLS (exec_dir_command_long_eol, Dir,LongList);
+
+KEYWORD (exec_long_list,exec_dir_command_long_eol,exec_dir_command_eol,"detail","Detailed listing of directory contents",PRIV_ROOT);
+STRING (exec_dirname,exec_long_list,exec_dir_command_eol,OBJ(string,1),"Directory name");
+KEYWORD (exec_dir_command, exec_dirname, exec_cd_command,
+ "dir", "List the contents of a directory", PRIV_ROOT);
+
+
+
+
+/*************Print the current default directory****************/
+EOLNS (exec_pwd_command_eol, Pwd);
+KEYWORD (exec_pwd_command, exec_pwd_command_eol, exec_dir_command,
+ "pwd", "Print the current working directory path", PRIV_ROOT);
+
+
+/*********** Test that a remote host is reachable ***********/
+EOLNS (exec_ping_command_eol, Ping);
+STRING(exec_ping_command_ipaddress,exec_ping_command_eol,no_alt,OBJ(string,1),"Ip address of host");
+KEYWORD (exec_test_command, exec_ping_command_ipaddress, exec_pwd_command,
+ "ping", "Test that a remote host is reachable", PRIV_ROOT);
+
+
+#undef ALTERNATE
+#define ALTERNATE exec_test_command
+
+
+
+
+
+
diff --git a/data/mnet/Common/cli/include/vxworks_show_chain.h b/data/mnet/Common/cli/include/vxworks_show_chain.h
new file mode 100644
index 0000000..8950ad7
--- /dev/null
+++ b/data/mnet/Common/cli/include/vxworks_show_chain.h
@@ -0,0 +1,145 @@
+
+
+/*************** definitions ******************/
+#define TASK_ALL 1
+#define TASK_GEN 2
+#define TASK_DETAIL 3
+#define TASK_SUMMARY 4
+#define NAME 5
+#define ALL 6
+#define SUMMARY 7
+#define DETAIL 8
+
+
+
+/******Shows the symbolic name of machine **********/
+EOLNS (show_host_eol,ShowHost);
+KEYWORD (show_host, show_host_eol, no_alt,"hostname", "Shows the symbolic name of machine", PRIV_MIN);
+
+
+/************** Shows environment variable *****************/
+
+EOLNS (show_env_name_eol,ShowEnv);
+STRING (show_env_name,show_env_name_eol,no_alt,OBJ(string,1),"Variable name");
+KEYWORD (show_env, show_env_name, show_host,"env", "Shows environment variable ", PRIV_MIN | PRIV_HIDDEN);
+
+/*****************look up a symbol by name******************/
+
+EOLS (show_symbol_name_eol,Show_Symbol,NAME);
+STRING (show_symbol_name,show_symbol_name_eol,no_alt,
+ OBJ(string,1),"Symbol name");
+KEYWORD (show_symbol, show_symbol_name,show_env,
+ "symbol", "Look up a symbol by name", PRIV_MIN | PRIV_HIDDEN);
+
+
+
+/***************** Shows the current status for loaded modules ******************/
+EOLS (show_module_name_all,Show_Module,ALL);
+
+EOLS (show_module_name_eol,Show_Module,NAME);
+STRING (show_module_name,show_module_name_eol,show_module_name_all,
+ OBJ(string,1),"Module name with correct directory path");
+KEYWORD (show_module, show_module_name,show_symbol,
+ "module", "Shows the current status for loaded modules ", PRIV_MIN);
+
+
+/************* Shows task information from Task control block *********/
+EOLS (show_task_all_eol,Show_Task,TASK_ALL);
+
+EOLS(show_tasks_general,Show_Task,TASK_GEN);
+
+EOLS (show_tasks_detail_eol,Show_Task,TASK_DETAIL);
+KEYWORD (show_tasks_detail,show_tasks_detail_eol,show_tasks_general,
+ "detail","Displays the task details",PRIV_MIN);
+
+EOLS (show_tasks_summary_eol, Show_Task,TASK_SUMMARY);
+KEYWORD (show_tasks_option,show_tasks_summary_eol,show_tasks_detail,
+ "summary","Displays task summary",PRIV_ROOT);
+
+HEXNUM (show_tasks_tid,show_tasks_option,show_task_all_eol,OBJ(int,1),"Task ID");
+KEYWORD (show_tasks, show_tasks_tid,show_module,
+ "task", "Shows task information from Task control block ", PRIV_MIN);
+
+
+/************* Shows a stack trace of a task *********/
+EOLNS (show_stack_trace_eol, Show_Stack_Trace);
+HEXNUM (show_stack_trace_tid,show_stack_trace_eol,no_alt,OBJ(int,1),"Task ID");
+KEYWORD (show_stack_trace, show_stack_trace_tid,show_tasks,
+ "stack", " Shows a stack trace of a task ", PRIV_MIN);
+
+
+/************* Shows list of system drivers *********/
+EOLNS (show_drivers_eol, Show_Drivers);
+KEYWORD (show_drivers, show_drivers_eol,show_stack_trace,
+ "drivers", " Shows list of system drivers", PRIV_MIN);
+
+/********Shows the list of devices in the system ****************/
+
+EOLNS (show_devices_eol, Show_Devices);
+KEYWORD (show_devices, show_devices_eol,show_drivers,
+ "devices", "Displays devices", PRIV_MIN);
+
+/************** Shows list of file descriptor names in the system**************/
+EOLNS (show_fd_eol, Show_Fd);
+KEYWORD (show_fd, show_fd_eol, show_devices,
+ "fd", "Shows list of file descriptor names in the system", PRIV_MIN);
+
+
+
+/************** Show ip **************/
+EOLNS (show_ip_route_eol,Show_ip_Route);
+KEYWORD (show_ip_route, show_ip_route_eol,no_alt,
+ "route", "Displays ip route", PRIV_MIN);
+
+EOLNS (show_ip_traffic_eol,Show_ip_Traffic);
+KEYWORD (show_ip_traffic, show_ip_traffic_eol, show_ip_route,
+ "traffic", "Displays ip traffic", PRIV_MIN);
+
+
+KEYWORD (show_ip, show_ip_traffic, show_fd,
+ "ip", "Shows ip route / traffic", PRIV_MIN);
+
+
+/************** Shows the attached network interfaces **************/
+EOLNS (show_interfaces_eol, Show_Interfaces);
+KEYWORD (show_interfaces, show_interfaces_eol, show_ip,
+ "interfaces", "Shows list of gp10 interfaces", PRIV_MIN);
+
+
+/************** Show users **************/
+EOLNS (show_users_eol, Show_Users);
+KEYWORD (show_users, show_users_eol, show_interfaces,
+ "users", "Shows list of system users", PRIV_MIN | PRIV_HIDDEN);
+
+
+/************** Show arp **************/
+EOLNS (show_arp_eol, Show_Arp);
+
+KEYWORD (show_arp, show_arp_eol, show_users,
+ "arp", "Shows entries in the system ARP table", PRIV_MIN);
+
+
+/******************* Show Clock ***************/
+EOLNS (show_clock_eol, Show_Clock);
+
+KEYWORD (show_clock, show_clock_eol, show_arp,
+ "clock", "Shows system clock", PRIV_MIN);
+
+
+
+/******************* Show memory ***************/
+EOLS (show_memory_detail_eols, Show_Memory,DETAIL);
+EOLS (show_memory_summary_eols,Show_Memory,SUMMARY);
+KEYWORD (show_memory_detail ,show_memory_detail_eols,no_alt,
+ "detail", "Shows system memory in detail", PRIV_MIN);
+KEYWORD (show_memory_summary,show_memory_summary_eols,show_memory_detail,
+ "summary", "Shows summary of system memory", PRIV_MIN);
+KEYWORD (show_memory, show_memory_summary, show_clock,
+ "memory", "Shows system memory partition blocks and statistics", PRIV_MIN);
+
+
+
+
+
+#undef ALTERNATE
+#define ALTERNATE show_memory
diff --git a/data/mnet/Common/cli/src/Makefile b/data/mnet/Common/cli/src/Makefile
new file mode 100644
index 0000000..32d915e
--- /dev/null
+++ b/data/mnet/Common/cli/src/Makefile
@@ -0,0 +1,63 @@
+##########################################################
+#
+# (c) Copyright Cisco 2000
+# All Rights Reserved
+#
+# Use Examples:
+#
+# Case 1:
+# make all VOB=GP10 -
+# Places .out in VOB/bin directory
+#
+# Case 2:
+# make all VOB=GP10 APPDIR=Host\<Application Name>\<Source Directory> -
+# Places .o file(s) in VOB\$(APPDIR)\bin directory.
+#
+# <Application Name> = Name of Application directory
+# <Source Directory> = application sub directory where the calling
+# Makefile resides.
+#
+# Example: make all VOB=GP10 APPDIR=Host\vxTemplate\src
+#
+#
+# Note: This make file must reference a VOB that
+# has a defs.mk in the top level directory.
+#
+##########################################################
+
+# TOP_OF_VOB must be defined before including l3defs.mk
+TOP_OF_VOB = ..\..
+
+# Name of this App's Directory
+THIS_APP_DIR = cli
+
+VOB2DIR = $(TOP_OF_VOB)\..\$(VOB)
+BINDIR = ..\bin
+
+ifeq ($(APPDIR),)
+ MY_OUTPUT = $(VOB2DIR)\bin\cli_com.out
+else
+ MY_OUTPUT = $(OBJDIR)\snmp_com.out
+endif
+
+
+include $(VOB2DIR)\l3defs.mk
+
+CC_INCLUDE += -I$(VOB2DIR)\Host
+
+all: $(MY_OUTPUT)
+
+$(MY_OUTPUT): $(MODULE_OBJS)
+ $(LD) -r -o $@.tmp $(MODULE_OBJS)
+ $(NM) $@.tmp | munch > _ctdt.c
+ $(CC) -traditional $(CC_ARCH_SPEC) -c _ctdt.c
+ $(LD) -r -o $@ _ctdt.o $@.tmp
+ $(RM)$(subst /,$(DIRCHAR), _ctdt.c _ctdt.o $@.tmp)
+
+cleanall:
+ @for %f in ($(notdir $(MODULE_OBJS))) do \
+ $(RM) ..\bin\%f
+
+ $(RM) $(MY_OUTPUT)
+
+
diff --git a/data/mnet/Common/cli/src/basic_exec_chain.c b/data/mnet/Common/cli/src/basic_exec_chain.c
new file mode 100644
index 0000000..a3da367
--- /dev/null
+++ b/data/mnet/Common/cli/src/basic_exec_chain.c
@@ -0,0 +1,733 @@
+
+
+#include <vxworks.h>
+#include <stdioLib.h>
+#include <stdio.h>
+#include <tyLib.h>
+#include <taskLib.h>
+#include <errnoLib.h>
+#include <lstLib.h>
+#include <inetLib.h> /* for INET_ADDR_LEN */
+#include <timers.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <msgQLib.h>
+#include <sigLib.h>
+#include <usrLib.h>
+#include <rebootLib.h>
+#include <pingLib.h>
+#include <symLib.h>
+#include <dirent.h>
+#include <stat.h>
+
+
+#include <../include/cli_parser_private.h>
+#include <../include/pstypes.h>
+#include <../include/psvxif.h>
+#include <../include/imsg.h>
+#include <../include/imc.h>
+#include <../include/address.h>
+#include <../include/parsertypes.h>
+#include <../include/config.h>
+#include <../include/parser_sim.h>
+#include <../include/parser.h>
+#include <../include/parser_defs_exec.h>
+#include <../include/parser_input.h>
+#include <../include/parser_sim.h>
+#include <../include/parser_util.h>
+#include <../include/parser_commands.h>
+#include <../include/nv.h>
+#include <../include/parser_errno.h>
+#include <../include/parser_ModNum.h>
+#include <../include/defs.h>
+#include <../include/parser_init.h>
+#include <../include/macros.h>
+#include <../include/parser_actions.h>
+
+#define maxMessages 100
+BOOL ServerBreak;
+BOOL vxsh_flag=FALSE;
+BOOL load_running_config=FALSE;
+int backInFd;
+extern boolean doneAuth;
+
+/* Global Variables */
+
+static int num_of_args; /* To keep track of number of arguments entered by the user */
+
+
+#define ALTERNATE NONE
+#include "../include/vxworks_exec_chain.h"
+LINK_POINT(basic_exec_command, ALTERNATE);
+#undef ALTERNATE
+
+
+
+
+static parser_extension_request exec_chain_init_table[] = {
+ {PARSE_ADD_EXEC_CMD, &pname(basic_exec_command)},
+ {PARSE_ADD_VXSH_CHAIN, &pname(vxsh_command_string)},
+ {PARSE_LIST_END, NULL}
+};
+
+void init_vxsh_submode (void)
+{
+ parser_add_mode("vxsh", "vxsh",
+ "VXworks shell", TRUE, TRUE, "configure",
+ NULL, NULL, &pname(vxsh_command_string),NULL);
+}
+
+void ExecParserInit(void)
+{
+ parser_add_command_list(exec_chain_init_table, "basic exec commands");
+ init_vxsh_submode();
+
+}
+
+
+/**************************** Call back functions ***********************/
+
+/*** Test that a remote host is reachable ***/
+void Ping(parseinfo *csb){
+ ping(GETOBJ(string,1),1,0);
+}
+
+/****Print the current default directory ***/
+void Pwd(parseinfo *csb){
+ char buffer[512];
+ pwd();
+
+}
+/**** List the contents of a directory ***/
+void Dir(parseinfo *csb){
+
+ switch(csb->which){
+ case LongList:
+ if(strlen(GETOBJ(string,1)))
+ ls(GETOBJ(string,1),1);
+ else
+ ls(0,1);
+ break;
+ case NormalList:
+ if(strlen(GETOBJ(string,1)))
+ ls(GETOBJ(string,1),0);
+ else
+ ls(0,0);
+ break;
+ }
+
+}
+
+/*********** Change directory ********/
+void ChangeDir(parseinfo *csb){
+ struct stat fileStat;
+
+ stat (GETOBJ(string,1), &fileStat);
+ if (!S_ISDIR (fileStat.st_mode)){
+ printf ("%s No such directory exists\n", GETOBJ(string,1));
+ return;
+ }else
+ cd(GETOBJ(string,1));
+
+}
+
+/**** Make a directory **************/
+void Mkdir(parseinfo *csb){
+ mkdir(GETOBJ(string,1));
+}
+
+/**Reset network devices and transfer control to boot ROMs **/
+void Reload(parseinfo *csb){
+ char c;
+ printf("Do you want to reboot the system : [yes/no] ");
+ read(STD_IN,&c,1);
+ write(STD_OUT,"\n",1);
+ if(c!='y')
+ return;
+ else
+ write(STD_OUT,"System is rebooting\n",strlen("\nSystem is rebooting\n"));
+ taskDelay (sysClkRateGet ()*2);
+ reboot(0x04);
+}
+
+
+/**** Delete a directory ****/
+void RmDir(parseinfo *csb){
+ struct stat fileStat;
+
+ stat (GETOBJ(string,1), &fileStat);
+ if (!S_ISDIR (fileStat.st_mode)){
+ printf ("%s No such directory exists\n", GETOBJ(string,1));
+ return;
+ }
+ if(rmdir(GETOBJ(string,1)))
+ printf("\nDirectory is not empty .Could not be deleted\n");
+
+}
+
+/******* Delete a file ******/
+void DeleteFile(parseinfo *csb){
+ struct stat fileStat;
+
+ stat (GETOBJ(string,1), &fileStat);
+ if (S_ISDIR (fileStat.st_mode)){
+ printf ("%s is not a file\n", GETOBJ(string,1));
+ return;
+ }
+ if(rm(GETOBJ(string,1)))
+ printf("\nFile could not be deleted\n");
+
+}
+
+/******** copy a file *****/
+void Copy(parseinfo *csb) {
+ copy(GETOBJ(string,1),GETOBJ(string,2));
+}
+
+/****** Rename a file *******/
+void Rename(parseinfo *csb){
+ copy(GETOBJ(string,1),GETOBJ(string,2));
+ rm(GETOBJ(string,1));
+}
+
+/*** load an object module into memory ***/
+void LoadModule(parseinfo *csb){
+ ld(0,0,GETOBJ(string,1));
+
+}
+
+
+
+struct {
+ int type;
+ union {
+ int i;
+ char s[256];
+ }value;
+} argv[3];
+
+
+/*********** Invoke a function ***********/
+extern void *sysSymTbl;
+
+void Invoke(parseinfo *csb){
+
+ int (*f)();
+ char command[256];
+ SYM_TYPE type;
+ STATUS s;
+ f=0;
+
+#ifdef MNET_GP10
+ strcpy(command,GETOBJ(string,1));
+
+#else
+ strcpy(command,"_");
+ strcat(command,GETOBJ(string,1));
+#endif
+
+
+
+ s= symFindByName(sysSymTbl, command, (char **) &f, &type);
+ if((s == OK) && (f!=0) ){
+ switch(num_of_args)
+ {
+ case 0: (*f)(); break;
+ case 1:{
+
+ if(argv[0].type==0)(*f)(argv[0].value.i);
+ else (*f)(argv[0].value.s);
+ break;
+ }
+ case 2:{
+ switch(2*argv[0].type+argv[1].type){
+ case 0:(*f)(argv[0].value.i, argv[1].value.i); break;
+ case 1:(*f)(argv[0].value.i, argv[1].value.s); break;
+ case 2:(*f)(argv[0].value.s, argv[1].value.i); break;
+ case 3:(*f)(argv[0].value.s, argv[1].value.s); break;
+ }
+ break;
+ }
+ case 3:{
+ switch((4*argv[0].type+2*argv[1].type+argv[2].type)){
+ case 0:(*f)(argv[0].value.i, argv[1].value.i, argv[2].value.i); break;
+ case 1:(*f)(argv[0].value.i, argv[1].value.i, argv[2].value.s); break;
+ case 2:(*f)(argv[0].value.i, argv[1].value.s, argv[2].value.i); break;
+ case 3:(*f)(argv[0].value.i, argv[1].value.s, argv[2].value.s); break;
+ case 4:(*f)(argv[0].value.s, argv[1].value.i, argv[2].value.i); break;
+ case 5:(*f)(argv[0].value.s, argv[1].value.i, argv[2].value.s); break;
+ case 6:(*f)(argv[0].value.s, argv[1].value.s, argv[2].value.i); break;
+ case 7:(*f)(argv[0].value.s, argv[1].value.s, argv[2].value.s); break;
+ }
+ break;
+ }
+ default:printf("\nargc = %d\n",num_of_args); printf(" can not invoke functions with more parameters\n");
+ }
+ }else
+ printf("\nsymbol could not be found\n");
+ num_of_args=0;
+ return;
+}
+
+/************* Function to accept parameters from command line *********/
+void AcceptArg(parseinfo *csb){
+
+
+ if(num_of_args < 3) {
+ switch(GETOBJ(int,2))
+ {
+ case 1: {
+
+ argv[num_of_args].type=0;
+ argv[num_of_args].value.i= GETOBJ(int,1);
+ break;
+ }
+ case 2: {
+
+ argv[num_of_args].type=1;
+ strcpy((char *)argv[num_of_args].value.s, getenv(GETOBJ(string,2)));
+ break;
+ }
+ case 3: {
+
+ argv[num_of_args].type=1;
+ strcpy((char *)argv[num_of_args].value.s,(char*)GETOBJ(string,2));
+ break;
+ }
+ default :
+ printf(" unknown param\n");
+ }
+ num_of_args++;
+
+ }
+}
+
+
+
+/******** Set an environment variable *****/
+void SetEnv(parseinfo *csb){
+
+ char variable[1024];
+ int i;
+
+ strcpy(variable,GETOBJ(string,1));
+ strcat(variable,"=");
+ for(i=0;i<num_of_args;i++)
+ strcat(variable, argv[i].value.s);
+
+ num_of_args=0;
+
+ putenv(variable);
+
+}
+
+
+
+
+/***** Log out of shell ****/
+void Logout(parseinfo *csb){
+
+ if(ShellTask==ConsoleTask){
+ doneAuth = FALSE;
+ return;
+ }
+ if (ShellTask==TelnetTask || ShellTask == SSHTask)
+ ServerBreak=TRUE;
+ if(cli_logoutf)
+ (*cli_logoutf)(cli_logVar);
+ else
+ printf("\nLogout routine could not be found\n");
+}
+void logoutTask(void){
+
+ if(cli_logoutf)
+ (*cli_logoutf)(cli_logVar);
+
+}
+int shellTerminateCurrentSession(void){
+ int retVal=1;
+
+ if( ShellTask == ConsoleTask ){
+ doneAuth = FALSE;
+ return 0;
+ }
+ if ( ShellTask == TelnetTask || ShellTask == SSHTask){
+ ServerBreak=TRUE;
+
+ if(taskSpawn("tlogoutTask", 150, 0, 10000,(FUNCPTR)logoutTask,0,0,0,0,0,0,0,0,0,0)==ERROR)
+ retVal=1;
+ else
+ retVal=0;
+
+ }
+
+ do
+ taskDelay (sysClkRateGet ());
+ while (taskNameToId ("tlogoutTask") != ERROR);
+
+
+ return retVal;
+}
+
+
+#ifdef MNET_GMC
+ extern void rtc_write( const struct tm *);
+#endif
+
+/********* Clock set *********/
+void ClockSet(parseinfo *csb){
+
+ struct timespec tp;
+ char timeBuffer[128];
+
+ struct tm cli_gmtime;
+ clock_gettime(CLOCK_REALTIME,&tp);
+
+ if(gmtime_r( &(tp.tv_sec),&cli_gmtime )!=OK){
+ printf("\nCould not get the time\n");
+ return;
+ }
+ cli_gmtime.tm_hour=GETOBJ(int,1);
+ cli_gmtime.tm_min=GETOBJ(int,2);
+ cli_gmtime.tm_sec=GETOBJ(int,3);
+ if(GETOBJ(int,4)!=0){
+ cli_gmtime.tm_mday=GETOBJ(int,4);
+ cli_gmtime.tm_mon=GETOBJ(int,5)-1;
+ cli_gmtime.tm_year=GETOBJ(int,6)-1900;
+ cli_gmtime.tm_isdst=0;
+ }
+
+#ifdef MNET_GMC
+ rtc_write(&cli_gmtime);
+#endif
+
+ tp.tv_sec=mktime(&cli_gmtime);
+ tp.tv_nsec=0;
+ clock_settime(CLOCK_REALTIME,&tp);
+
+
+}
+
+extern FUNCPTR cli_logoutf;
+extern int cli_logVar;
+
+
+
+/*******************************/
+int vxpipe;
+int ptydev_m;
+MSG_Q_ID vxshQueueID;
+int workerTaskID;
+
+
+int readLine(int inFd,char* buffer){
+ char c;
+ int ret,i=0;
+ while(1){
+ ret = read(inFd, &c, 1);
+ if ( ret != 1 ) {buffer[i]='\0';return -1;}
+
+ if(c == '\n') { buffer[i]='\0'; return i; }
+ buffer[i++]=c;
+ }
+}
+void workTask(void){
+ char msg[PARSEBUF];
+ int msgLen;
+ STATUS (*myExecute)(char *);
+
+ myExecute=(FUNCPTR)shellGetVxExecute();
+
+ while(1){
+ msgLen = msgQReceive(vxshQueueID,msg,PARSEBUF, WAIT_FOREVER );
+ if(strlen(msg)!=0){
+ if(strcmp(msg,"exit")==0){
+ msgQDelete (vxshQueueID);
+ return;
+ }
+ msg[msgLen]=0;
+ (*myExecute)(msg);
+ }
+ }
+
+}
+void createWorkerTask(void){
+
+ vxshQueueID = msgQCreate( maxMessages, PARSEBUF, MSG_Q_FIFO);
+ if ( vxshQueueID == NULL ) {
+ printf("Cannot create callback message queue for vxshell\n");
+ return;
+ }
+ workerTaskID=taskSpawn("vxshWorkerTask",140, PARSER_TASK_OPTION, PARSER_TASK_STACK_SIZE,
+ (FUNCPTR)workTask, 0,0,0,0,0,0,0,0,0,0);
+
+}
+
+void cleanupWorkerTask(void){
+ if((workerTaskID=taskNameToId ("vxshWorkerTask") )!= ERROR){
+ taskDelete(workerTaskID);
+ }
+ msgQDelete (vxshQueueID);
+}
+
+void execVxShellScript
+ (
+ char *fileName
+ )
+ {
+ int old;
+ int newStdIn;
+ char command[PARSEBUF];
+ BOOL ret=FALSE;
+
+ newStdIn = open (fileName, O_RDONLY, 0);
+ if(newStdIn <0){
+ printf("\nCould not execute the script\n");
+ return;
+ }
+ createWorkerTask();
+ command[0]=0;
+ ret=readLine( newStdIn,command);
+ while( ret != -1 && strcmp(command,"exit") ){
+ if(strlen(command)!=0)
+ if(msgQSend(vxshQueueID,command,strlen(command),WAIT_FOREVER, MSG_PRI_NORMAL)==ERROR){
+ printf("\n Command could not be sent to the queue\n");
+ cleanupWorkerTask();
+ return;
+ }
+ command[0]=0;
+ ret=readLine( newStdIn,command);
+
+ }
+ msgQSend(vxshQueueID,"exit",strlen("exit"),WAIT_FOREVER, MSG_PRI_NORMAL);
+ close(newStdIn);
+
+ }
+
+
+
+void vxshCommand(parseinfo *csb){
+ int ret=-1;
+ int oldTaskInFd,oldTaskOutFd,oldGlobalInFd,oldGlobalOutFd;
+ switch(GETOBJ(int,1)){
+
+ case 1 : /*load vxshell */
+ if(!GETOBJ(int,2)){
+ printf("\nCould not load vxworks shell\n");
+ break;
+ }
+ if(GETOBJ(int,2)==1)
+ ret=shellLoadVxShell(GETOBJ(string,1));
+ else if(GETOBJ(int,2)==2)
+ ret=shellLoadVxShell(getenv(GETOBJ(string,1)));
+
+ if(!ret)
+ printf("\nCould not load vxworks shell\n");
+ else
+ installedVxShell=1;
+
+ break;
+
+ case 2 : /* unolad vxshell */
+ installedVxShell=0;
+ break;
+
+ case 3 : /* vxshell */
+
+ if(!isInstalledVxShell()){
+ printf("Vx Shell not installed\n");
+ return;
+ }
+ if(!vxsh_flag){
+ return;
+ }
+
+ if(GETOBJ(int,2)==NULL){
+ createWorkerTask();
+ set_mode_byname(&csb->mode,"vxsh",MODE_VERBOSE);
+ break;
+ }
+
+ oldGlobalOutFd = ioGlobalStdGet(STD_OUT);
+ oldGlobalInFd = ioGlobalStdGet(STD_IN);
+ oldTaskOutFd = ioTaskStdGet(0,STD_OUT);
+ oldTaskInFd = ioTaskStdGet(0,STD_IN);
+
+ if(GETOBJ(int,2)==1)
+ execVxShellScript(GETOBJ(string,1));
+ else
+ execVxShellScript(getenv(GETOBJ(string,1)));
+
+ do
+ taskDelay (sysClkRateGet ());
+ while (taskNameToId ("vxshWorkerTask") != ERROR);
+
+ ioGlobalStdSet(STD_OUT,oldGlobalOutFd);
+ ioGlobalStdSet(STD_IN,oldGlobalInFd);
+ ioTaskStdSet(0,STD_OUT,oldTaskOutFd);
+ ioTaskStdSet(0,STD_IN,oldTaskInFd);
+
+
+ break;
+ }
+}
+void execVxshCommand(parseinfo *csb){
+ int msgLen;
+ BOOL ret=FALSE;
+ STATUS (*myExecute)(char *);
+
+ myExecute=(FUNCPTR)shellGetVxExecute();
+
+ if(!GETOBJ(string,1)){
+ printf("\nCommand input error\n");
+ return;
+ }
+ if((msgLen=strlen(GETOBJ(string,1)))==0)
+ return;
+
+ if(strcmp(GETOBJ(string,1),"exit")==0){
+ cleanupWorkerTask();
+ csb->mode = exec_mode;
+ return;
+ }
+
+ if(msgQSend(vxshQueueID,GETOBJ(string,1),msgLen,WAIT_FOREVER, MSG_PRI_NORMAL)==ERROR){
+ printf("\n Command could not be sent to the queue\n");
+ return;
+ }
+
+}
+
+void createFile(parseinfo *csb){
+
+ struct stat fileStat;
+ char c;
+ BOOL create_flag=FALSE;
+
+ if(stat (GETOBJ(string,1), &fileStat)==ERROR){
+ create_flag=TRUE;
+ }else{
+ if (S_ISDIR (fileStat.st_mode))
+ create_flag=TRUE;
+ }
+
+ if(!create_flag){
+ printf("This file already exists.Do you want to overwrite [yes/no] ");
+ read(STD_IN,&c,1);
+ write(STD_OUT,"\n",1);
+ if(c!='y')
+ return;
+ }
+
+ if(GETOBJ(string,1)){
+ if(creat(GETOBJ(string,1),O_RDWR) == ERROR)
+ printf("\n File %s could not be created\n",GETOBJ(string,1));
+ else
+ printf("\n File %s created\n",GETOBJ(string,1));
+
+ }
+
+}
+
+void printFile(parseinfo *csb){
+
+ char c;
+ int ret,i=0;
+ int fileFd;
+
+ if(GETOBJ(string,1) == NULL){
+ printf("\n File could not be opend\n");
+ return;
+ }
+
+ fileFd = open(GETOBJ(string,1), O_RDONLY,0);
+ if(fileFd == -1){
+ printf("\n File %s could not be opend\n",GETOBJ(string,1));
+ return;
+ }
+
+ while(1){
+ ret = read(fileFd, &c, 1);
+ if ( ret <= 0 ) return;
+ write(STD_OUT,&c,1);
+ }
+
+
+
+}
+
+/******** Load and save configuration ************/
+
+void saveRunning (parseinfo *csb)
+{
+ parseinfo *nvcsb;
+ char filePath[128];
+ int fileFd,backTaskFd,backGlobalFd;
+
+#ifdef MNET_GP10
+ strcpy(filePath,getenv("VIPERCALL_BASE"));
+#else
+ strcpy(filePath,getenv("MNET_BASE"));
+#endif
+ printf("\n %s\n",filePath);
+ strcat(filePath,"/vx/configfile");
+ printf("\n %s\n",filePath);
+
+ fileFd = open (filePath, O_WRONLY | O_CREAT, 0644);
+ if (fileFd == -1)
+ {
+ printf("\n Could not open the file \n");
+ return;
+ }
+
+ nvcsb = get_csb("NV parser CSB");
+ if (csb == NULL) {
+ printf(nomemory);
+ return;
+ }
+ printf("\nBuilding configuration...\n");
+ nvcsb->nvgen = TRUE;
+ nvcsb->sense = TRUE;
+
+
+
+ backTaskFd = ioTaskStdGet (0,STD_OUT);
+ backGlobalFd = ioGlobalStdGet(STD_OUT);
+
+ ioGlobalStdSet(STD_OUT,fileFd);
+ ioTaskStdSet (0,STD_OUT,fileFd);
+
+ nvcsb->priv = PRIV_MAX;
+ nvcsb->priv_set = 0xf;
+ nvcsb->mode = config_mode;
+ push_node(nvcsb, get_mode_nv(nvcsb));
+ parse_token(nvcsb);
+ free_csb(&nvcsb);
+
+ ioGlobalStdSet(STD_OUT,backGlobalFd);
+ ioTaskStdSet (0,STD_OUT,backTaskFd);
+ close(fileFd);
+ }
+void loadRunning( parseinfo *csb ){
+ int fileFd;
+ char filePath[128];
+
+
+#ifdef MNET_GP10
+ strcpy(filePath,getenv("VIPERCALL_BASE"));
+#else
+ strcpy(filePath,getenv("MNET_BASE"));
+#endif
+ strcat(filePath,"/vx/configfile");
+
+ if((fileFd = open (filePath, O_RDONLY,0644))==-1){
+ printf("\nConfig file could not be opend\n");
+ return;
+ }
+ backInFd= csb->inFd;
+ csb->inFd=fileFd;
+ csb->mode=config_mode;
+ load_running_config=TRUE;
+
+}
diff --git a/data/mnet/Common/cli/src/cfg_chain.c b/data/mnet/Common/cli/src/cfg_chain.c
new file mode 100644
index 0000000..6106ce6
--- /dev/null
+++ b/data/mnet/Common/cli/src/cfg_chain.c
@@ -0,0 +1,360 @@
+
+#include <vxworks.h>
+#include <stdioLib.h>
+#include <tyLib.h>
+#include <taskLib.h>
+#include <errnoLib.h>
+#include <lstLib.h>
+#include <inetLib.h> /* for INET_ADDR_LEN */
+#include <timers.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <msgQLib.h>
+#include <sigLib.h>
+#include <usrLib.h>
+#include <bootLib.h>
+
+#include <../include/cli_parser_private.h>
+#include <../include/pstypes.h>
+#include <../include/psvxif.h>
+#include <../include/imsg.h>
+#include <../include/imc.h>
+#include <../include/address.h>
+#include <../include/parsertypes.h>
+#include <../include/config.h>
+#include <../include/parser_sim.h>
+#include <../include/parser.h>
+#include <../include/parser_defs_exec.h>
+#include <../include/parser_input.h>
+#include <../include/parser_sim.h>
+#include <../include/parser_util.h>
+#include <../include/parser_commands.h>
+#include <../include/nv.h>
+#include <../include/parser_errno.h>
+#include <../include/parser_ModNum.h>
+#include <../include/defs.h>
+#include <../include/parser_init.h>
+#include <../include/macros.h>
+#include <../include/parser_actions.h>
+
+
+#ifdef MNET_GP10
+#define BOOT_LINE_OFFSET 0x4200
+#else
+#define BOOT_LINE_OFFSET 0x1200
+#endif
+
+#define LOCAL_MEM_LOCAL_ADRS 0x00000000
+#define BOOT_LINE_ADRS ((char *) (LOCAL_MEM_LOCAL_ADRS+BOOT_LINE_OFFSET))
+
+static BOOT_PARAMS pBootParams;
+
+
+
+extern void ShowParserInit(void);
+extern void ExecParserInit(void);
+int sysUserGetUserLevelByName (char*);
+extern char current_user[];
+
+
+#define ALTERNATE NONE
+#include "../include/vxworks_cfg_chain.h"
+LINK_POINT(basic_cfg_command, ALTERNATE);
+#undef ALTERNATE
+
+
+static parser_mode *config_boot;
+static parser_extension_request basic_chain_init_table[] = {
+ {PARSE_ADD_CFG_TOP_CMD, &pname(basic_cfg_command)},
+ {PARSE_ADD_BOOT_PARAM, &pname(exec_boot_change_boot_device)},
+ {PARSE_LIST_END, NULL}
+};
+
+static void cli_submode_nvgen (parseinfo *csb,parser_mode *mode)
+{
+ parseinfo *nvcsb;
+
+ nvcsb = get_csb("NV parser CSB");
+ if (csb == NULL) {
+ printf(nomemory);
+ return;
+ }
+ nvcsb->nvgen = TRUE;
+ nvcsb->sense = TRUE;
+ nvcsb->priv = PRIV_MAX;
+ nvcsb->priv_set = 0xf;
+ nvcsb->mode = mode;
+ push_node(nvcsb, get_mode_nv(nvcsb));
+ parse_token(nvcsb);
+ free_csb(&nvcsb);
+}
+
+void init_boot_submode (void)
+{
+ config_boot=parser_add_mode("boot-params", "boot-params",
+ "boot Parameters", TRUE, TRUE, "configure",
+ NULL, NULL, &pname(exec_boot_change_boot_device),NULL);
+
+}
+
+
+extern void init_boot_submode(void);
+void BasicParserInit(void)
+{
+ parser_add_command_list(basic_chain_init_table, "basic commands");
+ ShowParserInit();
+ ExecParserInit();
+ init_boot_submode();
+
+}
+
+/********* Call back functions ****************/
+
+
+
+/******** Set host name ***************/
+void HostName(parseinfo *csb){
+ sethostname(GETOBJ(string,1),strlen(GETOBJ(string,1)));
+}
+
+
+/**************** Add new system user *************/
+void AddNewUser(parseinfo *csb){
+ char password[128];
+ char confirm_password[128];
+ STATUS retstat=ERROR;
+
+ if(csb->nvgen)
+ return;
+
+ if(sysUserGetUserLevelByName(current_user)!=0){
+ printf("\nRoot privillege required for this operation\n");
+ return;
+ }
+
+ if(csb->sense){
+ printf("Enter the password with minimum 8 characters\n");
+ if(getInput( STD_OUT,STD_IN,"password :", password, 127, TRUE )==FALSE){
+ printf("\n Could not read password \n");
+ return;
+ }
+ if(getInput( STD_OUT,STD_IN,"\nconfirm password :", confirm_password, 127, TRUE )==FALSE){
+ printf("\nCould not read password \n");
+ return;
+ }
+ if(strcmp(password,confirm_password)!=0)
+ {
+ printf("\nPasswords do not match\n");
+ return;
+ }
+ retstat=sysUserAdd(GETOBJ(string,1),(char*)password,GETOBJ(int,1));
+ if(retstat==ERROR)
+ printf("\nUser could not be added\n");
+ else
+ printf("\nAdded user successfully\n");
+
+ }else{
+ retstat=sysUserDelete(GETOBJ(string,1));
+ if(retstat==ERROR)
+ printf("\nUser %s could not be deleted \n", GETOBJ(string,1));
+ else
+ printf("\nDeleted user successfully\n");
+
+ }
+
+}
+
+/**********Enable SSH access *********/
+extern BOOL ssh_enable_flag;
+extern BOOL telnet_enable_flag;
+extern BOOL ssh_present;
+
+void EnableSsh(parseinfo *csb){
+ if(csb->nvgen){
+ if(ssh_enable_flag)
+ printf("\nssh enable\n");
+ return ;
+ }
+ if(!ssh_present){
+ printf("\nSSH is not supported\n");
+ return;
+ }
+
+ if(csb->sense){
+ ssh_enable_flag=TRUE;
+ }else{
+ if(!telnet_enable_flag)
+ printf("\nSSH and Telnet can't be disabled at same time\n");
+ else
+ ssh_enable_flag=FALSE;
+ }
+
+}
+/**********Enable telnet access *********/
+
+void EnableTelnet(parseinfo *csb){
+ if(csb->nvgen){
+ if(!telnet_enable_flag)
+ printf("\nno telnet enable\n");
+ return ;
+ }
+
+ if(csb->sense){
+ telnet_enable_flag=TRUE;
+ }else{
+ if(!ssh_enable_flag)
+ printf("\nTelnet and SSH can't be disabled at same time\n");
+ else
+ telnet_enable_flag=FALSE;
+ }
+
+}
+/*************** Change password for existing user ***************/
+void ChangePasswd(parseinfo *csb){
+ STATUS retstat=ERROR;
+ char password[128];
+ char new_password[128];
+
+ if(csb->nvgen)
+ return;
+
+ if( (GETOBJ(string,1)==NULL) ){
+ printf("\nPasswd could not be changed\n");
+ return;
+ }
+
+ if( (sysUserGetUserLevelByName(current_user)!=0) && strcmp(GETOBJ(string,1),current_user) != 0 ){
+ printf("\nRoot privillege required for this operation\n");
+ return;
+ }
+ if(getInput( STD_OUT,STD_IN,"Old password :", password, 127, TRUE )==FALSE){
+ printf("\n Could not read password \n");
+ return;
+ }
+ if(getInput( STD_OUT,STD_IN,"\nNew password :", new_password, 127, TRUE )==FALSE){
+ printf("\nCould not read password \n");
+ return;
+ }
+
+ retstat=sysUserPasswdChange( GETOBJ(string,1),password,new_password );
+ if(retstat==OK)
+ printf("\n Passwd changed succesfully\n");
+ else
+ printf("\n Passwd could not be changed\n");
+
+}
+extern BOOL vxsh_flag;
+void EnableVxsh(parseinfo *csb){
+
+ if(csb->nvgen)
+ return ;
+
+ if(csb->sense)
+ vxsh_flag = TRUE;
+ else
+ vxsh_flag = FALSE;
+
+}
+
+
+
+void readBootLine(void){
+ char bootString[256];
+ bootStringToStruct( (char *)BOOT_LINE_ADRS, &pBootParams);
+ bootStructToString ( bootString, &pBootParams);
+ strcpy((char *)BOOT_LINE_ADRS, bootString);
+}
+void setBootParamsMode(parseinfo *csb){
+
+ if (csb->nvgen) {
+ printf("\nboot-params");
+ cli_submode_nvgen(csb,config_boot);
+ }
+ readBootLine();
+ set_mode_byname(&csb->mode,"boot-params",MODE_VERBOSE);
+}
+
+extern void sysNvRamSet(char *,int,int);
+
+void changeBootParams(parseinfo *csb){
+ char bootString[256];
+ if(!GETOBJ(string,1) && !GETOBJ(int,1)){
+ printf("\ncould not change the parameter\n");
+ return;
+ }
+
+ if (csb->nvgen) {
+ bootStringToStruct( (char *)BOOT_LINE_ADRS, &pBootParams);
+
+ printf("\n\tboot_device %s",pBootParams.bootDev);
+ printf("\n\tprocessor_number %d",pBootParams.procNum);
+ printf("\n\tunit_number %d",pBootParams.unitNum);
+ printf("\n\thost_name %s",pBootParams.hostName);
+ printf("\n\tfile_name %s",pBootParams.bootFile);
+ printf("\n\tinet_on_ethernet %s",pBootParams.ead);
+ printf("\n\tinet_on_backplane %s",pBootParams.bad);
+ printf("\n\tgateway_inet %s",pBootParams.gad);
+ printf("\n\thost_inet %s",pBootParams.had);
+ printf("\n\tuser %s",pBootParams.usr);
+ printf("\n\tftp_password %s",pBootParams.passwd);
+ printf("\n\ttarget_name %s",pBootParams.targetName);
+ printf("\n\tflags %s",pBootParams.flags);
+ printf("\n\tstartup_script %s",pBootParams.startupScript);
+ printf("\n\tother %s",pBootParams.other);
+ }
+
+ switch(csb->which){
+ case EXIT_BOOT_MODE:
+ bootStructToString ( bootString, &pBootParams);
+ strcpy((char *)BOOT_LINE_ADRS, bootString);
+ sysNvRamSet((char *)BOOT_LINE_ADRS, strlen (bootString) + 1, 0);
+ set_mode_byname(&csb->mode,"configure",MODE_VERBOSE);
+ break;
+ case BOOT_DEV:
+ strcpy(pBootParams.bootDev,GETOBJ(string,1));
+ break;
+ case UNIT_NUM:
+ pBootParams.unitNum=GETOBJ(int,1);
+ break;
+ case PROC_NUM:
+ pBootParams.procNum=GETOBJ(int,1);
+ break;
+ case HOST_NAME:
+ strcpy(pBootParams.hostName,GETOBJ(string,1));
+ break;
+ case FILE_NAME:
+ strcpy(pBootParams.bootFile,GETOBJ(string,1));
+ break;
+ case ETHER_IP:
+ strcpy(pBootParams.ead,GETOBJ(string,1));
+ break;
+ case BACK_IP:
+ strcpy(pBootParams.bad,GETOBJ(string,1));
+ break;
+ case HOST_IP:
+ strcpy(pBootParams.had,GETOBJ(string,1));
+ break;
+ case GATEWAY_IP:
+ strcpy(pBootParams.gad,GETOBJ(string,1));
+ break;
+ case USER_NAME:
+ strcpy(pBootParams.usr,GETOBJ(string,1));
+ break;
+ case FTP_PASSWD:
+ strcpy(pBootParams.passwd,GETOBJ(string,1));
+ break;
+ case TARGET_NAME:
+ strcpy(pBootParams.targetName,GETOBJ(string,1));
+ break;
+ case FLAGS:
+ pBootParams.flags=GETOBJ(int,1);
+ break;
+ case STARTUP_SCRIPT:
+ strcpy(pBootParams.startupScript,GETOBJ(string,1));
+ break;
+ case OTHER:
+ strcpy(pBootParams.other,GETOBJ(string,1));
+ break;
+ }
+}
diff --git a/data/mnet/Common/cli/src/chain.c b/data/mnet/Common/cli/src/chain.c
new file mode 100644
index 0000000..0295600
--- /dev/null
+++ b/data/mnet/Common/cli/src/chain.c
@@ -0,0 +1,267 @@
+#include <vxworks.h>
+#include <stdioLib.h>
+#include <tyLib.h>
+#include <taskLib.h>
+#include <errnoLib.h>
+#include <lstLib.h>
+#include <inetLib.h> /* for INET_ADDR_LEN */
+#include <timers.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <msgQLib.h>
+#include <sigLib.h>
+
+
+#include <../include/cli_parser_private.h>
+#include <../include/pstypes.h>
+#include <../include/psvxif.h>
+#include <../include/imsg.h>
+#include <../include/imc.h>
+#include <../include/address.h>
+#include <../include/parsertypes.h>
+#include <../include/config.h>
+#include <../include/parser_sim.h>
+#include <../include/parser.h>
+#include <../include/parser_defs_exec.h>
+#include <../include/parser_input.h>
+#include <../include/parser_sim.h>
+#include <../include/parser_util.h>
+#include <../include/parser_commands.h>
+#include <../include/nv.h>
+#include <../include/parser_errno.h>
+#include <../include/parser_ModNum.h>
+#include <../include/defs.h>
+#include <../include/parser_init.h>
+#include <../include/macros.h>
+#include <../include/parser_actions.h>
+/*#include <parser/parser_defs_config.h>
+ #include "exception.h" */
+
+enum {
+ TASK_DETAIL,
+ TASK_SUMMARY,
+ TASK_GEN
+};
+
+const char parser_help_default_keyword[] = "Set a command to its defaults";
+const char parser_help_no_keyword[] = "Negate a command or set its defaults";
+const char parser_default_keyword[] = "default";
+const char parser_no_keyword[] = "no";
+
+
+/* Global parser items */
+transition pname(NONE) = {NULL, NULL, (trans_func) NONE_action, NULL};
+transition pname(no_alt) = {NULL, NULL, (trans_func) no_alt_action, NULL};
+transition pname(link_point) = {NULL, NULL, (trans_func) link_point_action, NULL};
+transition pname(link_trans) = {NULL, NULL, (trans_func) NONE_action, NULL};
+
+/* Function for emitting comments about last config and NV update times */
+static void write_config_times (parseinfo *csb)
+{
+ if (csb->nvgen && !csb->priv_set) {
+ /*
+ *RAMS: commented this for now
+
+ nv_write(TRUE, "!"); */
+ }
+
+}
+
+/***************************************************
+ * Interface mode commands
+ */
+
+#ifdef a0
+
+#define ALTERNATE no_alt
+#include "os/ip/src/cfg_interface_exit.h"
+#include "os/ip/src/cfg_int_ip.h"
+#undef ALTERNATE
+
+#endif
+
+
+LINK_TRANS(top_configure_interface_extend_here, no_alt);
+NO_OR_DEFAULT(config_interface_no, top_configure_interface_extend_here,
+ PRIV_MIN | PRIV_NONVGEN);
+HELP(top_configure_interface, config_interface_no,
+ "Configure Interface commands:\n");
+
+/*********************************************************
+ * Clear commands.
+ */
+LINK_TRANS(exec_clear_extend_here, no_alt);
+
+#undef ALTERNATE
+#define ALTERNATE exec_clear_extend_here
+/*#include "../include/exec_clear_interface.h" */
+NOP (exec_clear_commands, ALTERNATE, NONE);
+
+
+/*********************************************************
+ * Debug commands.
+ * Linkage to here is from exec_commands/debug.h
+ */
+LINK_TRANS(exec_debug_extend_here, no_alt);
+
+#undef ALTERNATE
+#define ALTERNATE exec_debug_extend_here
+#include "../include/exec_debug_all.h"
+NOP (exec_debug_commands, ALTERNATE, NONE);
+
+
+/*********************************************************
+ * Show commands.
+ * Linkage to here is from exec_commands/show.h
+ */
+LINK_TRANS(exec_show_extend_here, no_alt);
+
+#undef ALTERNATE
+#define ALTERNATE exec_show_extend_here
+/*#include "../include/exec_show_configuration.h" */
+NOP (exec_show_commands, ALTERNATE, NONE);
+
+/*********************************************************
+ * Global commands that exist at all levels
+ * These always terminate at 'no_alt' and therefore
+ * must be referenced from the terminal states in
+ * each of the command sets.
+ *
+ * None of the global commands
+ * should have a 'no' prefix format.
+ */
+
+LINK_TRANS (global_extend_here, NONE);
+TESTVAR (globalcmd_start_no, NONE, global_extend_here,
+ NONE, NONE, NONE, sense, FALSE);
+TESTVAR (globalcmd_start, globalcmd_start_no, NONE,
+ NONE, NONE, no_alt, nvgen, FALSE);
+
+/*********************************************************
+ * configure commands from here down
+ */
+
+#undef ALTERNATE
+#define ALTERNATE globalcmd_start
+
+#include "../include/cfg_exit.h"
+#include "../include/cfg_end.h"
+NVCOMMENT(after_line_comment, ALTERNATE);
+LINK_TRANS(cfg_extend_last_here, after_line_comment);
+#undef ALTERNATE
+#define ALTERNATE cfg_extend_last_here
+/*#include "../include/cfg_exception.h" */
+/*#include "../include/cfg_term.h" */
+/*#include "../include/cfg_trusthost.h" */
+/*#include "../include/cfg_exec_timeout.h" */
+NVCOMMENT(cfg_extend_comment, ALTERNATE );
+LINK_TRANS(cfg_extend_here, cfg_extend_comment);
+#undef ALTERNATE
+#define ALTERNATE cfg_extend_here
+
+
+EVAL (config_times, ALTERNATE, write_config_times(csb));
+NVCOMMENT(first_comment, config_times);
+NO_OR_DEFAULT(config_no, first_comment, PRIV_MIN | PRIV_NONVGEN);
+HELP (top_configure, config_no, "Configure commands:\n");
+
+
+/*********************************************************
+ * Exec Commands
+ *
+ * If we're enabled, then include the priv_commands, otherwise, go
+ * to the global command set.
+ *
+ */
+
+LINK_TRANS(exec_extend_here, globalcmd_start);
+
+#undef ALTERNATE
+#define ALTERNATE exec_extend_here
+/*#include "../include/exec_ping.h" */
+#include "../include/exec_undebug.h"
+#include "../include/exec_debug.h"
+#include "../include/exec_exit.h"
+#include "../include/exec_show.h"
+/*#include "../include/exec_term.h" */
+/*#include "../include/exec_tclsh.h" */
+#include "../include/exec_clear.h"
+/*#include "../include/exec_traceroute.h"*/
+HELP (top, ALTERNATE, "Exec commands:\n");
+
+#ifdef PARSER_DEBUG_LINKS
+#define LINK(which,str,where,link)\
+ {which,str,((dynamic_transition *)&pname(where)),link},
+#else /* PARSER_DEBUG_LINKS */
+#define LINK(which,str,where,link)\
+ {which,((dynamic_transition *)&pname(where)),link},
+#endif /* PARSER_DEBUG_LINKS */
+
+chain_link chain_gang[] = {
+ LINK(PARSE_ADD_EXEC_CMD, "exec", exec_extend_here,
+ PARSER_ENTRY_LINK_POINT)
+ LINK(PARSE_ADD_SHOW_CMD, "show", exec_show_extend_here,
+ PARSER_ENTRY_LINK_POINT)
+ LINK(PARSE_ADD_DEBUG_CMD, "debug", exec_debug_extend_here,
+ PARSER_ENTRY_LINK_POINT)
+ LINK(PARSE_ADD_CLEAR_CMD, "clear", exec_clear_extend_here,
+ PARSER_ENTRY_LINK_POINT)
+ LINK(PARSE_ADD_CFG_TOP_CMD, "configuration", cfg_extend_here,
+ PARSER_ENTRY_LINK_POINT)
+ LINK(PARSE_ADD_CFG_INTERFACE_TOP_CMD, "interface",
+ top_configure_interface_extend_here,
+ PARSER_ENTRY_LINK_POINT)
+ LINK(PARSE_ADD_CFG_LAST_CMD, "end of top level configuration commands",
+ cfg_extend_last_here, PARSER_ENTRY_LINK_POINT)
+ LINK(PARSE_ADD_GLOBAL_CMD, "global", global_extend_here,
+ PARSER_ENTRY_LINK_POINT)
+
+
+ { PARSE_LIST_END,
+#ifdef PARSER_DEBUG_LINKS
+ NULL,
+#endif /* PARSER_DEBUG_LINKS */
+ NULL, 0}
+};
+
+
+
+
+
+/*
+ * chain.c common mode information
+ */
+
+parser_mode *exec_mode;
+parser_mode *config_mode;
+parser_mode *interface_mode;
+
+void parser_add_main_modes (void)
+{
+ exec_mode = parser_add_mode("exec", NULL, "Exec mode",
+ TRUE, TRUE, NULL, NULL, NULL,
+ &pname(top),
+ NULL );
+
+ config_mode = parser_add_mode("configure", "config",
+ "Global configuration mode",
+ TRUE, TRUE, NULL, NULL, NULL,
+ &pname(top_configure),
+ NULL);
+
+ interface_mode = parser_add_mode("interface", "config-if",
+ "Interface configuration mode",
+ TRUE, TRUE,
+ NULL, /* "configure", */
+ NULL, /* interface_save_var, */
+ NULL, /* interface_reset_var, */
+ &pname(top_configure_interface),
+ NULL);
+}
+
+
+void show_test_mnet(parseinfo *csb)
+{
+ printf("\n show command is integrated\n");
+}
diff --git a/data/mnet/Common/cli/src/cli_parser_init.c b/data/mnet/Common/cli/src/cli_parser_init.c
new file mode 100644
index 0000000..6a0d73e
--- /dev/null
+++ b/data/mnet/Common/cli/src/cli_parser_init.c
@@ -0,0 +1,379 @@
+#include <vxworks.h>
+#include <stdioLib.h>
+#include <taskLib.h>
+#include <tyLib.h>
+#include <lstLib.h>
+#include <inetLib.h> /* for INET_ADDR_LEN */
+#include <timers.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+
+#include <../include/cli_parser_private.h>
+#include <../include/pstypes.h>
+#include <../include/psvxif.h>
+#include <../include/imsg.h>
+#include <../include/imc.h>
+#include <../include/cli_parser_api.h>
+#include <../include/address.h>
+#include <../include/parsertypes.h>
+#include <../include/config.h>
+#include <../include/parser_sim.h>
+#include <../include/parser.h>
+
+static tCSEMAPHORE parserSemId;
+static tTASKID parserTaskId;
+
+SEM_ID systemloadingSemId = NULL;
+SEM_ID parse_chain_sem = NULL;
+extern int consoleFd;
+extern void BasicParserInit(void);
+
+
+#if 0
+#include "cli_private.h"
+
+#include <parser/parser_init.h>
+#include <parser/parser_sim.h>
+#include <parser/parser_actions.h>
+#include <imc/imc.h>
+#include <imc/imsg.h>
+#include <parser/nv.h>
+#include <parser/sys_debug.h>
+#include <parser/debug.h>
+#include <syslog.h>
+#include <h/os/bootflags.h>
+
+
+
+
+int terminalLength = LINES;
+int waitingTaskCount = 0;
+int parserNullFd = -1;
+
+FILE *parserNullFp = NULL;
+
+/* Extern Declarations */
+extern SEM_ID waitingSemId;
+extern SEM_ID rootBSemId;
+extern tCSEMAPHORE initSemId;
+extern void mace_chain_init(void);
+extern void sysconf_init(void);
+
+/* Prototypes */
+static void parser_process_request( tpCOMSIM );
+static void parser_process_response( tpCOMSIM , tINT);
+static void parser_work(void);
+
+
+
+
+
+
+void
+parser_configure(void)
+{
+ if ( sysBootParams.flags & BYPASS_NVRAM_CONFIG) {
+ printf("Bypassing NVRAM Configuration...\n");
+ } else {
+ printf("Configuring from NVRAM...\n");
+ nv_configure( PRIV_ROOT );
+ }
+}
+
+void
+parser_check(void)
+{
+ extern int ip_name_server_config_check(void);
+
+ /*
+ * check if all the required configuration has been done.
+ * if not, generate syslog messages
+ */
+ ip_name_server_config_check();
+}
+void parser_process_response( tpCOMSIM pComSim, tINT expectId )
+{
+
+ if (pComSim->requestid != expectId ) {
+ printf("Invalid Request Id obtained in Indication\n");
+ }
+
+ if ( pComSim->status != RC_OK ) {
+ printf("Invalid Status obtained\n");
+ }
+
+ if ( pComSim->pLayerSim ) {
+ printf("%s\n", (char *)(pComSim->pLayerSim));
+ }
+
+ return;
+
+}
+
+void parse_configure(char *buffer, int permanent,
+ int resolvemethod, uchar priv )
+{
+ tOCTET4 moduleId = ASSIGN_MODULE_ID;
+ boolean end_found;
+ parseinfo *csb;
+ tpCOMSIM pComSim = NULL;
+ tpPARSERSIM pSim = NULL;
+ int requestId = 0;
+ SEM_ID configparserSemId;
+
+ configparserSemId = semCCreate( _DEFAULT_COUNT_SEM_FLAG , 0 );
+ if ( imc_add( &moduleId, configparserSemId, taskIdSelf() ) == ERROR ) {
+ panic("Cannot add Parser Configuration to IMC\n");
+ }
+
+ csb = get_csb("Parser Configuration CSB");
+ if (csb == NULL) {
+ return;
+ }
+
+ csb->uid = 0; /* ROOT */
+ csb->priv = priv;
+ csb->resolvemethod = resolvemethod;
+ csb->mode = config_mode;
+ csb->break_chars = NVCONFIG_BREAKSET;
+ csb->batch_buf = buffer;
+ csb->batch_offset = buffer;
+ csb->flags = 0;
+ csb->inFd = csb->outFd = consoleFd;
+
+ end_found = FALSE;
+ while (batch_input(csb, csb->line, PARSEBUF,
+ csb->break_chars, &csb->lastchar)) {
+ if (*csb->line && (*csb->line != '!')) { /* Skip empty lines */
+
+ if ((strcmp(csb->line, "end") == 0) ||
+ (strcmp(csb->line, " end") == 0))
+ {
+ end_found = TRUE;
+ break;
+ }
+
+ pSim = (tpPARSERSIM ) mGETSIM( sizeof( tPARSERSIM ) );
+
+ if ( !pSim ) {
+ printf("Not enough memory.... please try later\n");
+ return;
+ }
+
+ mFILL_PARSER_SIM(pSim, csb, moduleId,
+ moduleId, PARSER_CMD_PROC_REQ, requestId,
+ csb->line, csb->lastchar, 0, 0 );
+
+ processCommand( pSim );
+
+ if ( semTake( configparserSemId, WAIT_FOREVER ) == ERROR ) {
+ panic("parser_work:Cannot wait on Parser Semaphore\n");
+ }
+
+ pComSim = NULL;
+
+ mGET_WORK_SIM( pComSim, moduleId );
+
+ if ( pComSim ) {
+ if ( IS_INDICATION(pComSim->serviceid)) {
+ parser_process_response( pComSim, requestId );
+ }
+ else if (IS_REQUEST(pComSim->serviceid)) {
+ printf("\nInvalid Request in Parser\n");
+ }
+ else
+ printf("\ntParser:Invalid Service Obtained\n");
+ mFREESIM( pComSim );
+ }
+ if ( semTake(csb->configSemId, WAIT_FOREVER) == ERROR )
+ panic("Cannot wait on CSB Configuration Semaphore\n");
+
+ requestId++;
+ }
+ }
+ if (!end_found) {
+ panic("Cannot complete Configuration!\n");
+ }
+
+ /* Mind our Free's & Q's */
+ free_csb(&csb);
+
+ semDelete( configparserSemId );
+
+ imc_remove( moduleId );
+
+}
+
+void wait_for_system_load( void )
+{
+ if ( semTake( waitingSemId, WAIT_FOREVER ) == ERROR ) {
+ printf("wait_for_system_load(%s): Cannot wait on waitingSemId\n",
+ _TASK_NAME);
+ return;
+ }
+
+ waitingTaskCount++;
+
+ if ( semGive( waitingSemId) == ERROR ) {
+ printf("wait_for_system_load(%s): Cannot Give waitingSemId\n",
+ PS_TASK_NAME);
+ }
+}
+
+
+void parser_svcinit(void)
+{
+ parser_sema_init();
+ parser_iowork_init();
+}
+
+void parser_configure(void)
+{
+ parser_callback_init();
+ parser_task_init();
+ parser_configure();
+}
+
+void parser_start(void)
+{
+ parser_check();
+}
+
+#endif
+
+void ProcessCommand ( tpPARSERSIM pParserSim )
+{
+ tOCTET2 error = PARSE_ERROR_NOERR;
+ char *line = pParserSim->command;
+ char lastchar = pParserSim->lastchar;
+ parseinfo *csb = pParserSim->csb;
+
+ if ( csb == NULL ) {
+ panic("processCommand : NULL CSB Obtained\n");
+ return;
+ }
+
+ if (lastchar == '?') {
+ csb->in_help = PARSER_HELP;
+ csb->lastchar = '?';
+ } else if (lastchar == '\t') {
+ csb->in_help = PARSER_COMMAND_COMPLETION;
+ csb->lastchar = '\t';
+ } else {
+ csb->in_help = PARSER_NO_HELP;
+ csb->lastchar = '\0';
+ }
+
+ strcpy(csb->line, line);
+ error = parse_cmd(csb, pParserSim);
+}
+
+void CliParserMain ( void )
+{
+
+ tpCOMSIM pComSim = NULL;
+
+ while ( 1 ) {
+ if ( semTake( parserSemId, WAIT_FOREVER ) == ERROR ) {
+ panic("parser_work:Cannot wait on Parser Semaphore\n");
+ }
+
+ pComSim = NULL;
+
+ mGET_WORK_SIM( pComSim, (tOCTET4)PARSER_MODULE );
+
+ if ( pComSim ) {
+ /* Check if it is Request or Indication */
+ if ( IS_INDICATION(pComSim->serviceid)) {
+ printf("Invalid Indication obtained in parser_work\n");
+ /* parser_send_response(pComSim, NULL, RC_ERR ); */
+ mFREESIM( pComSim );
+ }
+ else if (IS_REQUEST(pComSim->serviceid)) {
+ ProcessCommand(( tpPARSERSIM)pComSim);
+ }
+ else
+ printf("\ntParser:Invalid Service Obtained\n");
+ }
+ }
+}
+
+void ParserSemInit(void)
+{
+ tOCTET4 moduleId = PARSER_MODULE;
+
+ parse_chain_sem = semMCreate( PS_DEFAULT_MUTEX_SEM_FLAG ) ;
+ if ( parse_chain_sem == NULL ) {
+ panic("parser_init:Cannot create parse chain semaphore\n");
+ }
+
+ systemloadingSemId = semCCreate(PS_DEFAULT_COUNT_SEM_FLAG, 0 );
+ if ( systemloadingSemId == NULL) {
+ panic("Cannot create System Initialization Semaphore\n");
+ }
+
+ /* initSemId = semCCreate(PS_DEFAULT_COUNT_SEM_FLAG, 0); */
+
+ /* TO be removed */
+ if ( imc_init() != RC_OK ) {
+ panic("Cannot Initialize IMC\n");
+ }
+
+ parserSemId = semCCreate( PS_DEFAULT_COUNT_SEM_FLAG , 0 );
+ parserTaskId = taskIdSelf();
+
+ if ( imc_add( &moduleId, parserSemId, parserTaskId ) == ERROR ) {
+ panic("Cannot add Parser to IMC\n");
+ }
+
+}
+
+
+void ParserTaskInit (void)
+{
+ STATUS errcode = 0;
+
+ errcode = taskSpawn("tParser",PARSER_TASK_PRIORITY, PARSER_TASK_OPTION,
+ PARSER_TASK_STACK_SIZE,
+ (FUNCPTR)CliParserMain,0,0,0,0, 0, 0, 0, 0, 0, 0);
+
+
+ if (errcode == ERROR) {
+ printf("\nCLI Parser Task spawn failed");
+ }
+}
+
+void parser_init ( void )
+{
+ config_prompt = TRUE;
+
+ debug_init();
+ parser_modes_init();
+ command_parser_init();
+ exec_parser_init();
+
+ ip_address_init();
+ /*
+ * RAMS: commented this for now
+ show_os_chain_init();
+
+ nv_init();
+ sysconf_init();
+ */
+}
+
+
+void SysCommandCli (void)
+{
+ ParserSemInit ();
+ parser_init();
+ ParserTaskInit();
+ ParserCallbackInit();
+ BasicParserInit();
+#if 0
+ parser_iowork_init ();
+ parser_configure();
+ parser_check ();
+#endif
+}
diff --git a/data/mnet/Common/cli/src/cli_shellLib.c b/data/mnet/Common/cli/src/cli_shellLib.c
new file mode 100644
index 0000000..e06e57a
--- /dev/null
+++ b/data/mnet/Common/cli/src/cli_shellLib.c
@@ -0,0 +1,729 @@
+/********** File contains APIs used by telnet server and VxWorks to start or destroy the shell ***/
+
+#include "vxWorks.h" /* always first */
+#include <taskLib.h>
+#include "stdio.h"
+#include "ioLib.h"
+#include "symLib.h"
+#include "string.h"
+#include "loadLib.h"
+#include "usrLib.h"
+#include "sysLib.h"
+
+#include <../include/psvxif.h>
+/******* Global variables **********/
+
+char *shellTaskName="tShell";
+char *ios_shellTaskName="tShell";
+
+int shellTaskId;
+int ios_shellTaskId;
+
+int myShellTaskId;
+int myFd;
+int outfd,errfd,infd;
+BOOL ssh_enable_flag=FALSE;
+BOOL telnet_enable_flag=TRUE;
+BOOL ssh_present =FALSE;
+
+
+int ConsoleTask=0;
+int TelnetTask=1;
+int SSHTask =2;
+
+int ShellTask=0;
+
+FUNCPTR cli_logoutf=NULL;
+int cli_logVar=0;
+
+SEM_ID cli_semM;
+BOOL isLoggedOut=FALSE;
+extern SYMTAB_ID sysSymTbl;
+extern BOOL ServerBreak;
+
+int ParserCallBackTask[3];
+
+/******* external variables **********/
+extern int consoleFd; /* fd of initial console device */
+extern int CliIOInit (int,int,int,BOOL);
+extern int SysCommandCli(void) ;
+
+void logmsg(char* string);
+void logerr(char* string);
+void PrintMsg(char* Msg);
+int logfd;
+
+
+
+
+
+
+
+
+
+enum {
+ VX_SHELL,
+ IOS_SHELL
+};
+
+static currentShell=IOS_SHELL;
+
+BOOL ios_shellLock(BOOL request);
+STATUS ios_execute (char *line);
+STATUS ios_shellInit (int stackSize, int arg);
+void ios_shell (BOOL interactive);
+void ios_shellHistory (int size);
+void ios_shellLoginInstall (FUNCPTR logRtn, int logVar);
+void ios_shellLogout (void);
+void ios_shellLogoutInstall (FUNCPTR logRtn, int logVar);
+void ios_shellOrigStdSet (int which, int fd);
+void ios_shellPromptSet (char *newPrompt);
+void ios_shellRestart (BOOL staySecure);
+void ios_shellRestart (BOOL staySecure);
+
+
+
+BOOL shellLock(BOOL request);
+STATUS execute (char *line);
+STATUS shellInit (int stackSize, int arg);
+void shell (BOOL interactive);
+void shellHistory (int size);
+void shellLoginInstall (FUNCPTR logRtn, int logVar);
+void shellLogout (void);
+void shellLogoutInstall (FUNCPTR logRtn, int logVar);
+void shellOrigStdSet (int which, int fd);
+void shellPromptSet (char *newPrompt);
+void shellRestart (BOOL staySecure);
+void shellRestart (BOOL staySecure);
+
+
+
+
+enum {
+ SHELLLOCK_ID,
+ EXECUTE_ID,
+ SHELLINIT_ID,
+ SHELL_ID,
+ SHELLHISTORY_ID,
+ SHELLLOGININSTALL_ID,
+ SHELLLOGOUT_ID,
+ SHELLLOGOUTINSTALL_ID,
+ SHELLORIGSTDSET_ID,
+ SHELLPROMPTSET_ID,
+ SHELLRESTART_ID,
+ SHELLENDOFLIST_ID
+};
+
+typedef struct _stdShellVector {
+ char *shellTaskName;
+ int shellTaskId;
+ /*
+ void *shellLock;
+ void *execute;
+ void *shellInit;
+ void *shell;
+ void *shellHistory;
+ void *shellLoginInstall;
+ void *shellLogout;
+ void *shellLogoutInstall;
+ void *shellOrigStdSet;
+ void *shellPromptSet;
+ void *shellRestart;
+ void *shellendOfList;
+ */
+ void *symValue[12];
+
+}stdShellVector;
+
+#ifdef MNET_GP10
+char *stdShellNames[] = {
+ "shellLock",
+ "execute",
+ "shellInit",
+ "shell",
+ "shellHistory",
+ "shellLoginInstall",
+ "shellLogout",
+ "shellLogoutInstall",
+ "shellOrigStdSet",
+ "shellPromptSet",
+ "shellRestart",
+ 0
+};
+#else
+char *stdShellNames[] = {
+ "_shellLock",
+ "_execute",
+ "_shellInit",
+ "_shell",
+ "_shellHistory",
+ "_shellLoginInstall",
+ "_shellLogout",
+ "_shellLogoutInstall",
+ "_shellOrigStdSet",
+ "_shellPromptSet",
+ "_shellRestart",
+ 0
+};
+
+#endif
+
+static stdShellVector iosShellVector =
+{
+ "tShell",
+ 0,
+ {
+ ios_shellLock,
+ ios_execute,
+ ios_shellInit,
+ ios_shell,
+ ios_shellHistory,
+ ios_shellLoginInstall,
+ ios_shellLogout,
+ ios_shellLogoutInstall,
+ ios_shellOrigStdSet,
+ ios_shellPromptSet,
+ ios_shellRestart,
+ 0
+ }
+};
+
+static stdShellVector defaultShellVector =
+{
+ "tShell",
+ 0,
+ {
+ shellLock,
+ execute,
+ shellInit,
+ shell,
+ shellHistory,
+ shellLoginInstall,
+ shellLogout,
+ shellLogoutInstall,
+ shellOrigStdSet,
+ shellPromptSet,
+ shellRestart,
+ 0
+ }
+};
+
+static stdShellVector vxShellVector;
+static stdShellVector runShellVector=
+{
+ "tShell",
+ 0,
+ {
+ ios_shellLock,
+ ios_execute,
+ ios_shellInit,
+ ios_shell,
+ ios_shellHistory,
+ ios_shellLoginInstall,
+ ios_shellLogout,
+ ios_shellLogoutInstall,
+ ios_shellOrigStdSet,
+ ios_shellPromptSet,
+ ios_shellRestart,
+ 0
+ }
+};
+
+
+
+
+int installedVxShell=0;
+static void *vxShellSymValue;
+
+BOOL stdFindVxShellSymbol( char *name, int val, SYM_TYPE type, int arg, UINT16 group)
+{
+ if ( strcmp(name, (char *) arg) == 0 )
+ {
+ /*printf("found symbol %s in group %d\n", (char *)arg, (int) group);*/
+ if ( group != 0 )
+ {
+ vxShellSymValue=(void *)val;
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
+
+
+int shellLoadVxShell(char *file)
+{
+ MODULE_ID ret;
+ int next=0;
+
+
+ ret=ld(0,0,file);
+ if(ret==NULL){
+ return 0;
+ }
+
+ next=0;
+ while(stdShellNames[next]!=0){
+ vxShellSymValue=0;
+ symEach(sysSymTbl, stdFindVxShellSymbol, (int) stdShellNames[next]);
+ if(vxShellSymValue == 0)
+ return 0;
+ vxShellVector.symValue[next]=vxShellSymValue;
+ next++;
+ }
+ installedVxShell=1;
+ return 1;
+}
+
+int isInstalledVxShell()
+{
+ return installedVxShell;
+}
+
+void shellSetRunning(int shell)
+{
+ currentShell=shell;
+ if(shell == VX_SHELL)
+ runShellVector=vxShellVector;
+ else
+ runShellVector=iosShellVector;
+}
+
+int shellGetRunning()
+{
+ return currentShell;
+}
+
+void shellScriptAbort (void){
+ logmsg("shellScriptAbort\n");;
+}
+
+BOOL shellLock(BOOL request){
+ BOOL (*f)();
+
+ f=runShellVector.symValue[SHELLLOCK_ID];
+ return (*f)(request);
+}
+
+STATUS execute (char *line){
+
+ STATUS (*f)();
+
+ f=runShellVector.symValue[EXECUTE_ID];
+ return (*f)(line);
+
+}
+
+void *shellGetVxExecute()
+{
+
+ return vxShellVector.symValue[EXECUTE_ID];
+
+}
+
+STATUS shellInit (int stackSize, int arg){
+
+ STATUS (*f)();
+
+ f=runShellVector.symValue[SHELLINIT_ID];
+ return (*f)(stackSize, arg);
+
+}
+void shell (BOOL interactive){
+
+ void (*f)();
+
+ f=runShellVector.symValue[SHELL_ID];
+ (*f)(interactive);
+}
+
+void shellHistory (int size){
+
+ void (*f)();
+
+ f=runShellVector.symValue[SHELLHISTORY_ID];
+ (*f)(size);
+
+}
+
+void shellLoginInstall (FUNCPTR logRtn, int logVar){
+
+ void (*f)();
+
+ f=runShellVector.symValue[SHELLLOGININSTALL_ID];
+ (*f)(logRtn, logVar);
+
+}
+
+void shellLogout (void){
+
+ void (*f)();
+
+ f=runShellVector.symValue[SHELLLOGOUT_ID];
+ (*f)();
+}
+
+void shellLogoutInstall (FUNCPTR logRtn, int logVar){
+
+ void (*f)();
+
+ f=runShellVector.symValue[SHELLLOGOUTINSTALL_ID];
+ (*f)(logRtn, logVar);
+
+}
+
+void shellOrigStdSet (int which, int fd){
+
+ void (*f)();
+
+ f=runShellVector.symValue[SHELLORIGSTDSET_ID];
+ (*f)(which, fd);
+
+}
+
+void shellPromptSet (char *newPrompt){
+
+ void (*f)();
+
+ f=runShellVector.symValue[SHELLPROMPTSET_ID];
+ (*f)(newPrompt);
+}
+
+void shellRestart (BOOL staySecure){
+
+ void (*f)();
+
+ f=runShellVector.symValue[SHELLRESTART_ID];
+ (*f)(staySecure);
+}
+
+
+
+extern BOOL ExitFlag;
+
+void callbackRestart(){
+
+ int callbackTaskID;
+/* if(ServerBreak || ExitFlag)
+ return;*/
+ if(ServerBreak)
+ return;
+
+
+ if((callbackTaskID=taskNameToId ("tCallback0") )!= ERROR){
+ /*printMsg("\nTask 0 deleted\n");*/
+ taskDelete(callbackTaskID);
+ }
+ if((callbackTaskID=taskNameToId ("tCallback1") )!= ERROR){
+ /* printMsg("\nTask 1 deleted\n");*/
+ taskDelete(callbackTaskID);
+ }
+ if((callbackTaskID=taskNameToId ("tCallback2") )!= ERROR){
+ /* printMsg("\nTask 2 deleted\n");*/
+ taskDelete(callbackTaskID);
+ }
+ ParserCallbackInit();
+}
+
+
+/*****************Get the status of shell *********************/
+
+int shellGetCurrentStatus(char* status){
+ int retVal=0;
+ switch(ShellTask){
+ case 0 :
+ retVal=1;
+ if(status)
+ strcpy(status,"\nSystem is being accessed via Console connection\n");
+ break;
+ case 1 :
+ retVal=2;
+ if(status)
+ strcpy(status,"\nSystem is being accessed via Telnet connection\n");
+ break;
+ case 2 :
+ retVal=3;
+ if(status)
+ strcpy(status,"\nSystem is being accessed via SSH connection\n");
+ break;
+ default :
+ retVal=0;
+ if(status)
+ strcpy(status,"\nThere is no active CLI user in the system\n");
+ break;
+ }
+ return retVal;
+}
+
+
+
+/******** Locks the access to shell *********/
+BOOL ios_shellLock (BOOL request){
+
+
+
+ if(request==FALSE) {
+ ShellTask=ConsoleTask;
+ callbackRestart();
+ if(ServerBreak){
+ shellRestart(TRUE);
+ ServerBreak=FALSE;
+ }
+ return TRUE;
+ }else{
+ if(!telnet_enable_flag)
+ return FALSE;
+
+ if(ShellTask==SSHTask){
+ return FALSE;
+ }else{
+ callbackRestart();
+ ShellTask=TelnetTask;
+ return TRUE;
+ }
+ }
+}
+
+/**************/
+STATUS ios_execute (char *line){
+ logmsg("shellexecute\n");
+ return OK;
+ }
+
+
+
+extern void ParserCallbackRestart(int index);
+int tShell()
+{
+ char StatusOfTask[128];
+ int index;
+ for(;;){
+ /* for(index=0;index<3;index++){
+ if(taskStatusString(ParserCallBackTask[index],StatusOfTask)==ERROR)
+ ParserCallbackRestart(index);
+
+
+ }*/
+ taskDelay (sysClkRateGet ()*10);
+ }
+ return OK;
+}
+
+
+
+
+/*****************Shellinit******************
+Creates shell task for console
+*********************************************/
+
+STATUS ios_shellInit (int stackSize, int arg){
+
+ char taskName[100];
+
+ logerr("\nshellinit");
+
+
+ shellTaskId = taskSpawn("tShell", 200, 0, 10000,
+ (FUNCPTR)tShell,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,0,0,0,0);
+
+
+ sprintf(taskName, "shellInit - %d\n", shellTaskId);
+ logmsg(taskName);
+
+ outfd=errfd=infd=consoleFd;
+ ShellTask=ConsoleTask;
+
+ myShellTaskId=CliIOInit(infd,outfd,errfd,TRUE);
+ return OK;
+ }
+
+/*****************Shell******************/
+
+void ios_shell (BOOL interactive){
+ logmsg("shelllogout\n");
+ }
+
+
+
+/*****************ShellHistory******************/
+void ios_shellHistory (int size){
+ logmsg("shellHistory\n");;
+}
+
+static FUNCPTR loginf;
+
+
+
+
+/*****************shellLoginInstall******************/
+void ios_shellLoginInstall (FUNCPTR logRtn, int logVar){
+;
+}
+
+
+
+
+/*****************shellLogout******************/
+void ios_shellLogout (void){
+ myFd=consoleFd;
+ logmsg("shellLogout\n");
+ logerr("\nshellLogout\n");
+
+}
+
+
+
+
+
+/*****************shellLogoutInstall******************/
+void ios_shellLogoutInstall (FUNCPTR logRtn, int logVar){
+
+ logmsg("shellLogoutInstall\n");
+ cli_logoutf=logRtn;
+ cli_logVar=logVar;
+ logerr("\nshellLogoutInstall\n");
+}
+
+/*****************shellOrigStdSet******************/
+void ios_shellOrigStdSet (int which, int fd){
+
+ logmsg("shellOrigStdSet\n");
+ logerr("\nshellOrigStdSet\n");
+ if(which == STD_OUT) outfd=fd;
+ if(which == STD_IN) infd=fd;
+ if(which == STD_ERR) errfd=fd;
+}
+
+
+
+
+/*****************shellPromptSet******************/
+
+void ios_shellPromptSet (char *newPrompt){
+ logmsg("shellPromptSet\n");
+
+}
+
+
+extern void io_cleanup( int TaskID);
+
+/*****************shellRestart******************/
+void ios_shellRestart (BOOL staySecure){
+
+
+ if((myShellTaskId=taskNameToId ("tCli") )!= ERROR){
+ taskDelete(myShellTaskId);
+ io_cleanup(0);
+ }
+ myShellTaskId=CliIOInit(infd,outfd,errfd,TRUE);
+ switch(ShellTask){
+ case 0 :
+ printMsg("\nTask for console created\n");
+ break;
+ case 1 :
+ printMsg("\nTask for telnet session created\n");
+ break;
+ case 2 :
+ printMsg("\nTask for SSH session created\n");
+ break;
+ }
+
+}
+
+/*****************shellScriptAbort******************/
+void ios_shellScriptAbort (void){
+ logmsg("shellScriptAbort\n");;
+}
+
+BOOL isSSHEnabled(void){
+ return ssh_enable_flag;
+}
+
+
+
+BOOL SSHLock(void){
+/*
+ if(isLoggedOut==FALSE){
+ isLoggedOut=TRUE;
+ if(cli_logoutf){
+ isLoggedOut=FALSE;
+ (*cli_logoutf)(cli_logVar);
+ }
+ else{
+ isLoggedOut=FALSE;
+ }
+ }
+
+
+ logerr("\nLockForSSH exit\n");*/
+
+ if(cli_logoutf){
+ (*cli_logoutf)(cli_logVar);
+ }
+
+
+
+ return TRUE;
+}
+
+void LockForSSH(BOOL lock){
+ callbackRestart();
+ if(!lock){
+ ShellTask=ConsoleTask;
+ if(ServerBreak){
+ shellRestart(TRUE);
+ ServerBreak=FALSE;
+ }
+ return;
+ }
+
+ if(ShellTask!=TelnetTask){
+ ShellTask=SSHTask;
+ return;
+ }
+
+isLoggedOut=TRUE;
+/******************* If and only if ssh is preempting the telnet ****/
+ taskSpawn("tSSHLockTask", 150, 0, 10000,
+ (FUNCPTR)SSHLock,
+ 0,0,0,0,
+ 0,
+ 0,0,0,0,0);
+ do
+ taskDelay (sysClkRateGet ());
+ while (taskNameToId ("tSSHLockTask") != ERROR);
+
+ ShellTask=SSHTask;
+}
+
+
+
+
+void SshPresent(void){
+ ssh_present=TRUE;
+}
+
+void printMsg(char* Msg){
+
+write(consoleFd,Msg,strlen(Msg));
+
+}
+
+void logmsg(char* string){
+ return;
+write(consoleFd,string,strlen(string));
+}
+
+void logerr(char* string){
+return;
+ write(consoleFd,string,strlen(string));
+}
+
+
+
+
diff --git a/data/mnet/Common/cli/src/command2.c b/data/mnet/Common/cli/src/command2.c
new file mode 100644
index 0000000..c108262
--- /dev/null
+++ b/data/mnet/Common/cli/src/command2.c
@@ -0,0 +1,635 @@
+#include <vxworks.h>
+#include <stdioLib.h>
+#include <tyLib.h>
+#include <taskLib.h>
+#include <errnoLib.h>
+#include <lstLib.h>
+#include <inetLib.h> /* for INET_ADDR_LEN */
+#include <timers.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <msgQLib.h>
+#include <sigLib.h>
+
+
+#include <../include/cli_parser_private.h>
+#include <../include/pstypes.h>
+#include <../include/psvxif.h>
+#include <../include/imsg.h>
+#include <../include/imc.h>
+#include <../include/address.h>
+#include <../include/parsertypes.h>
+#include <../include/config.h>
+#include <../include/parser_sim.h>
+#include <../include/parser.h>
+#include <../include/parser_defs_exec.h>
+#include <../include/parser_input.h>
+#include <../include/parser_sim.h>
+#include <../include/parser_util.h>
+#include <../include/parser_commands.h>
+#include <../include/nv.h>
+#include <../include/parser_actions.h>
+#include <../include/parser_defs_config.h>
+
+boolean config_dirty = FALSE;
+
+#if 0
+#include <parser/parser.h>
+#include <parser/parser_actions.h>
+#include <parser/parser_defs_exec.h>
+#include <parser/parser_defs_config.h>
+#include <parser/nv.h>
+#include <cenetdb.h>
+#include <dosfs_posix.h>
+#include "assert.h"
+#include <syslog.h>
+#include <dosfs/uvfatUsrApiExt.h>
+
+
+static STATUS write_running_to_file( int fd , uint);
+
+
+
+
+/*
+ * write_terminal
+ * Show the current configuration on the terminal
+ */
+
+void write_terminal (parseinfo *csb)
+{
+ size_t len, cc;
+ char *curcfg = NULL;
+
+ /*
+ * Dump the current configuration to our buffer
+ */
+ curcfg = nv_current_to_buffer(TRUE,
+ PRIV_MAX,
+ (csb->flags & HIDE_PASSWORDS));
+ if ( curcfg == NULL ) {
+ return;
+ }
+
+ printf("\nCurrent configuration:");
+ len = strlen(curcfg);
+ cc = fwrite(curcfg, 1, len, stdout);
+ assert(cc == len);
+ PARSERfree(curcfg);
+}
+
+
+/*
+ * nv_save_config_info()
+ * This function is called by GUI for saving configuration information
+ * to NVRAM
+ *
+ */
+
+void nv_save_config_info()
+{
+ syslog(LOG_NOTICE, "Configured from GUI");
+ write_memory(NULL);
+}
+
+
+/*
+ * write_erase
+ * Jacket for EXEC "write erase" command
+ */
+
+void write_erase (parseinfo *csb)
+{
+ (void) nv_erase(TRUE);
+ config_dirty = TRUE;
+}
+
+/*
+ * write_memory
+ * Jacket for EXEC "write memory" command
+ */
+
+void write_memory (parseinfo *csb)
+{
+ if (ok_to_write_nv()) {
+ (void) nv_current_to_nv(TRUE);
+ config_dirty = FALSE;
+ } else
+ printf("No action taken because command was not confirmed\n");
+}
+
+void ping_command (parseinfo *csb)
+{
+ char host[256];
+ int numpkts = GETOBJ(int, 1);
+
+ strncpy(host, GETOBJ(string,1), 256);
+
+
+ ping( host, numpkts, 0 );
+}
+
+
+/*
+ * cfg_dirty -- return status of config. If user has modified
+ * config and not saved then return true else return false
+ */
+boolean cfg_dirty (void)
+{
+ return(config_dirty);
+}
+
+
+
+
+/*
+ * Write the configuration to TFTP / DISK
+ */
+void write_config( parseinfo *csb )
+{
+ char fileName[MAX_FILENAME_LENGTH + 1 ];
+ char remoteFileName[PATH_MAX + 1] = "";
+ char tftpServerAddr[INET_ADDR_LEN + 1] = "";
+ char buffer[256] = "";
+
+ boolean tftpPut = FALSE;
+ boolean tftpGet = FALSE;
+
+ int fd = -1;
+ int error = 0;
+ int fileAccess = 0;
+
+ int status = OK;
+
+ /* For Disk Copy the file to open is the filename
+ * specified. For TFTP operation, need to create
+ * a temporary file locally and ask for Remote file
+ * name also
+ */
+ if ( ( csb->which == COPY_RUNNING_CONFIG_DISK ) ||
+ ( csb->which == COPY_STARTUP_CONFIG_DISK ) ||
+ ( csb->which == COPY_DISK_STARTUP_CONFIG )) {
+
+ strcpy(fileName, GETOBJ(string,1));
+
+ if ( strcmp(fileName,"") == 0 ) {
+ printf("Invalid Filename specfied\n");
+ return;
+ }
+ } else {
+ time_t current_time = 0;
+
+ /* Temporary Filename creation to prevent
+ * conflicts
+ */
+ if ( time( &current_time ) < 0 )
+ current_time = 0;
+ sprintf(fileName, mVOLNAME".tmp.%d.%ld", taskIdSelf(),
+ current_time);
+
+ startIOTimer(csb);
+ status = getTftpInput(tftpServerAddr, remoteFileName ) ;
+ if ( status != OK ) {
+ if ( status == RC_TIMEOUT ) {
+ setExecTimeout(csb);
+ stopIOTimer(csb);
+ }
+ return;
+ }
+ stopIOTimer(csb);
+ }
+
+ /*
+ * Make sure we do not create a file when we need
+ * data from file, like copy disk startup-config
+ */
+ if ( (csb->which == COPY_DISK_STARTUP_CONFIG ) ) {
+ fileAccess = O_RDWR;
+ } else {
+ fileAccess = O_RDWR | O_CREAT;
+ }
+
+ /* Open the local file */
+ if ( (fd = open(fileName, fileAccess , 0644)) < 0 ) {
+ if (!(tftpPut || tftpGet) )
+ printf("Cannot open file %s!\n", fileName);
+ else
+ printf("Cannot open temporary file for writing!\n");
+
+ return;
+ }
+
+ error = 0 ;
+
+ switch(csb->which ) {
+
+ case COPY_DISK_STARTUP_CONFIG:
+ printf("Writing Startup Configuration from %s...", fileName);
+ /*
+ * This is defined in nv_common.c. Writes the configuration
+ * from NVRAM to the file descriptor 'fd'
+ */
+ if ( write_nv_config_from_fd( fd ) == ERROR ) {
+ printf("[Failed]\n") ;
+ } else {
+ printf("[OK]\n");
+ printf("You need to reboot the box for the configuration to"
+ " take effect\n");
+ }
+ close(fd);
+ break;
+
+ case COPY_STARTUP_CONFIG_DISK:
+ printf("Writing startup configuration to %s...", fileName);
+ csb->flags |= CONFIG_FILE;
+ SETOBJ(int,2)= fd;
+ nv_review( csb );
+ csb->flags &= ~CONFIG_FILE;
+ if ( GETOBJ(int, 2) == FALSE )
+ printf("[OK]\n");
+ else
+ printf("[Failed]\n");
+ close( fd );
+ break;
+
+ case COPY_RUNNING_CONFIG_DISK:
+ printf("Writing Current configuration to %s...", fileName);
+ if ( write_running_to_file( fd , ( csb->flags & HIDE_PASSWORDS) )
+ == OK )
+ printf("[OK]\n");
+ else
+ printf("[Failed]\n");
+ close( fd );
+ break;
+
+ case COPY_RUNNING_CONFIG_TFTP:
+ printf("Writing Current configuration to %s:%s...", tftpServerAddr,
+ remoteFileName);
+ if ( write_running_to_file( fd, ( csb->flags & HIDE_PASSWORDS ) )
+ == ERROR ) {
+ printf("[Failed] ( Configuration creation error)\n");
+ error = TRUE;
+ }
+ close( fd );
+ tftpPut = TRUE;
+ tftpGet = FALSE;
+ break;
+
+ case COPY_TFTP_STARTUP_CONFIG:
+ /* The entire TFTP Operation is done at the end */
+ printf("Writing Startup Configuration from %s:%s...", tftpServerAddr,
+ remoteFileName);
+ tftpPut = FALSE;
+ tftpGet = TRUE;
+ break;
+
+ case COPY_STARTUP_CONFIG_TFTP:
+ printf("Writing Startup configuration to %s:%s...", tftpServerAddr,
+ remoteFileName);
+ csb->flags |= CONFIG_FILE;
+ SETOBJ(int,2)= fd;
+ nv_review( csb );
+ csb->flags &= ~CONFIG_FILE;
+ close( fd );
+ error = GETOBJ(int, 2);
+ tftpPut = TRUE;
+ tftpGet = FALSE;
+ break;
+
+ default:
+ break;
+
+ }
+
+ if ( tftpPut || tftpGet ) {
+
+ /* Determine if it is 'get' or 'put' operation */
+ strcpy(buffer, ( tftpPut == TRUE )?"put":"get");
+
+ if ( !error ) {
+
+ /* The local temporary file would not have been opened
+ * for TFTP GET Operation yet or would have been closed
+ * in case of TFTP PUT Operation
+ */
+ if ( (fd = open(fileName, O_RDWR | O_CREAT, 0644)) < 0 ) {
+ printf("[Failed] ( Temporary file creation error)\n");
+ } else if ( tftpCopy( tftpServerAddr, 0, remoteFileName,
+ buffer, "binary", fd ) == ERROR ) {
+ printf("[Failed] ( TFTP Error)\n");
+ } else if ( tftpGet == TRUE ) {
+
+ /* We close the 'fd' just to make sure the buffers are
+ * flushed to the file
+ */
+ close(fd);
+
+ /* Got the configuration file from TFTP Server. Need
+ * to update the startup-configuration from the
+ * temporary file
+ */
+ if (!((( fd = open(fileName, O_RDWR | O_CREAT, 0644)) > 0 ) &&
+ ( write_nv_config_from_fd(fd) == OK ))) {
+ printf("[Failed]\n");
+ } else {
+ printf("[OK]\n");
+ printf("You need to reboot the box for the configuration "
+ "to take effect\n");
+ }
+ } else
+ printf("[OK]\n");
+ }
+ close( fd );
+
+ /* Remove the temporary file */
+ if ( fileName )
+ remove( fileName );
+ }
+}
+
+/*
+ * Write the running configuration to a file with
+ * file descriptor fd
+ */
+static STATUS write_running_to_file( int fd , uint flags)
+{
+ char *curcfg = NULL;
+ STATUS result = ERROR;
+
+ /*
+ * Dump the current configuration to our buffer
+ */
+ curcfg = nv_current_to_buffer( FALSE, PRIV_MAX, flags ) ;
+
+
+ if ( curcfg != NULL ) {
+ if ( write(fd, curcfg, strlen(curcfg)) < strlen(curcfg)) {
+ result = ( ERROR ) ;
+ }
+ PARSERfree(curcfg);
+ result = OK;
+ }
+ return( result );
+}
+
+
+int getTftpInput( char *pTftpServer, char *pFileName )
+{
+ char server[256] = "";
+ char fileName[PATH_MAX + 1] = "";
+ char buffer[1024] = "";
+
+ struct hostent *pHostEnt = NULL;
+ struct hostent hostEntry;
+ struct in_addr serverAddr;
+
+ int nbytes = 0;
+ int error = 0;
+ u_long addr;
+
+
+ printf("TFTP Server Address: ");
+ if ( ( nbytes =
+ read( STD_IN, server, (sizeof(server) - 1)) ) <= 0) {
+ if ( errnoOfTaskGet(0) == S_ioLib_CANCELLED ) {
+ return( RC_TIMEOUT );
+ } else {
+ return(ERROR );
+ }
+ }
+
+ server[nbytes - 1] = '\0';
+
+ if ( nbytes >= 256 ) {
+ printf("Hostname too long\n");
+ return(ERROR);
+ }
+
+ /* Verify if the Server specified is valid
+ * Check first to see if it is HOSTNAME. If
+ * it is not valid, check to see if it is a
+ * HOSTADDRESS. If both fail, then it is considered
+ * an invalid address
+ */
+ if ( ( pHostEnt =
+ gethostbyname_r(server, &hostEntry, buffer,
+ sizeof(buffer), &error )) == NULL) {
+ if ( ( pHostEnt = gethostbyaddr_r((char *)&addr, 4, AF_INET,
+ &hostEntry, buffer,
+ sizeof(buffer),
+ &error )) == NULL ) {
+ printf("Cannot resolve the TFTP Server Address "
+ "(Errno %d)\n", error);
+ return(ERROR);
+ }
+ }
+
+ bcopy(pHostEnt->h_addr_list[0], (char *)&serverAddr,
+ pHostEnt->h_length);
+
+ inet_ntoa_b(serverAddr, pTftpServer);
+
+ printf("Remote Filename: ");
+ if ( ( nbytes =
+ read( STD_IN, fileName,
+ PATH_MAX ) ) <= 0) {
+ if ( errnoOfTaskGet(0) == S_ioLib_CANCELLED ) {
+ return( RC_TIMEOUT );
+ } else {
+ return(ERROR );
+ }
+ }
+ fileName[nbytes - 1] = '\0';
+
+ if ( nbytes > PATH_MAX ) {
+ printf("Filename too long\n");
+ return(ERROR);
+ }
+
+ strcpy(pFileName, fileName);
+
+ return(OK);
+}
+
+#ifdef INCLUDE_TRACEROUTE
+/************************************************
+ *
+ * func: traceroute_command
+ *
+ * desc: cli traceroute callback func
+ *
+ ************************************************/
+extern int traceroute(char *host);
+
+void traceroute_command (parseinfo *csb)
+{
+ addrtype *pHost = GETOBJ(paddr, 1);
+ char host[INET_ADDR_LEN + 1 ];
+ struct in_addr address;
+
+ if ( martian(ntohl(pHost->ip_addr), MARTIAN_FLAG_IS_HOST) == TRUE ) {
+ printf("Not a valid Host Address\n");
+ return;
+ }
+
+ address.s_addr = pHost->ip_addr;
+
+ inet_ntoa_b(address, host );
+
+ traceroute( host);
+ return;
+}
+#endif
+#endif
+
+void exit_config_command( parseinfo *csb )
+{
+ parser_mode *alt_mode;
+ char *username = NULL;
+ char unknown_name[]="Unknown";
+
+ csb->giveConfigSem = TRUE;
+ if (csb->nvgen) {
+ if (csb->which == CMD_END) {
+ /* Reset buffer size
+ * to always save room for "\nend".
+
+ nv_write(TRUE, "%s\n", csb->nv_command); */
+ }
+ return;
+ }
+ alt_mode = get_alt_mode(csb->mode);
+ while (alt_mode) {
+ (void) mode_save_vars(csb);
+ csb->mode = alt_mode;
+ alt_mode = get_alt_mode(csb->mode);
+ }
+
+ csb->mode = exec_mode;
+
+#if 0
+ /* RAMS commented this for now */
+ if (!systemloading) {
+
+ username = getNameByUid(csb->uid);
+ if (username == NULL)
+ username = unknown_name;
+
+ if (csb->inFd == consoleFd) {
+ syslog(LOG_NOTICE, "Configured from console by %s", username);
+ } else {
+ syslog(LOG_NOTICE, "Configured from telnet session by %s",
+ username);
+ }
+ }
+#endif
+}
+
+
+/*
+ * Display the '?' help text for the parser
+ */
+void
+parser_help(parseinfo *csb)
+{
+ csb->MoreStatus = print_buf(csb->help_save,
+ FALSE,
+ !(csb->flags & CONFIG_HTTP),
+ NULL,
+ 0
+ );
+ csb->help_save.used = 0;
+ csb->visible_ambig.ambig[0] = '\0';
+ csb->visible_ambig.ambig_save[0] = '\0';
+ csb->hidden_ambig.ambig[0] = '\0';
+ csb->hidden_ambig.ambig_save[0] = '\0';
+}
+
+
+/*
+ * enable_command
+ */
+
+void enable_command (parseinfo *csb)
+{
+ uint level = GETOBJ(int,1);
+
+ /*
+ * If this was really the disable command, turn off wizardliness
+ * and return.
+ */
+ if (csb->which == CMD_DISABLE) {
+ if (level <= csb->priv) {
+ csb->priv = level;
+ /* SET_PRIV(stdio->privilege, level); */
+ if (parser_priv_debug) {
+ printf("\nPrivilege level set to %d",level);
+ /* CUR_PRIV(stdio->privilege)); */
+
+ }
+ } else {
+ printf("\nNew privilege level must be "
+ "less than current privilege level");
+ }
+ return;
+ }
+ /*
+ * RAMS: commented this for now
+
+ if ( !( isSuperUser( csb->uid ) ) ) {
+ printf("You need administrative privilege to enter privileged mode\n");
+ } else {
+ csb->priv = level;
+ }
+ */
+ csb->priv = level;
+ return;
+}
+
+/*
+ * Write the configuration to TFTP / DISK
+ */
+void write_config( parseinfo *csb )
+{
+ printf("\n Write config called");
+}
+
+
+/*
+ * manual_configure
+ * Query user for configuration file
+ */
+void manual_configure (parseinfo *csb)
+{
+ csb->priv = 0xf;
+ /*
+ * If we are not doing a "conf term" ("conf net" or "conf mem"),
+ * and we are not root, dont' let through
+ */
+ if ((csb->which != PARSER_CONF_TERM) &&
+ (csb->priv != PRIV_ROOT)) {
+ printf("\nInvalid privileges");
+ return;
+ }
+
+
+ switch (csb->which) {
+
+ case PARSER_CONF_TERM:
+ csb->mode = config_mode;
+ printf("Enter configuration commands, one per line. "
+ "End with CNTL/Z\n\n");
+ csb->break_chars = CONFIG_BREAKSET;
+ csb->batch_buf = NULL;
+ csb->resolvemethod = RES_MANUAL;
+ csb->flags = CONFIG_TERM;
+ config_dirty = TRUE;
+ csb->giveConfigSem = TRUE;
+ return;
+
+ default:
+ bad_parser_subcommand(csb, csb->which);
+ break;
+ }
+}
diff --git a/data/mnet/Common/cli/src/command_chain.c b/data/mnet/Common/cli/src/command_chain.c
new file mode 100644
index 0000000..d85d8c0
--- /dev/null
+++ b/data/mnet/Common/cli/src/command_chain.c
@@ -0,0 +1,73 @@
+#include <vxworks.h>
+#include <stdioLib.h>
+#include <tyLib.h>
+#include <taskLib.h>
+#include <errnoLib.h>
+#include <lstLib.h>
+#include <inetLib.h> /* for INET_ADDR_LEN */
+#include <timers.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <msgQLib.h>
+#include <sigLib.h>
+
+
+#include <../include/cli_parser_private.h>
+#include <../include/pstypes.h>
+#include <../include/psvxif.h>
+#include <../include/imsg.h>
+#include <../include/imc.h>
+#include <../include/address.h>
+#include <../include/parsertypes.h>
+#include <../include/config.h>
+#include <../include/parser_sim.h>
+#include <../include/parser.h>
+#include <../include/parser_defs_exec.h>
+#include <../include/parser_input.h>
+#include <../include/parser_sim.h>
+#include <../include/parser_util.h>
+#include <../include/parser_commands.h>
+#include <../include/nv.h>
+#include <../include/parser_errno.h>
+#include <../include/parser_ModNum.h>
+#include <../include/defs.h>
+#include <../include/parser_init.h>
+#include <../include/macros.h>
+#include <../include/parser_actions.h>
+#include <../include/parser_defs_config.h>
+
+/*
+ * Parse chains for Command exec commands
+ */
+#define ALTERNATE NONE
+#include "../include/exec_disable.h"
+#include "../include/exec_enable.h"
+#include "../include/exec_configure.h"
+/*#include "../include/exec_write.h" */
+LINK_POINT(command_exec_commands, ALTERNATE);
+#undef ALTERNATE
+
+#define ALTERNATE NONE
+/*#include "../include/exec_erase.h" */
+LINK_POINT(erase_commands, ALTERNATE);
+#undef ALTERNATE
+
+/*
+ * Parse chain registration array for Command
+ */
+static parser_extension_request command_chain_init_table[] = {
+ { PARSE_ADD_EXEC_CMD, &pname(command_exec_commands) },
+ { PARSE_ADD_ERASE_CMD, &pname(erase_commands) },
+ { PARSE_LIST_END, NULL }
+};
+
+
+/*
+ * command_parser_init - Initialize Command parser support
+ */
+void command_parser_init (void)
+{
+ parser_add_command_list(command_chain_init_table, "command");
+ return;
+}
diff --git a/data/mnet/Common/cli/src/debug.c b/data/mnet/Common/cli/src/debug.c
new file mode 100644
index 0000000..b8e2213
--- /dev/null
+++ b/data/mnet/Common/cli/src/debug.c
@@ -0,0 +1,342 @@
+#include <vxworks.h>
+#include <stdioLib.h>
+#include <lstLib.h>
+#include <stdlib.h>
+#include <inetLib.h>
+#include <timers.h>
+#include <ctype.h>
+#include <msgQLib.h>
+#include <sigLib.h>
+#include <logLib.h>
+
+#include <../include/cli_parser_private.h>
+#include <../include/pstypes.h>
+#include <../include/psvxif.h>
+#include <../include/imsg.h>
+#include <../include/imc.h>
+#include <../include/address.h>
+#include <../include/parsertypes.h>
+#include <../include/config.h>
+#include <../include/parser_sim.h>
+#include <../include/parser.h>
+#include <../include/parser_input.h>
+#include <../include/debug.h>
+#include <../include/sys_debug.h>
+#include <../include/parser_debug.h>
+#include <../include/mutex.h>
+
+
+#define __DECLARE_DEBUG_VARS__
+#include <../include/parser_debug_flags.h>
+
+/*
+ * debug_all_flag is set whenever "debug all" is in effect. Should be
+ * static, but I believe that screws up run-from-ROM in Cisco images...
+ * anyway, external users should use debug_all_p() to interrogate this
+ * flag.
+ */
+
+static boolean debug_all_flag = FALSE;
+extern mutex_t *pPrintDebugMutex;
+
+/*
+ * debug_init
+ * Initialize the debugging system
+ */
+
+void debug_init (void)
+{
+ debug_all_flag = FALSE;
+ sys_debug_init();
+}
+
+/*
+ * debug_all_p
+ * Tells the caller whether "debug all" is in effect. Used (at least) at
+ * subsystem initialization time to determine whether a subsystem should
+ * turn on all its debug flags.
+ */
+
+boolean debug_all_p (void)
+{
+ return(debug_all_flag);
+}
+
+
+/*
+ * debug_command
+ * Generic handler for all manner of "debug" and "undebug" commands.
+ * Any subsystem can use this routine to handle its debug flags as long
+ * as it uses an array of debug_item_type to describe them and as long
+ * as it sets up its parse chains correctly.
+ *
+ * csb->sense = TRUE for "debug", FALSE for "undebug".
+ * csb->which = index into flag definition array.
+ * GETOBJ(int,1) = mempointer to beginning of array...
+ */
+
+void debug_command (parseinfo *csb)
+{
+ int i;
+ const debug_item_type *debugarr;
+
+ debugarr = (debug_item_type *)GETOBJ(vptr,0);
+
+ if ( debugarr == NULL )
+ return;
+
+ /*
+ * Sanity check the index -- paranoia is truly a terrible scourge in
+ * these troubled times.
+ */
+ for (i=0; i < csb->which; i++) {
+ if (debugarr[i].var == NULL) {
+ bad_parser_subcommand(csb, csb->which);
+ return;
+ }
+ }
+ *(debugarr[csb->which].var) = csb->sense;
+
+ /* Confirm the change to the user */
+ debug_show_flag(*(debugarr[csb->which].var),
+ debugarr[csb->which].txt);
+}
+
+#if 0
+/*
+ * RAMS : commented this for now
+ */
+extern void debug_http_all();
+extern void debug_icp_all();
+extern void debug_log_all();
+extern void debug_translog_all();
+extern void debug_radius_all();
+extern void debug_tacacs_all();
+extern void debug_snmp_all();
+extern void debug_stat_all();
+extern void debug_wccp_all();
+extern void debug_wi_all();
+extern void debug_url_all();
+extern void debug_rule_all();
+extern void debug_sreg_all();
+extern void debug_https_all();
+extern void debug_authentication_all();
+#endif
+
+/*
+ * debug_all_cmd
+ * Handler for "debug all" and "undebug all". csb->sense is TRUE for "debug",
+ * FALSE for "undebug"
+ */
+
+void debug_all_cmd (parseinfo *csb)
+{
+ /* If we're about to start spewing huge amounts of debugging crap
+ * that might make the system unusable, make sure the user really
+ * wants it to happen...
+ */
+ if ((csb->sense) &&
+ (!yes_or_no("This may severely impact network performance. "
+ "Continue ",FALSE, TRUE )))
+ return;
+
+ debug_all_flag = csb->sense;
+
+ /* Declare an event so the subsystems can set their local flags */
+ invoke_debug_all(debug_all_flag);
+
+#if 0
+ /*
+ *RAMS: commented this for now
+ */
+ /* These modules haven't registered correctly */
+ /* This hack is the simplest way to fix the problem */
+ debug_http_all(csb->sense);
+ debug_icp_all(csb->sense);
+ debug_log_all(csb->sense);
+ debug_translog_all(csb->sense);
+ debug_radius_all(csb->sense);
+ debug_tacacs_all(csb->sense);
+ debug_snmp_all(csb->sense);
+ debug_stat_all(csb->sense);
+ debug_wccp_all(csb->sense);
+ debug_wi_all(csb->sense);
+ debug_url_all(csb->sense);
+ debug_rule_all(csb->sense);
+ debug_sreg_all(csb->sense);
+ debug_https_all(csb->sense);
+ debug_authentication_all(csb->sense);
+#endif
+ /* Confirm to the user */
+ printf("All possible debugging has been turned %s\n",
+ debug_all_flag ? "on" : "off");
+}
+
+/*
+ * show_debug
+ * Show the state of debugging everywhere in the system.
+ */
+
+void show_debug (void)
+{
+ if (debug_all_p()) {
+ printf("\"debug all\" is in effect.\n");
+ }
+ invoke_debug_show();
+}
+
+/*
+ * debug_show_flag
+ * Show the value of a single debugging flag in a standardized format.
+ * Used by subsystems that need to display individual flags, and when
+ * a flag is set or reset. The "flag" argument is the boolean value of
+ * the flag to display. "text" is a description of the debugging the
+ * flag controls.
+ */
+void debug_show_flag (boolean flag, char *text)
+{
+ printf("%s debugging is %s\n", text, flag ? "on" : "off");
+}
+
+/*
+ * debug_show_flags
+ * Show a whole array of flags. Called by subsystems do do their parts
+ * of "show debug". The "heading" argument contains a string that describes
+ * the category into which all the flags to be displayed fall. It will
+ * be displayed if and only if one or more of the flags is true. If the
+ * heading is non-null, all the flags under it will be indented.
+ */
+
+void debug_show_flags (const debug_item_type *array, const char *heading,
+ boolean printLevel )
+{
+ int i;
+ boolean hasheading = FALSE;
+ boolean hdisplayed = FALSE;
+ boolean printNewLine = FALSE;
+
+ if ((heading != NULL) && (*heading != '\0'))
+ hasheading = TRUE;
+ for (i = 0; array[i].var != (boolean *) NULL; i++) {
+ if (*(array[i].var)) {
+ if (hasheading && !hdisplayed) {
+ printf("%s:\n", heading);
+ hdisplayed = TRUE;
+ }
+ printf("%s%s debugging is %s", hasheading ? " " : "",
+ array[i].txt, (*array[i].var) ? "on" : "off");
+ printNewLine = TRUE;
+ if ( *(array[i].var) && printLevel ) {
+ printf(" (Level : %d)\n", *(array[i].var));
+ }
+ printf("\n");
+ }
+ }
+ if ( printNewLine )
+ printf("\n");
+}
+
+/*
+ * generic_debug_all
+ *
+ * a generic routine that <routine_name>_debug_all can call
+ * whenever anybody issues
+ * a "debug all" or "undebug all" command... or whenever you want to
+ * set the state of all the debug_items flags at once. The argument is
+ * TRUE for "debug all", FALSE for "undebug all".
+ */
+
+void generic_debug_all (const debug_item_type *debug_items, boolean flag)
+{
+ while (debug_items->var) {
+ *(debug_items->var) = flag;
+ debug_items++;
+ }
+}
+
+/*
+ * generic_debug_show
+ *
+ * a generic routine that <routine_name>_debug_show can call
+ * whenever anybody issues
+ * a "show debug" command...
+ */
+
+void generic_debug_show (const debug_item_type *debug_items,
+ const char* heading)
+{
+ debug_show_flags(debug_items, heading, FALSE );
+}
+
+
+STATUS generic_debug_init( const debug_item_type *debug_items ,
+ const char *heading )
+{
+
+ if ( add_debug_all(NULL, debug_items) == ERROR ) {
+ return(ERROR);
+ }
+ if ( add_debug_show(NULL, debug_items, heading) == ERROR ) {
+ return(ERROR);
+ }
+ return(OK);
+}
+
+
+int print_debug(char *fmt, ... )
+{
+ int fd = 0;
+ char *buffer = NULL;
+ int nbytes = 0;
+ va_list ap;
+ char *ptr = NULL;
+ /*
+ *following is commented by rams for now
+
+ mutex_lock (pPrintDebugMutex); */
+ va_start( ap, fmt );
+ nbytes = doprnt(NULL, NULL, fmt, ap, TRUE);
+
+ if ( nbytes > 0 ) {
+ buffer = ( char *)PARSERmalloc(sizeof(char) * (nbytes + 1)) ;
+ va_end( ap );
+ if ( buffer ) {
+ va_start( ap, fmt );
+ nbytes = doprnt(buffer, NULL, fmt, ap, TRUE);
+ va_end( ap );
+ } else {
+ /*
+ *following is commented by rams for now
+
+ mutex_unlock (pPrintDebugMutex); */
+ return(-1);
+ }
+ }
+
+ buffer[nbytes] = '\0';
+
+ /*
+ * RAMS: commented this for now
+ for ( fd = 0; fd < MAX_FDS ; fd++ ) {
+ if ( fdArray[fd] != 0 )
+ write( fdArray[fd], buffer, strlen(buffer) );
+ }
+ */
+
+ /* We need this to make sure that the buffer
+ * does not contain "\r\n" ( example SMTP Response )
+ *
+ * Syslog will filter out additional "\n"s
+ */
+ if ( (ptr = strchr(buffer, '\r') ) != NULL ) {
+ *ptr = ' ';
+ }
+ logMsg("%s",buffer,0,0,0,0,0);
+
+ PARSERfree( buffer );
+ /*
+ *following is commented by rams for now
+ mutex_unlock (pPrintDebugMutex); */
+
+ return(nbytes);
+}
diff --git a/data/mnet/Common/cli/src/exec.c b/data/mnet/Common/cli/src/exec.c
new file mode 100644
index 0000000..e1556a3
--- /dev/null
+++ b/data/mnet/Common/cli/src/exec.c
@@ -0,0 +1,389 @@
+#include <vxworks.h>
+#include <stdioLib.h>
+#include <tyLib.h>
+#include <taskLib.h>
+#include <errnoLib.h>
+#include <lstLib.h>
+#include <inetLib.h> /* for INET_ADDR_LEN */
+#include <timers.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <msgQLib.h>
+#include <sigLib.h>
+
+
+#include <../include/cli_parser_private.h>
+#include <../include/pstypes.h>
+#include <../include/psvxif.h>
+#include <../include/imsg.h>
+#include <../include/imc.h>
+#include <../include/address.h>
+#include <../include/parsertypes.h>
+#include <../include/config.h>
+#include <../include/parser_sim.h>
+#include <../include/parser.h>
+#include <../include/parser_defs_exec.h>
+#include <../include/parser_input.h>
+#include <../include/parser_sim.h>
+#include <../include/parser_util.h>
+#include <../include/parser_commands.h>
+#include <../include/nv.h>
+#include <../include/parser_errno.h>
+#include <../include/parser_ModNum.h>
+#include <../include/defs.h>
+#include <../include/parser_init.h>
+#include <../include/macros.h>
+#include <../include/parser_actions.h>
+
+
+#if 0
+#include <parser/parser.h>
+#include <parser/parser_actions.h>
+#include <parser/parser_defs_config.h>
+#include <parser/parser_errno.h>
+#include <parser/parser_undo.h>
+#include <envLib.h>
+#include <dosfs/uvfatif.h>
+
+
+extern char **buildargv_k( char *, int *, int);
+extern tclMain( int, int, int, int, int, int, int, int );
+
+
+/* BuildPrompt
+ * Build promt at csb->prompt.
+ * This routine is global as it is used by SNA network management
+ */
+void BuildPrompt (parseinfo *csb, tt_soc *tty)
+{
+ int prompt_length; /* leftover length of prompt */
+
+ char Pprompt[MAXPROMPTLEN + 1];
+ char sHostName[MAXHOSTNAMELEN + 1];
+
+ gethostname(sHostName, sizeof(sHostName));
+
+ strncpy(Pprompt, sHostName, MAXPROMPTLEN);
+ Pprompt[MAXPROMPTLEN] = '\0';
+
+ if ( Pprompt[0] != '\0' ) {
+ ;
+ } else if ( sysBootParams.targetName &&
+ *(sysBootParams.targetName) ) {
+ strncpy(Pprompt, sysBootParams.targetName, MAXPROMPTLEN );
+ Pprompt[MAXPROMPTLEN] = '\0';
+ } else {
+ PSpanic("This Cannot be possible ? ? ? \n");
+ strcpy( Pprompt, "Cache Engine");
+ }
+
+ /* Build the prompt. */
+ if (config_prompt || (csb->mode == exec_mode) ||
+ !(csb->flags & CONFIG_TERM)) {
+ const char *src;
+ char *dst, trailer;
+
+ trailer = (csb->priv > PRIV_USER) ? '#' : '>';
+ dst = csb->prompt;
+ src = Pprompt;
+ prompt_length = MAXPROMPTLEN;
+ while (*src && prompt_length--) {
+ *dst++ = *src++;
+ }
+
+ /* dst += reg_invoke_parse_cli_prompt(tty->parse_cli_type,
+ csb, dst, &prompt_length);
+ */
+ src = get_mode_prompt(csb);
+ if (src && (prompt_length > 3)) {
+ prompt_length -= 3;
+ *dst++ = '(';
+ while (*src && prompt_length--) {
+ *dst++ = *src++;
+ }
+ *dst++ = ')';
+ } else {
+ /*
+ * Prompt is too long, so cut off end
+ */
+ if (prompt_length <= 0) {
+ dst = &csb->prompt[MAXPROMPTLEN-1];
+ }
+ }
+ *dst++ = trailer;
+ *dst = '\0';
+ } else {
+ csb->prompt[0] = '\0';
+ }
+}
+
+
+
+
+void terminalCmd( parseinfo *csb )
+{
+
+ int realOutFd = csb->savedFd;
+
+ csb->giveConfigSem = TRUE;
+
+ if ( csb->nvgen ) {
+ nv_write( ( ( csb->which == TERM_LENGTH) &&
+ ( terminalLength != LINES )) ,
+ "%s %d", csb->nv_command, terminalLength);
+ return;
+ }
+
+ if ( csb->which == TERM_LENGTH ) {
+ parse_undo(csb, "terminal length %d", terminalLength);
+ terminalLength = GETOBJ(int, 1);
+ return;
+ } else if ( csb->which == TERM_MONITOR) {
+ if ( realOutFd == consoleFd ) {
+ printf("Console is always monitored\n");
+ return;
+ }
+
+ if ( csb->sense ) {
+ if ( registerFd( realOutFd ) != RC_OK )
+ printf("Cannot monitor the terminal\n");
+ } else {
+ if ( unregisterFd( realOutFd ) != RC_OK );
+ printf("Cannot stop monitoring the terminal\n");
+ }
+ }
+}
+
+static void
+tclshTask(int argc, const char *const*argv, parseinfo *csb)
+{
+ SEM_ID sema;
+ long moduleId;
+ parseinfo *tclCsb;
+ char *uvfatBuffer = NULL;
+ tpUVFATFREEFUNC pFreeFunc = NULL;
+ char *pCwd = NULL;
+ tUID uid = csb->uid;
+ int err;
+ tCOMSIM *pComSim = NULL;
+ short rc = RC_OK;
+ int inFd = csb->inFd;
+ int outFd = csb->outFd;
+ extern int setenv(const char *, const char *);
+ extern int tclStart(int, const char *const *, const char *const*, const char *);
+
+ ioSetTerminalMode(inFd, IO_LINE_MODE);
+ ioTaskStdSet( 0, STD_IN, inFd );
+ ioTaskStdSet( 0, STD_OUT, outFd );
+ ioTaskStdSet( 0, STD_ERR, outFd );
+
+ if (setUid(uid) == FALSE) {
+ fprintf( stderr, "Invalid UID Obtained %d\n", uid);
+ fflush( stderr );
+ return;
+ }
+
+ moduleId = ASSIGN_MODULE_ID;
+ sema = PSsemCCreate(PS_DEFAULT_COUNT_SEM_FLAG, 0);
+ if (imc_add(&moduleId, sema, taskIdSelf()) == ERROR) {
+ PSpanic("Cannot add TCL Task to IMC\n");
+ }
+ if ( (tclCsb = get_csb("TCL CSB")) == NULL ) {
+ PSpanic("NULL CSB For TCL!!!!\n");
+ }
+
+ tclCsb->flags = CONFIG_TERM;
+ tclCsb->priv = csb->priv;
+ tclCsb->uid = csb->uid;
+ tclCsb->inFd = inFd;
+ tclCsb->outFd = outFd;
+ tclCsb->ioTaskId = csb->ioTaskId;
+ tclCsb->io_timer = csb->io_timer;
+ *(tclCsb->line) = '\0';
+
+ /* Get the current working directory of the I/O Source
+ */
+ pCwd = getTaskCWD_k( ((parseinfo*)csb)->ioTaskId, &pFreeFunc ) ;
+ if ( pCwd ) {
+ setCWD( pCwd );
+ pFreeFunc( pCwd );
+ pFreeFunc = NULL;
+ }
+
+ fflush( stdin ) ;
+ fflush( stdout ) ;
+
+ uvfatBuffer = getHomeDir_k(&pFreeFunc);
+ setenv( "HOME", (uvfatBuffer == NULL)?mVOLNAME:uvfatBuffer );
+ pFreeFunc( uvfatBuffer );
+ uvfatBuffer = NULL;
+ pFreeFunc = NULL;
+
+ uvfatBuffer = getNameByUid_k( uid , &pFreeFunc);
+ setenv( "USER", uvfatBuffer );
+ pFreeFunc( uvfatBuffer );
+ uvfatBuffer = NULL;
+ pFreeFunc = NULL;
+
+ err = tclStart(argc, argv, NULL, NULL);
+
+ /*
+ * Clean up the mess and
+ * Send a message back to the parser
+ * to let them know we are done.
+ */
+ if (csb != NULL) {
+ ((parseinfo *)csb)->MoreStatus = RC_OK ;
+ pComSim = NULL;
+ pComSim = mGETSIM( sizeof( tCOMSIM ) ) ;
+
+ if (pComSim == NULL)
+ {
+ printf("Not enough memory...please try later\n");
+ rc = RC_ERR;
+ }
+ else
+ {
+ mFILL_COM_SIM( pComSim, moduleId, \
+ ((parseinfo *)csb)->moduleId,
+ IO_WAIT_COMPLETE_IND, 0, NULL, 0, RC_OK );
+
+ mPOST_SIM_NIND( pComSim, rc );
+ }
+
+ free_csb(&(tclCsb));
+
+ if ( imc_remove( moduleId ) != RC_OK ) {
+ printf("tTcl: Cannot remove IMC \n");
+ }
+ if ( semDelete( sema ) == ERROR ) {
+ printf("tTcl: Could not delete TCL Semaphore\n");
+ }
+ sema = NULL;
+ tclCsb = NULL;
+ }
+
+ /* Check if we got to free the argv[] in our case */
+ if (argv != NULL) {
+
+ /* Free argv[argc - 1] till argv[0] */
+
+ while ( --argc >= 0 ) {
+ PSkfree( ((char **)argv)[argc], M_TCL);
+ }
+
+ PSkfree( (char **) argv, M_TCL );
+
+ }
+
+ /* Require this for CGI
+ * This effectively puts EOF in the FD which
+ * may be the terminating condition of 'fgets' or
+ * 'read'
+ */
+ if ( outFd ) {
+ ioctl(outFd, FIOCANCEL, 0);
+ write(outFd, "", 0 );
+ }
+}
+
+
+void tclshCommand( parseinfo *csb )
+{
+ char **argv = NULL;
+ int argc = 0;
+ char *pArg = GETOBJ(string, 1 );
+ char *temp = NULL;
+ int tid = 0;
+ char tname[20];
+
+ temp = PARSERmalloc((strlen(pArg) + strlen("tclsh") + 3));
+ strcpy(temp,"tclsh");
+
+ if ( strcmp( pArg, "") != 0 ){
+ strcat(temp, " ");
+ strcat(temp, pArg);
+ }
+
+ /* Note: argv is NOT allocated from Parser Pool */
+ argv = buildargv_k( temp, &argc, M_TCL ) ;
+
+ PARSERfree( temp );
+
+ if ( argv == NULL ) {
+ csb->MoreStatus = RC_OK;
+ return;
+ }
+
+ sprintf(tname, "tTcl%u", csb->outFd);
+ tid = PStaskSpawn(tname, PS_STD_PRIORITY, VX_PRIVATE_ENV|VX_FP_TASK,
+ PS_ENORMOUS_STACK, (FUNCPTR) tclshTask, (int)argc,
+ (int)argv,(int)csb,
+ 0,0,0,0,0,0,0);
+ if (tid == ERROR) {
+ csb->MoreStatus = RC_OK;
+ return;
+ }
+
+ /* Indicate to the source that it has a child that it has
+ * to take care of
+ */
+ csb->pIndex = (void*) tid;
+
+ /* Wait till TCL completes */
+ csb->MoreStatus = RC_WAIT;
+}
+#endif
+
+
+/*
+ * exec_help_command
+ *
+ * Provide the user with an introduction to the interactive
+ * help mechanism of the new parser.
+ */
+void exec_help_command (parseinfo *csb)
+{
+ csb->giveConfigSem = TRUE;
+
+ if (csb->nvgen) {
+ return;
+ }
+
+ printf("\nHelp may be requested at any point in a command by entering"
+ "\na question mark '?'. If nothing matches, the help list will"
+ "\nbe empty and you must backup until entering a '?' shows the"
+ "\navailable options."
+ "\nTwo styles of help are provided:"
+ "\n1. Full help is available when you are ready to enter a"
+ "\n command argument (e.g. 'show ?') and describes each possible"
+ "\n argument."
+ "\n2. Partial help is provided when an abbreviated argument is entered"
+ "\n and you want to know what arguments match the input"
+ "\n (e.g. 'show stat?'.)\n");
+}
+
+void show_help_command (parseinfo *csb)
+{
+ printf("\n%% Type \"%s ?\" for a list of subcommands\n", "show");
+ parser_return(csb, S_parser_SYNTAX_INCOMPLETE);
+}
+
+void clear_help_command (parseinfo *csb)
+{
+ printf("\n%% Type \"%s ?\" for a list of subcommands\n", "clear");
+ parser_return(csb, S_parser_SYNTAX_INCOMPLETE);
+}
+
+void debug_help_command (parseinfo *csb)
+{
+ printf("\n%% Type \"%s ?\" for a list of subcommands\n", "debug");
+ parser_return(csb, S_parser_SYNTAX_INCOMPLETE);
+}
+
+void show_version (parseinfo *csb)
+{
+ /* printVersion(); */
+ printf("\n SHOW version called");
+}
diff --git a/data/mnet/Common/cli/src/exec_chain.c b/data/mnet/Common/cli/src/exec_chain.c
new file mode 100644
index 0000000..6b5dc7c
--- /dev/null
+++ b/data/mnet/Common/cli/src/exec_chain.c
@@ -0,0 +1,160 @@
+#include <vxworks.h>
+#include <stdioLib.h>
+#include <tyLib.h>
+#include <taskLib.h>
+#include <errnoLib.h>
+#include <lstLib.h>
+#include <inetLib.h> /* for INET_ADDR_LEN */
+#include <timers.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <msgQLib.h>
+#include <sigLib.h>
+
+
+#include <../include/cli_parser_private.h>
+#include <../include/pstypes.h>
+#include <../include/psvxif.h>
+#include <../include/imsg.h>
+#include <../include/imc.h>
+#include <../include/address.h>
+#include <../include/parsertypes.h>
+#include <../include/config.h>
+#include <../include/parser_sim.h>
+#include <../include/parser.h>
+#include <../include/parser_defs_exec.h>
+#include <../include/parser_input.h>
+#include <../include/parser_sim.h>
+#include <../include/parser_util.h>
+#include <../include/parser_commands.h>
+#include <../include/nv.h>
+#include <../include/parser_errno.h>
+#include <../include/parser_ModNum.h>
+#include <../include/defs.h>
+#include <../include/parser_init.h>
+#include <../include/macros.h>
+#include <../include/parser_actions.h>
+/*
+ * Parse chains for Exec help commands
+ */
+#define ALTERNATE NONE
+#include "../include/exec_help.h"
+LINK_POINT(global_commands, ALTERNATE);
+#undef ALTERNATE
+
+
+/*
+ * Parse chains for Exec exec commands
+ */
+#define ALTERNATE NONE
+/*#include "../include/exec_type.h"*/
+/*#include "../include/exec_copy.h"*/
+/*#include "../include/exec_reload.h"*/
+LINK_POINT(exec_exec_commands, ALTERNATE);
+#undef ALTERNATE
+
+
+/*
+ * Parse chains for Exec show commands
+ */
+#define ALTERNATE NONE
+/*#include "../include/exec_show_version.h" */
+/*#include "../include/exec_show_debugging.h"*/
+/*#include "../include/exec_show_techsupport.h"*/
+LINK_POINT(exec_show_cmds, ALTERNATE);
+#undef ALTERNATE
+
+/*
+ * Parse chains for Exec copy commands
+ */
+#define ALTERNATE NONE
+/*#include "../include/exec_copy_techsupport.h"*/
+LINK_POINT(exec_copy_commands, ALTERNATE);
+#undef ALTERNATE
+
+
+/*
+ * Parse chains for copy running-configuration
+ */
+#define ALTERNATE NONE
+/*#include "../include/exec_copy_running_cfg.h"*/
+LINK_POINT(copy_running_cfg_cmds, ALTERNATE);
+#undef ALTERNATE
+
+/*
+ * Parse chains for copy startup-config
+ */
+#define ALTERNATE NONE
+/*#include "../include/exec_copy_startup_cfg.h"*/
+LINK_POINT(copy_startup_cfg_cmds, ALTERNATE);
+#undef ALTERNATE
+
+#define ALTERNATE NONE
+EOLS(exec_tftp_startup_eol, write_config, COPY_TFTP_STARTUP_CONFIG);
+KEYWORD(exec_copy_tftp_startup, exec_tftp_startup_eol, ALTERNATE,
+ "startup-config", "TFTP Server to Startup(NVRAM) Configuration",
+ PRIV_ROOT);
+LINK_POINT(copy_tftp_startup_cmds, exec_copy_tftp_startup);
+#undef ALTERNATE
+
+
+#define ALTERNATE NONE
+EOLS(exec_disk_startup_eol, write_config, COPY_DISK_STARTUP_CONFIG);
+STRING(exec_disk_startup_string, exec_disk_startup_eol, no_alt,
+ OBJ(string, 1), "Filename of existing configuration" );
+KEYWORD(exec_copy_disk_startup, exec_disk_startup_string, ALTERNATE,
+ "startup-config", "Disk to Startup(NVRAM) Configuration",
+ PRIV_ROOT);
+LINK_POINT(copy_disk_startup_cmds, exec_copy_disk_startup);
+#undef ALTERNATE
+
+/*
+ * Parse chain registration array for Exec
+ */
+static parser_extension_request exec_chain_init_table[] = {
+ { PARSE_ADD_EXEC_CMD, &pname(exec_exec_commands) },
+ { PARSE_ADD_SHOW_CMD, &pname(exec_show_cmds) },
+ { PARSE_ADD_GLOBAL_CMD, &pname(global_commands) },
+ { PARSE_ADD_COPY_CMD, &pname(exec_copy_commands) },
+ { PARSE_ADD_COPY_RUNNING_CMD, &pname(copy_running_cfg_cmds) },
+ { PARSE_ADD_COPY_STARTUP_CMD, &pname(copy_startup_cfg_cmds) },
+ { PARSE_ADD_COPY_DISK_CMD, &pname(copy_disk_startup_cmds) },
+ { PARSE_ADD_COPY_TFTP_CMD, &pname(copy_tftp_startup_cmds) },
+ { PARSE_LIST_END, NULL }
+};
+
+/*
+ * exec_parser_init - Initialize Exec parser support
+ */
+void exec_parser_init (void)
+{
+ static int exec_parser_initialized = FALSE;
+
+ if (!exec_parser_initialized) {
+ /* copy ... */
+#if 0
+ RAMS: commented this for now
+ parser_add_link_point(PARSE_ADD_COPY_CMD, "copy",
+ &pname(exec_copy_extend_here));
+
+ /* copy run-config ... */
+ parser_add_link_point(PARSE_ADD_COPY_RUNNING_CMD,
+ "copy running-config *",
+ &pname(exec_copy_running_extend_here));
+ parser_add_link_point(PARSE_ADD_COPY_RUNNING_FILE_CMD,
+ "copy running-config *",
+ &pname(exec_copy_running_file_extend_here));
+ /* copy start-config ... */
+ parser_add_link_point(PARSE_ADD_COPY_STARTUP_CMD,
+ "copy startup-config *",
+ &pname(exec_copy_startup_extend_here));
+ parser_add_link_point(PARSE_ADD_COPY_STARTUP_FILE_CMD,
+ "copy startup-config *",
+ &pname(exec_copy_startup_file_extend_here));
+#endif
+ parser_add_command_list(exec_chain_init_table, "exec");
+
+ exec_parser_initialized = TRUE;
+ }
+}
diff --git a/data/mnet/Common/cli/src/imc.c b/data/mnet/Common/cli/src/imc.c
new file mode 100644
index 0000000..7f21945
--- /dev/null
+++ b/data/mnet/Common/cli/src/imc.c
@@ -0,0 +1,513 @@
+#include <vxworks.h>
+#include <stdioLib.h>
+#include <taskLib.h>
+#include <lstLib.h>
+#include <inetLib.h> /* for INET_ADDR_LEN */
+#include <stdlib.h>
+#include <string.h>
+
+
+#include <../include/pstypes.h>
+#include <../include/psvxif.h>
+#include <../include/platdef.h>
+#include <../include/imsg.h>
+#include <../include/imc.h>
+
+/*
+ ** EXTERNAL VARIABLES
+ */
+
+/*
+ ** GLOBAL VARIABLES
+ */
+LIST *pimcListHead = NULL; /* Pointer to IMC ListHead */
+tUOCTET4 freeIndex = LAST_MODULE + 1; /* Free Index for dynamic IMC */
+SEM_ID freeIndexSemId; /* Protect freeIndex */
+tpIMC_QANCHOR pimcglp[MAX_IMC_COUNT]; /* Array for Indexing */
+boolean imcInited = FALSE;
+tOCTET4 imc_global_count = 0; /* keeps track of the TOTAL number
+ of entries in the imc */
+/*
+ ** STATIC VARIABLES
+ */
+
+/*
+ **
+ ** Prototypes
+ **
+ */
+static tOCTET2 imc_cleanup( tOCTET4 );
+
+#ifndef USE_IMC_MACROS
+static LIST* imc_get_queue( tOCTET4 , IMC_QUEUE_TYPE );
+static void imc_change_global_count( tOCTET2 );
+tOCTET2 imc_post_sim( tpCOMSIM , IMC_QUEUE_TYPE );
+void imc_get_sim( tpCOMSIM *, tUOCTET4 , IMC_QUEUE_TYPE );
+#endif
+
+/*COMMENTS*********************************************************
+ *
+ * Func: imc_init
+ *
+ * Desc: Initialize the IMC Anchor and global count Semaphore
+ *
+ * Inputs: None
+ *
+ * Outputs: RC_OK
+ *
+ *
+ *END*********************************************************************/
+
+tOCTET2 imc_init( void )
+{
+ if ( !imcInited ) {
+ tUOCTET2 index = 0;
+ imcInited = TRUE;
+
+ /* Create global Mutex Semaphores */
+
+ imc_global_count = 0;
+
+ freeIndexSemId = PSsemMCreate ( PS_DEFAULT_MUTEX_SEM_FLAG |
+ SEM_DELETE_SAFE);
+
+ if ( freeIndexSemId == NULL ) {
+ printf("imc_init:Could not create Free index semaphore\n");
+ return RC_ERR;
+ }
+
+ /* The head of the Anchor Block List */
+ if ( ( pimcListHead = (LIST*)IMCcalloc(1,sizeof(LIST))) == NULL ) {
+ printf("imc_init:Could not create global list\n");
+ PSsemDelete ( freeIndexSemId );
+ return RC_ERR;
+ }
+
+ lstInit(pimcListHead);
+
+ for ( index = 0; index < MAX_IMC_COUNT ; index++ )
+ pimcglp[index] = NULL;
+ }
+ return ( RC_OK );
+}
+
+
+/*COMMENTS*********************************************************
+ *
+ * Func: imc_add
+ *
+ * Desc: Dynamically allocate IMC for ** SUBTASKS **
+ * Well known modules * MUST * announce their Module ID
+ * as *pIndex whereas SUBTASKS send it as ASSIGN_MODULE_ID
+ * (-1 )
+ * Inputs: tUOCTET
+ *
+ * Outputs: RC_OK / RC_ERR
+ *
+ *
+ *END*********************************************************************/
+
+tOCTET2 imc_add( tpOCTET4 pIndex, tSEMAPHORE semId, tTASKID taskId )
+{
+
+
+ if ( PSsemTake ( freeIndexSemId, WAIT_FOREVER ) == ERROR ) {
+ panic("imc_add:Could not take free index semaphore\n");
+ return ( RC_ERR );
+ }
+
+ {
+ tUOCTET4 origIndex = 0;
+ tpIMC_QANCHOR pimcElement = NULL;
+
+ if ( pIndex == NULL ) {
+ printf("imc_add:NULL Index passed to imc_add\n");
+ PSsemGive( freeIndexSemId );
+ return (RC_ERR);
+ }
+
+
+ if ( *pIndex == ASSIGN_MODULE_ID ) {
+
+ origIndex = freeIndex;
+ freeIndex %= MAX_IMC_COUNT;
+ freeIndex = ( freeIndex == 0 )
+ ? (LAST_MODULE + 1)
+ : freeIndex;
+
+ while ( pimcglp[freeIndex] != NULL ) {
+ freeIndex++;
+ freeIndex %= MAX_IMC_COUNT;
+
+ /* If wrap-around, do not assign any "Well-known"
+ * Module Ids
+ */
+ freeIndex = ( freeIndex == 0 )
+ ? (LAST_MODULE + 1)
+ : freeIndex;
+
+ /* Make sure that we have space to add ! */
+ if ( origIndex == freeIndex ) {
+ printf("imc_add:Could not add new IMC\n");
+ PSsemGive ( freeIndexSemId );
+ return (RC_ERR);
+ }
+
+ }
+ *pIndex = freeIndex;
+ }
+
+ if ( pimcglp[*pIndex] != NULL ) {
+ printf("IMC for module %ld exists!\n", *pIndex );
+ return (RC_ERR);
+ }
+
+ pimcElement = (tpIMC_QANCHOR) IMCmalloc( sizeof( tIMC_QANCHOR ) );
+ memset( (void *)pimcElement, 0, sizeof(tIMC_QANCHOR));
+ if ( pimcElement == NULL ) {
+ printf("imc_add:Calloc failed from IMC Element\n");
+ PSsemGive ( freeIndexSemId );
+ return (RC_ERR);
+ }
+
+ pimcElement->taskId = taskId;
+ pimcElement->semId = semId;
+ pimcElement->workCount = 0;
+ lstInit(&(pimcElement->pimc_req ));
+ lstInit(&(pimcElement->pimc_ind ));
+ lstInit(&(pimcElement->pimc_exp_req ));
+ lstInit(&(pimcElement->pimc_exp_ind ));
+
+ pimcglp[*pIndex] = pimcElement;
+
+ lstAdd( pimcListHead, &(pimcElement->imc_element) );
+
+ if ( PSsemGive ( freeIndexSemId ) == ERROR ) {
+ panic ("imc_add:Could not give free index semaphore\n");
+ return ( RC_ERR );
+ }
+
+ return ( RC_OK );
+ }
+} /* end imc_init */
+
+
+
+/*COMMENTS*********************************************************
+ *
+ * Func: imc_remove
+ *
+ * Desc: Dynamically de-allocate IMC for ** SUBTASKS **
+ *
+ * Inputs: tUOCTET4
+ *
+ * Outputs: RC_OK / RC_ERR
+ *
+ *END*********************************************************************/
+
+tOCTET2 imc_remove( tUOCTET4 index )
+{
+
+ if ( PSsemTake ( freeIndexSemId, WAIT_FOREVER ) == ERROR ) {
+ panic("imc_remove:Could not take free index semaphore\n");
+ return ( RC_ERR );
+ }
+
+ if ( pimcglp[index] == NULL ) {
+ printf("Cannot find IMC Entry\n");
+ PSsemGive ( freeIndexSemId );
+ return (RC_ERR);
+ }
+
+ imc_cleanup( index );
+
+ if ( index > LAST_MODULE )
+ freeIndex = index;
+
+ pimcglp[index] = NULL;
+
+ if ( PSsemGive ( freeIndexSemId ) == ERROR ) {
+ panic ( "imc_remove:Could not give free index semaphore\n");
+ return ( RC_ERR );
+ }
+
+ return ( RC_OK );
+
+} /* imc_remove */
+
+
+/*COMMENTS*********************************************************
+ *
+ * Func: imc_term
+ *
+ * Desc: Release imc queues
+ *
+ * Inputs: None.
+ *
+ * Outputs: RC_OK
+ *
+ *
+ *END*********************************************************************/
+
+void imc_term()
+{
+ /* We assume that each layer has cleaned up their
+ interactions without generating any more */
+ int index = 0;
+
+ /* Deque & Cleanup elements from the lists */
+ /* in the anchor block */
+ for ( index = 0; index < MAX_IMC_COUNT ; index++ ){
+ if ( pimcglp[index] != NULL ) {
+ imc_cleanup( index );
+ }
+ }
+
+ lstFree( pimcListHead );
+
+ PSsemDelete( freeIndexSemId );
+
+}/*end imc_term */
+
+/*COMMENTS*********************************************************
+ *
+ * Func: imc_cleanup
+ *
+ * Desc: Dequeue elements, if any, from IMC lists.
+ *
+ * Inputs: index to the global array.
+ *
+ * Outputs: RC_OK
+ *
+ *
+ *END*********************************************************************/
+tOCTET2 imc_cleanup ( tOCTET4 index )
+{
+ /* This is already protected by freeIndexSemId */
+ /* Hence no need to Mutex this section */
+
+ NODE* element = (NODE *)NULLP;
+
+ /* Should Possibly be freeing the elements from non-empty queues*/
+
+ while ( ( element = lstGet( &(pimcglp[index]->pimc_req) ) ) != NULLP )
+ ; /* Do Nothing */
+
+ while ( ( element = lstGet( &(pimcglp[index]->pimc_ind) ) ) != NULLP )
+ ; /* Do Nothing */
+
+
+ while ( ( element = lstGet(&(pimcglp[index]->pimc_mgmt) ) ) != NULLP )
+ ; /* Do Nothing */
+
+ while ( ( element = lstGet(&(pimcglp[index]->pimc_exp_req) ) ) != NULLP )
+ ; /* Do Nothing */
+
+ while ( ( element = lstGet(&(pimcglp[index]->pimc_exp_ind) ) ) != NULLP )
+ ; /* Do Nothing */
+
+ lstFree(&pimcglp[index]->pimc_req);
+ lstFree(&pimcglp[index]->pimc_ind);
+ lstFree(&pimcglp[index]->pimc_mgmt);
+ lstFree(&pimcglp[index]->pimc_exp_req);
+ lstFree(&pimcglp[index]->pimc_exp_ind);
+
+ lstDelete( pimcListHead, &((pimcglp[index])->imc_element) );
+
+ IMCfree ( pimcglp[index] );
+
+ return ( RC_OK );
+}
+
+
+#ifndef USE_IMC_MACROS
+
+/*COMMENTS*********************************************************
+ *
+ * Func: imc_post_sim
+ *
+ * Desc: Post a Sim to the Given Queue of the Module
+ *
+ * Inputs: Post Type enum POST_QUEUE
+ * SIM tpCOMSIM pComSim
+ *
+ * Outputs: RC_OK ( or )
+ * RC_ERR
+ *
+ *
+ *END*********************************************************************/
+
+tOCTET2 imc_post_sim( tpCOMSIM pComSim, IMC_QUEUE_TYPE queue )
+{
+ tOCTET2 rc = RC_OK;
+ LIST *pListHead = NULL;
+
+ if ( PSsemTake( freeIndexSemId,WAIT_FOREVER ) == ERROR) {
+ panic("mPOST_SIM:Could not get semaphore\n");
+ rc = RC_ERR;
+ }
+ else if ( (pimcglp[pComSim->destid] == NULL ) ) {
+ printf("%s: ", taskName( taskIdSelf() ));
+ printf("NULL IMC Anchor for Destination %ld",(pComSim)->destid );
+ rc = RC_ERR;
+ }
+ else {
+
+ pListHead = imc_get_queue( pComSim->destid, queue );
+ if ( pListHead == NULL ) {
+ panic ("mPOST_SIM: Error occurred getting Queue to POST\n");
+ rc = RC_ERR;
+ }else {
+ lstAdd(pListHead, &(pComSim->simq));
+ imc_change_global_count( INCREMENT );
+ ++((pimcglp[pComSim->destid])->workCount);
+
+ if ( PSsemGive( mMID2SEM(pComSim->destid))== ERROR ) {
+ panic("mPOST_SIM:Could not give Task semaphore\n");
+ rc = RC_ERR;
+ }
+ }
+ }
+
+ if ( PSsemGive( freeIndexSemId ) == ERROR) {
+ panic("mPOST_SIM_NREQ:Could not give Index semaphore\n");
+ rc = RC_ERR;
+ }
+
+ return ( rc );
+}
+
+/*COMMENTS*********************************************************
+ *
+ * Func: imc_get_queue
+ *
+ * Desc: Get the Listhead of the Queue from a Module
+ *
+ * Inputs: Module Id tOCTET4 moduleId
+ * Queue Type enum IMC_QUEUE_TYPE
+ *
+ * Outputs: LIST*
+ * NULL on Error
+ *
+ *
+ *
+ *END*********************************************************************/
+
+static LIST* imc_get_queue( tOCTET4 moduleId, IMC_QUEUE_TYPE queue )
+{
+ LIST* pListHead = NULL;
+
+ switch ( queue ) {
+
+ case MGMT_QUEUE:
+ pListHead = ( mMID2MGMT(moduleId) );
+ break;
+
+ case NIND_QUEUE:
+ pListHead = ( mMID2NIND(moduleId) );
+ break;
+
+ case EIND_QUEUE:
+ pListHead = ( mMID2EIND(moduleId) );
+ break;
+
+ case NREQ_QUEUE:
+ pListHead = ( mMID2NREQ(moduleId) );
+ break;
+
+ case EREQ_QUEUE:
+ pListHead = ( mMID2EREQ(moduleId) );
+ break;
+
+ default:
+ pListHead = ( NULL );
+
+ }
+
+ return ( pListHead );
+}
+
+
+/*COMMENTS*********************************************************
+ *
+ * Func: imc_change_global_count
+ *
+ * Desc: Change the global work count
+ *
+ * Inputs: INCREMENT / DECREMENT
+ *
+ * Outputs: None
+ *
+ *END*********************************************************************/
+void imc_change_global_count( tOCTET2 action )
+{
+ if ( action == INCREMENT )
+ ++imc_global_count;
+ else if ( action == DECREMENT ) {
+ --imc_global_count;
+ if ( imc_global_count < 0 ) {
+ panic("mCHANGEGLOBALCOUNT: Negative Count\n"); \
+ }
+ } else {
+ printf("\n%s: ", taskName( taskIdSelf() ));\
+ printf("mCHANGEGLOBALCOUNT:Invalid Action\n"); \
+ }
+}
+
+
+/*COMMENTS*********************************************************
+ *
+ * Func: imc_get_sim
+ *
+ * Desc: Get a Sim to the Module
+ *
+ * Inputs: Post Type enum POST_QUEUE
+ * Module Id tOCTET2 moduleID
+ * SIM tpCOMSIM pComSim
+ *
+ * Outputs: None
+ *
+ *
+ *END*********************************************************************/
+
+void imc_get_sim( tpCOMSIM *ppComSim, tUOCTET4 moduleId, IMC_QUEUE_TYPE queue )
+{
+ tOCTET2 rc = RC_OK;
+ LIST* pListHead = NULL;
+ tOCTET2 workCount = 0;
+
+ if ( PSsemTake( freeIndexSemId,WAIT_FOREVER ) == ERROR) {
+ panic("mGET_SIM:Could not get semaphore\n");
+ rc = RC_ERR;
+ }
+ else if ( (pimcglp[moduleId] == NULL ) ) {
+ printf("%s: ", taskName( taskIdSelf() ));
+ printf("NULL IMC Anchor for Destination %ld",moduleId );
+ rc = RC_ERR;
+ }
+ else {
+ pListHead = imc_get_queue( moduleId, queue );
+ if ( pListHead == NULL ) {
+ panic ("mGET_SIM: Error occurred getting Queue to GET\n");
+ rc = RC_ERR;
+ }else {
+
+ workCount = lstCount( pListHead );
+ if ( workCount < 0 ) {
+ panic("mGET_SIM:Negative Work count obtained\n");
+ } else if ( workCount > 0 ) {
+ *ppComSim = ( tpCOMSIM ) lstGet( pListHead );
+ imc_change_global_count( DECREMENT );
+ --((pimcglp[moduleId])->workCount);
+ } else
+ *ppComSim = NULL;
+
+ if ( PSsemGive( freeIndexSemId ) == ERROR ) {
+ panic("mGET_SIM:Could not give Free Index semaphore\n");
+ rc = RC_ERR;
+ }
+ }
+ }
+}
+
+#endif
diff --git a/data/mnet/Common/cli/src/imsg.c b/data/mnet/Common/cli/src/imsg.c
new file mode 100644
index 0000000..7c1fd98
--- /dev/null
+++ b/data/mnet/Common/cli/src/imsg.c
@@ -0,0 +1,138 @@
+#include <vxworks.h>
+#include <stdioLib.h>
+#include <taskLib.h>
+#include <lstLib.h>
+#include <inetLib.h> /* for INET_ADDR_LEN */
+#include <stdlib.h>
+#include <string.h>
+
+
+#include <../include/pstypes.h>
+#include <../include/psvxif.h>
+
+#include <../include/imsg.h>
+
+
+/*COMMENTS*********************************************************
+ *
+ * Func: imsg_getsim
+ *
+ * Desc: Allocate Memory and create a Semaphore for Ownership
+ *
+ * Inputs: tUOCTET4 size Size of Memory to Allocate
+ *
+ * Outputs: tpCOMSIM Pointer to the SIM or NULL if allocate failed
+ *
+ *
+ *END*********************************************************************/
+
+tpCOMSIM imsg_getsim (tOCTET4 size)
+{
+ tpCOMSIM pComSim = NULL;
+
+ pComSim = (tpCOMSIM)IMCcalloc(1, size);
+
+ if ( !pComSim )
+ {
+ PSprintf("imsg_getsim(): mGETSIM Failed!; size=%ld\n", size);
+ return ( NULL );
+ }
+ else {
+ pComSim->ownerSemId = PSsemMCreate( PS_DEFAULT_MUTEX_SEM_FLAG );
+ if ( pComSim->ownerSemId == NULL ) {
+ PSpanic ( "imsg_getsim : Could not create owner id semaphore\n");
+ return ( NULL );
+ }
+ }
+
+ return ( pComSim );
+
+}/* end imsg_getsim */
+
+
+
+/*COMMENTS*********************************************************
+ *
+ * Func: imsg_zerosim
+ *
+ * Desc: Zero-out SIM
+ *
+ * Inputs: tpCOMSIM pSim SIM to zero-out
+ *
+ * Outputs: NONE
+ *
+ * Outputs: For debugging aid. getsim does memset
+ *
+ *END*********************************************************************/
+
+void imsg_zerosim( tpCOMSIM pSim )
+{
+ if ( !pSim ) {
+ printf("%s(mZEROSIM):", taskName( taskIdSelf() ));
+ printf("NULL SIM passed\n");
+ return;
+ }
+ pSim->simq.next = NULL;
+ pSim->simq.previous = NULL;
+ pSim->ownership = 0;
+ pSim->origid = 0;
+ pSim->destid = 0;
+ pSim->requestid = 0;
+ pSim->serviceid = 0;
+ pSim->status = 0;
+ pSim->ownerSemId = NULL;
+ pSim->pLayerSim = NULL;
+
+}
+
+#ifndef USE_IMC_MACROS
+
+/*COMMENTS*********************************************************
+ *
+ * Func: imsg_freesim
+ *
+ * Desc: Free SIM
+ *
+ * Inputs: tpCOMSIM pSim SIM to Free
+ *
+ * Outputs: NONE
+ *
+ * Outputs:
+ *
+ *END*********************************************************************/
+
+void imsg_freesim( tpCOMSIM pSim )
+{
+
+ /* Make sure no one does it at the same time */
+ if ( PSsemTake(pSim->ownerSemId, WAIT_FOREVER ) == ERROR ) {
+ PSpanic("Could not Take Ownership Semaphore ");
+ }
+ else if (pSim->ownership == 0) {
+
+ /* We are the sole owner... */
+ if(pSim->pLayerSim ) {
+ /* We cannot assume that this has been created using
+ * IMC type of memory. This should be done using
+ * malloc/calloc ?
+ */
+ PSfree(pSim->pLayerSim);
+ pSim->pLayerSim = NULL;
+ }
+
+ PSsemDelete(pSim->ownerSemId);
+ IMCfree(pSim);
+
+ }
+ else {
+
+ /* Someone else also wants it */
+ --(pSim->ownership);
+
+ if (PSsemGive(pSim->ownerSemId) == ERROR ) {
+ PSpanic("mFREESIM:Could not Give Ownership Semaphore\n");
+ }
+ }
+}
+
+#endif
diff --git a/data/mnet/Common/cli/src/ip_address.c b/data/mnet/Common/cli/src/ip_address.c
new file mode 100644
index 0000000..5f7331f
--- /dev/null
+++ b/data/mnet/Common/cli/src/ip_address.c
@@ -0,0 +1,958 @@
+#include "parser_if.h"
+
+#define IOS_PARSER
+#include <inetLib.h>
+
+/*#include <cenetdb.h> for inetGetHostByName() reference */
+/* #include <cacheapp/utils.h> for remove_ws() reference */
+
+static char *ip_addr_short_help (parseinfo *, uint, void * );
+static char *parser_xlate_errcode(int errorCode);
+
+boolean match_ip_addr (parseinfo *, char *, int *, void *, int , uint, void *);
+
+boolean subnetzero_enable;
+
+void ip_address_init( void )
+{
+ subnetzero_enable = FALSE;
+ parser_add_address(ADDR_IP, ip_addr_short_help, match_ip_addr);
+}
+
+char *ip_addr_short_help (parseinfo *csb, uint flag, void *idb )
+{
+ if (flag & ADDR_NAME_LOOKUP) {
+ return("Hostname or A.B.C.D");
+ } else {
+ return("A.B.C.D");
+ }
+}
+
+boolean match_ip_addr (parseinfo *csb, char *buf, int *pi, void *addr_pointer,
+ int in_help, uint flag, void *idb)
+{
+ addrtype *addrp = (addrtype *)addr_pointer;
+ ushort num[4];
+ boolean matched;
+ int init_ptr = *pi;
+
+
+ if (match_decimal(buf, 0, 255, pi, &num[0]) &&
+ match_char(buf, pi, '.') &&
+ match_decimal(buf, 0, 255, pi, &num[1]) &&
+ match_char(buf, pi, '.') &&
+ match_decimal(buf, 0, 255, pi, &num[2]) &&
+ match_char(buf, pi, '.') &&
+ match_decimal(buf, 0, 255, pi, &num[3])) {
+
+ addrp->ip_addr = ((((ulong) num[0]) << 24) |
+ (((ulong) num[1]) << 16) |
+ (((ulong) num[2]) << 8) |
+ ((ulong) num[3]));
+ matched = TRUE;
+ } else {
+ matched = FALSE;
+ }
+
+ if (matched) {
+ addrp->type = ADDR_IP;
+ addrp->length = ADDRLEN_IP;
+ return(TRUE);
+ }
+ return(FALSE);
+}
+/*
+ * remove_ws
+ * Remove leading and trailing whitespace
+ */
+
+char *
+remove_ws (char *s)
+{
+ char *x;
+
+ /* Check for null string */
+ if (!s) {
+ return(s);
+ }
+
+ /* Remove leading whitespace */
+ while ((*s == ' ') || (*s == '\t')) {
+ s++;
+ }
+
+ /* Move to end of string */
+ x = s;
+ while (*x) {
+ x++;
+ }
+
+ /* Remove trailing whitespace */
+ x--;
+ while ((*x == ' ') || (*x == '\t')) {
+ *x = '\0';
+ x--;
+ }
+ return(s);
+}
+
+
+/*
+ * parser_ipaddr_or_hostname
+ *
+ * This is a utility function that is used by both the CLI parser and
+ * the GUI so that ipaddress and hostnames can be handled in an
+ * indentical manner.
+ */
+
+/*
+??? WHAT SHOULD THE INTERFACE BE - RETURN ERRORCODE OR RETURN ERROR AND
+ SET "errno"?
+*/
+
+/* If doing cli processing, then pInputStr points to the start of the
+ * ipaddr (or possibly hostname) field within the entire cli parse
+ * buffer for the command (i.e., other fields may following in the buffer).
+ * If doing gui processing, then pInputStr points to the start of
+ * a null terminated string which contains only the ipaddr field
+ * (or possibly hostname).
+ */
+
+int
+parser_ipaddr_or_hostname (char *pInputStr, int *pOffset, ulong flagsParm,
+ pIpAddr_t pIpAddrInfo, char **ppErrMsg)
+{
+ int currOffset; /* for match_decimal & match_char apis
+ * which increment currOffset as buffer
+ * pointed to by pInputStr is parsed
+ * NOTE: Only interesting to cli
+ */
+ ushort num[4]; /* for match_decimal/match_char apis */
+ /* RESOLV_PARAMS_S resolvParms; for resolvParamsGet() api */
+ struct in_addr ipaddrTemp; /* for inet_ntoa_b() api */
+ char *pHostName; /* ptr to dynamically allocated buff */
+ int tempOffset; /* for get_name() api */
+ ulong martianFlags = 0; /* flags for martian() api */
+ int i;
+
+ /* If doing processing for the GUI,
+ * then remove any white space from the string and
+ * return an error if the resultant string is null.
+ * Note that removing white space may alter the
+ * caller's buffer if white space was removed from
+ * the end of the string.
+ * Note that in the case of a null string, the ip address
+ * data structure is reset because the caller may want
+ * to do processing even in the case of a null string.
+ */
+ if ((flagsParm & IPADDR_CLI_PROCESSING) != IPADDR_CLI_PROCESSING) {
+ pInputStr = remove_ws(pInputStr);
+ if (strlen(pInputStr) == 0) {
+ pIpAddrInfo->ipAddrNetOrder = 0;
+ pIpAddrInfo->ipAddrHostOrder = 0;
+ pIpAddrInfo->ipAddrStr[0] = '\0';
+ *ppErrMsg = parser_xlate_errcode(S_parser_SYNTAX_NULL_STRING);
+ return (S_parser_SYNTAX_NULL_STRING);
+ }
+ }
+
+ /* Track the current offset into the caller's buffer in a temporary
+ * variable in case match_decimal() or match_char() fails and we need
+ * to start at the beginning of the field again if it can be considered
+ * a hostname.
+ */
+
+ currOffset = *pOffset;
+
+ /* Check if this is an ip address in decimal dotted notation */
+
+ if (match_decimal(pInputStr, 0, 255, &currOffset, &num[0]) &&
+ match_char(pInputStr, &currOffset, '.') &&
+ match_decimal(pInputStr, 0, 255, &currOffset, &num[1]) &&
+ match_char(pInputStr, &currOffset, '.') &&
+ match_decimal(pInputStr, 0, 255, &currOffset, &num[2]) &&
+ match_char(pInputStr, &currOffset, '.') &&
+ match_decimal(pInputStr, 0, 255, &currOffset, &num[3])) {
+
+ /* If doing processing for the GUI, then return an
+ * error if the character after the last valid
+ * ip address character is not either the null
+ * terminator of a white space character (i.e.,
+ * a space or tab).
+ *
+ * Note that for CLI processing, the check is not
+ * done because the parser itself handles it and
+ * puts the help indicator character (^) exactly
+ * at the bad character following a valid ip
+ * address. If an error was returned here for
+ * CLI processing also, the result would be that
+ * the help indicator character would be at the
+ * beginning of the ip address which is less
+ * desirable.
+ */
+
+ if ( (flagsParm & IPADDR_CLI_PROCESSING) != IPADDR_CLI_PROCESSING ) {
+
+ if (( *(pInputStr + currOffset) != '\0' ) &&
+ ( *(pInputStr + currOffset) != ' ' ) &&
+ ( *(pInputStr + currOffset) != '\t' )) {
+ *ppErrMsg = parser_xlate_errcode(
+ S_parser_SYNTAX_INVALID_IPADDR_FORMAT);
+ return (S_parser_SYNTAX_INVALID_IPADDR_FORMAT);
+ }
+ }
+
+ /* Input string an ip address in dotted-decimal notation.
+ * Save the result in the following three different formats:
+ * 1. unsigned long integer in network byte order
+ * 2. unsigned long integer in host byte order
+ * 3. character string in dotted-decimal notation
+ */
+
+ /* Save in network byte order */
+
+#if BYTE_ORDER == BIG_ENDIAN
+ pIpAddrInfo->ipAddrNetOrder = ((((ulong) num[0]) << 24) |
+ (((ulong) num[1]) << 16) |
+ (((ulong) num[2]) << 8) |
+ ((ulong) num[3]));
+
+#elif BYTE_ORDER == LITTLE_ENDIAN
+ pIpAddrInfo->ipAddrNetOrder = ((((ulong) num[3]) << 24) |
+ (((ulong) num[2]) << 16) |
+ (((ulong) num[1]) << 8) |
+ ((ulong) num[0]));
+
+#else /* force a compilation error if BTYE_ORDER is not defined */
+#error Unknown BYTE_ORDER
+#endif
+
+ /* Save ip address in host byte order */
+ pIpAddrInfo->ipAddrHostOrder = ntohl(pIpAddrInfo->ipAddrNetOrder);
+
+ /* Save ip address as a null terminated dotted-decimal string. */
+ ipaddrTemp.s_addr = pIpAddrInfo->ipAddrNetOrder;
+ inet_ntoa_b(ipaddrTemp, pIpAddrInfo->ipAddrStr);
+
+ /* Update the caller's offset into the input string. */
+ *pOffset = currOffset;
+
+ }
+#if 0
+else {
+
+ /* If input string can be not considered a hostname,
+ * then update the caller's offset into the parsed string
+ * and return an error.
+ */
+
+ if ((flagsParm & IPADDR_HOSTNAME_ALLOWED) != IPADDR_HOSTNAME_ALLOWED) {
+ *pOffset = currOffset;
+ *ppErrMsg =
+ parser_xlate_errcode(S_parser_SYNTAX_INVALID_IPADDR_FORMAT);
+ return (S_parser_SYNTAX_INVALID_IPADDR_FORMAT);
+ }
+
+ /* Treat the input string as a hostname.
+ * Make a copy of the hostname from the beginning of the field and
+ * verify the string is well-formed for a hostname.
+ */
+
+ pHostName = PARSERmalloc(PARSEBUF + 1);
+ if (pHostName == NULL) {
+ *ppErrMsg =
+ parser_xlate_errcode(S_parser_RESOURCE_ALLOCATION_ERROR);
+ if ((flagsParm & IPADDR_CLI_PROCESSING) == IPADDR_CLI_PROCESSING) {
+ printf("%s\n", *ppErrMsg);
+ }
+ return (S_parser_RESOURCE_ALLOCATION_ERROR);
+ }
+
+ if (get_name(&pInputStr[*pOffset],
+ pHostName, &tempOffset, PARSEBUF) == FALSE) {
+ PARSERfree(pHostName);
+ *ppErrMsg =
+ parser_xlate_errcode(S_parser_SYNTAX_INVALID_HOSTNAME_FORMAT);
+ return (S_parser_SYNTAX_INVALID_HOSTNAME_FORMAT);
+ }
+
+ /* If the cli is just processing help, there is no more work.
+ * Update the caller's offset into the input string and return
+ */
+ if ((flagsParm & IPADDR_CLI_IN_HELP) == IPADDR_CLI_IN_HELP) {
+ *pOffset += tempOffset;
+ PARSERfree(pHostName);
+ return (OK); /* note there is no ipaddr in info structure */
+ }
+
+ if (name_verify(pHostName) == FALSE) {
+ PARSERfree(pHostName);
+ *ppErrMsg =
+ parser_xlate_errcode(S_parser_SYNTAX_INVALID_HOSTNAME_FORMAT);
+ return (S_parser_SYNTAX_INVALID_HOSTNAME_FORMAT);
+ }
+
+ /* If there are no ip name servers configured to do the DNS lookup,
+ * then return an error.
+ */
+ resolvParms.nameServersAddr[0][0] = NULL; /* init before api call */
+ resolvParamsGet(&resolvParms); /* DNS resolver api call */
+ if (resolvParms.nameServersAddr[0][0] == NULL) {
+ *ppErrMsg = parser_xlate_errcode(S_parser_IPADDR_NO_NAME_SERVER);
+ if ((flagsParm & IPADDR_CLI_PROCESSING) == IPADDR_CLI_PROCESSING) {
+ printf("%s \"%s\"\n", *ppErrMsg, pHostName);
+ }
+ PARSERfree(pHostName);
+ return (S_parser_IPADDR_NO_NAME_SERVER);
+ }
+
+ for (i = 0; i < MAXNS; i++)
+ {
+ if (resolvParms.nameServersAddr[i][0] != '\0')
+ {
+ if (OK ==
+ ping(resolvParms.nameServersAddr[i], 1, PING_OPT_SILENT))
+ break;
+ }
+ }
+
+ if (i == MAXNS)
+ {
+ printf("Cannot communicate with any ip name-server\n");
+ return (S_parser_IPADDR_NO_NAME_SERVER);
+ }
+
+ if ((flagsParm & IPADDR_CLI_PROCESSING) == IPADDR_CLI_PROCESSING) {
+ printf("Translating \"%s\" using configured ip name-server(s)...",
+ pHostName);
+ }
+
+ /* Do the DNS lookup on the input hostname.
+ * The inetGetHostByName() function looks in the local DNS
+ * cache first (if it is on) and if the hostname is not found,
+ * then it consults the DNS resolver.
+ * If successful, the return value is the ip address u_long
+ * in network byte order.
+ * The inetGetHostByName() function is thread-safe.
+ */
+
+ pIpAddrInfo->ipAddrNetOrder = NULL;
+ /*RAMS: commented this for now
+ * inetGetHostByName(pHostName,strlen(pHostName));
+ */
+
+ if (pIpAddrInfo->ipAddrNetOrder == NULL) {
+ if ((flagsParm & IPADDR_CLI_PROCESSING) == IPADDR_CLI_PROCESSING) {
+ printf("Failed\n");
+ }
+ PARSERfree(pHostName);
+ *ppErrMsg =
+ parser_xlate_errcode(S_parser_IPADDR_HOSTNAME_LOOKUP_FAILED);
+ return (S_parser_IPADDR_HOSTNAME_LOOKUP_FAILED);
+ }
+
+ /* Save the ip address in two other formats:
+ * 1. unsigned long integer in host byte order
+ * 2. character string in dotted-decimal notation
+ */
+
+ /* Save ip address in host byte order */
+ pIpAddrInfo->ipAddrHostOrder = ntohl(pIpAddrInfo->ipAddrNetOrder);
+
+ /* Save ip address in dotted-decimal notation. */
+ ipaddrTemp.s_addr = pIpAddrInfo->ipAddrNetOrder;
+ inet_ntoa_b(ipaddrTemp, pIpAddrInfo->ipAddrStr);
+
+ if ((flagsParm & IPADDR_CLI_PROCESSING) == IPADDR_CLI_PROCESSING) {
+ printf("%s[OK]\n", pIpAddrInfo->ipAddrStr);
+ }
+
+ /* Update the offset into the caller's buffer. */
+ *pOffset += tempOffset;
+
+ PARSERfree(pHostName);
+ }
+#endif
+
+ /* Check if we test Default Routing
+ * Default Routing allows 0.0.0.0 ip address
+ * test it and return OK if address is 0.0.0.0
+ */
+ if ((flagsParm & IPADDR_DEFAULT_ROUTING ) ==
+ IPADDR_DEFAULT_ROUTING ) {
+
+ if ( (num[3] == 0) && (num[2] == 0) && (num[1] == 0) && (num[0] == 0) ) {
+ *ppErrMsg = parser_xlate_errcode(OK);
+ return (OK);
+ }
+ }
+
+ /* The caller's structure pointed to by pIpAddrInfo is updated.
+ * If caller did not request the Martian ip address test,
+ * then there is no more work to do so return success.
+ */
+
+ if ((flagsParm & IPADDR_MARTIAN_TEST_REQUIRED) !=
+ IPADDR_MARTIAN_TEST_REQUIRED) {
+ *ppErrMsg = parser_xlate_errcode(OK);
+ return (OK);
+ }
+
+ /* Perform Martian ip address test based on the caller's input flags. */
+
+ if ((flagsParm & IPADDR_MARTIAN_IS_HOST_ADDRESS) ==
+ IPADDR_MARTIAN_IS_HOST_ADDRESS) {
+ martianFlags |= MARTIAN_FLAG_IS_HOST;
+ }
+
+ if ((flagsParm & IPADDR_MARTIAN_MULTICAST_ALLOWED) ==
+ IPADDR_MARTIAN_MULTICAST_ALLOWED) {
+ martianFlags |= MARTIAN_FLAG_MULTICAST_ALLOWED;
+ }
+
+ if (martian(pIpAddrInfo->ipAddrHostOrder, martianFlags) == TRUE) {
+ *ppErrMsg = parser_xlate_errcode(S_parser_IPADDR_RESERVED);
+ return (S_parser_IPADDR_RESERVED);
+ }
+ else {
+ *ppErrMsg = parser_xlate_errcode(OK);
+ return (OK);
+ }
+}
+
+/* The following table is used by parser_xlate_errcode() below to
+ * translate a parser error code that can possibly be returned by the
+ * parser_ipaddress_or_hostname() function into a string that can be
+ * used to format an error message.
+ * This feature of parser_ipaddress_or_hostname() is used by the GUI
+ * so that it can display specific error messages to the administrator.
+ */
+
+struct xlateInfo {
+ int errCode; /* error code */
+ char *pErrMsg; /* pointer to error message for errcode */
+} static parser_xlateTable[] = {
+ { OK,
+ "Success" },
+ { S_parser_SYNTAX_NULL_STRING,
+ "Host is a null string" },
+ { S_parser_SYNTAX_INVALID_IPADDR_FORMAT,
+ "IP address is malformed" },
+ { S_parser_SYNTAX_INVALID_HOSTNAME_FORMAT,
+ "Hostname is malformed" },
+ { S_parser_IPADDR_RESERVED,
+ "Host address is not valid because it is reserved" },
+ { S_parser_IPADDR_NO_NAME_SERVER,
+ "No ip name-server configured for DNS lookup of hostname" },
+ { S_parser_IPADDR_HOSTNAME_LOOKUP_FAILED,
+ "DNS lookup failed for hostname" },
+ { S_parser_RESOURCE_ALLOCATION_ERROR,
+ "Internal resource allocation error" },
+ { S_parser_SYNTAX_INVALID_NETMASK_FORMAT,
+ "Netmask is malformed" },
+ { S_parser_SYNTAX_INVALID_NETMASK_CONTIGUOUS,
+ "Netmask binary format should have contiguous 1" },
+ { S_parser_SYNTAX_INVALID_NETMASK_IPADDR_MISMATCH,
+ "Netmask inconsistent with destination address" },
+};
+
+#define ERRMSG_UNKNOWN "Unknown error occurred"
+#define MAXXLATES (sizeof (parser_xlateTable) / sizeof (parser_xlateTable[0]))
+
+static char *
+parser_xlate_errcode(int errorCode)
+{
+ register int i;
+
+ for (i = 0; i < MAXXLATES; i++) {
+ if (errorCode == parser_xlateTable[i].errCode) {
+ return (parser_xlateTable[i].pErrMsg);
+ }
+ }
+
+ /* errorCode was not in table, so return a default error message */
+ return (ERRMSG_UNKNOWN);
+}
+
+
+
+
+/*
+ * martian
+ * Returns "TRUE" if the address is one of Mill's Martians, i.e., it is not
+ * a valid IP address for a host (if MARTIAN_FLAG_IS_HOST is TRUE) or network
+ * if (MARTIAN_FLAG_IS_HOST is FALSE). An IP address is not valid if it
+ * is one of the reserved IP addresses.
+ *
+ * "martianFlag" contains various flags provided by the caller which dictate
+ * how the martian checking is performed. See h/parser/address.h for the
+ * flag definitions and meaning.
+ */
+
+/* The following table is used by martian() to determine which IP addresses
+ * are considered invalid because they are reserved.
+ */
+
+struct martiantype {
+ ipaddrtype address; /* potential bad address */
+ ipaddrtype mask; /* address mask */
+ tinybool net; /* network check */
+ tinybool valid_entry; /* TRUE == this entry in table is valid */
+ /* FALSE == this entry in table is not valid */
+} static martians[] = {
+
+/* Description of special addresses
+ * Each entry in martian() table notes which case applies (if any)
+ *
+ * case i - network id = all bits 0; host id = any
+ * Note: For Class A (00.x.x.x), these are reserved addresses,
+ * including the address 0.0.0.0
+ * For Class B (128.0.x.x) and Class C (192.0.0.x),
+ * IANA has assigned registered users.
+ *
+ * case ii - network id = all bits 1; host id = any
+ * Note: For Class A (127.x.x.x) these address are used
+ * as internal host loopback addresses.
+ * For Class B (191.255.x.x) and Class C (223.255.255.x),
+ * these addresses are reserved.
+ *
+ * case iii - network id = any valid netid; host id = all bits 0
+ * Note: Identifies an entire network; not a valid host address.
+
+ * case iv - network id = any valid netid; host id = all bits 1
+ * Directed broadcast to specified network.
+ *
+ * case v - network id = all bits 1; host id = all bits 1
+ * Limited broadcast address.
+ * A datagram with this address is never forwared outside
+ * the network or subnetwork of the source.
+ *
+ * case vi - Class D (224.x.x.x) - the entire class is reserved for
+ * multicast addresses (the low order 24 bits represent
+ * the multicast group ID).
+ *
+ * case vii - Class E (240.x.x.x - 255.x.x.x) - the entire class is
+ * reserved for future use.
+ */
+
+/*
+ * Limited Broadcast Address
+ */
+ {0xFFFFFFFF, 0xFFFFFFFF, FALSE, TRUE}, /* 255.255.255.255, 255.255.255.255
+ * case v - reserved */
+
+/*
+ * Class A specials
+ */
+ {0x00000000, 0xFF000000, FALSE, TRUE}, /* 0.0.0.0, 255.0.0.0
+ * case i - reserved */
+ {0x7F000000, 0xFF000000, FALSE, TRUE}, /* 127.0.0.0, 255.0.0.0
+ * case ii - reserved
+ * internal host loopback */
+ {0x00000000, 0x80FFFFFF, TRUE, TRUE}, /* 0.0.0.0, 128.255.255.255
+ * case iii - network address */
+ {0x00FFFFFF, 0x80FFFFFF, FALSE, TRUE}, /* 0.255.255.255, 128.255.255.255
+ * case iv - directed broadcast */
+
+/*
+ * Class B specials
+ */
+ {0xBFFF0000, 0xFFFF0000, FALSE, TRUE}, /* 191.255.0.0, 255.255.0.0
+ * case ii - reserved */
+ {0x80000000, 0xC000FFFF, TRUE, TRUE}, /* 128.0.0.0, 192.0.255.255
+ * case iii - network address */
+ {0x8000FFFF, 0xC000FFFF, FALSE, TRUE}, /* 128.0.255.255, 192.0.255.255
+ * case iv - directed broadcast */
+
+/*
+ * Class C specials
+ */
+ {0xDFFFFF00, 0xFFFFFF00, FALSE, TRUE}, /* 223.255.255.0, 255.255.255.0
+ * case ii - reserved */
+ {0xC0000000, 0xE00000FF, TRUE, TRUE}, /* 192.0.0.0, 224.0.0.255
+ * case iii - network address */
+ {0xC00000FF, 0xE00000FF, FALSE, TRUE}, /* 192.0.0.255, 224.0.0.255
+ * case iv - directed broadcast */
+
+/*
+ * Class D
+ */
+ {0xE0000000, 0xF0000000, FALSE, TRUE}, /* 224.0.0.0, 240.0.0.0
+ * case vi - the entire class is
+ * reserved for multicast addresses */
+
+/*
+ * Class E
+ */
+ {0xF0000000, 0xF0000000, FALSE, TRUE}, /* 240.0.0.0, 240.0.0.0
+ * case vii - the entire class is
+ * reserved for future use */
+};
+
+#define MAXMARTIANS (sizeof (martians) / sizeof (martians[0]))
+#define CLASS_D_ADDRESS 0xE0000000
+
+boolean
+martian (register ipaddrtype address, ulong martianFlags)
+{
+ register int i;
+
+ for (i = 0; i < MAXMARTIANS; i++) {
+ if ((address & martians[i].mask) == martians[i].address) {
+
+ /* If the table entry is marked invalid, then skip it */
+ if (martians[i].valid_entry == FALSE) {
+ continue;
+ }
+
+ /* If this is a Class D multicast address and
+ * caller specified multicast address are allowed,
+ * then this address is not consider an invalid address.
+ */
+ if (martians[i].address == CLASS_D_ADDRESS) {
+ if ((martianFlags & MARTIAN_FLAG_MULTICAST_ALLOWED) ==
+ MARTIAN_FLAG_MULTICAST_ALLOWED) {
+ return (FALSE); /* caller's address is not a martian */
+ }
+ else {
+ return (TRUE); /* caller's address is a martian */
+ }
+ }
+
+ /* If the caller specified that the address
+ * being check may be a network address and
+ * this address is OK as a network address
+ * then continue checking the rest of the table.
+ * Else, the caller's address is considered a martian.
+ */
+ if (((martianFlags & MARTIAN_FLAG_IS_HOST) !=
+ MARTIAN_FLAG_IS_HOST) &&
+ (martians[i].net == TRUE)) {
+ continue; /* continue checking the table */
+ }
+ else {
+ return (TRUE); /* it's a martian */
+ }
+ }
+ }
+ /* Passed all table checks, so address must not be reserved ip address. */
+ return (FALSE);
+}
+
+
+/*
+ * mask_contiguous
+ * Return TRUE if the given mask is left contiguous, FALSE otherwise.
+ */
+
+boolean mask_contiguous (ipaddrtype mask)
+{
+ while ((mask & 0xff000000) == 0xff000000)
+ mask <<= 8;
+ while (mask & 0x80000000)
+ mask <<= 1;
+ if (mask)
+ return(FALSE);
+ return(TRUE);
+}
+
+/*
+ * get_majormask
+ * Given an address, return the mask of major network number.
+ */
+
+ipaddrtype get_majormask (ipaddrtype address)
+{
+ if (!address) /* net 0.0.0.0 */
+ return(0); /* mask 0.0.0.0 */
+ if (!(address & CLASS_A_BIT)) /* Class A network */
+ return(CLASS_A_MASK);
+ else if (!(address & CLASS_B_BIT)) /* Class B network */
+ return(CLASS_B_MASK);
+ else if (!(address & CLASS_C_BIT)) /* Class C network */
+ return(CLASS_C_MASK);
+ else /* unknown network class */
+ return(MASK_HOST);
+}
+
+#if 0
+
+/*
+ * ValidateNetMask
+ * Validate a network mask
+ * return OK or Error Number.
+ * Checks:
+ * - a netmask should have valid IP address
+ * - the mask must be left contiguous
+ * - the mask must be consistent with the destination address
+ */
+
+int ValidateNetMask (ipaddrtype address, char *sMask, char **ppErrMsg)
+{
+ int offset;
+ ipAddr_t ipAddrInfo;
+ char *pErrMsg;
+ int errcode;
+ ipaddrtype mask;
+
+ /* Call the parser to process the sMask field */
+ offset = 0;
+ errcode = parser_ipaddr_or_hostname(sMask,
+ &offset,
+ 0,
+ &ipAddrInfo,
+ &pErrMsg);
+ if (errcode != OK) {
+ *ppErrMsg = parser_xlate_errcode(
+ S_parser_SYNTAX_INVALID_NETMASK_FORMAT);
+ return (S_parser_SYNTAX_INVALID_NETMASK_FORMAT);
+ }
+ mask = ipAddrInfo.ipAddrHostOrder;
+
+ if (!mask_contiguous(mask))
+ {
+ *ppErrMsg = parser_xlate_errcode(
+ S_parser_SYNTAX_INVALID_NETMASK_CONTIGUOUS);
+ return (S_parser_SYNTAX_INVALID_NETMASK_CONTIGUOUS);
+ }
+
+ if (address & ~mask)
+ {
+ *ppErrMsg = parser_xlate_errcode(
+ S_parser_SYNTAX_INVALID_NETMASK_IPADDR_MISMATCH);
+ return (S_parser_SYNTAX_INVALID_NETMASK_IPADDR_MISMATCH);
+ }
+
+ *ppErrMsg = parser_xlate_errcode(OK);
+ return (OK);
+}
+
+#endif
+/*
+ * good_address
+ * Validate an address and/or network mask, return TRUE/FALSE.
+ * Checks:
+ * - an address or mask is never all zeros or all ones
+ * - an address must not be a reserved IP address, i.e., a martian
+ * - the mask may not have zeros in the major network portion, that is,
+ * it must be consistent with the address class type.
+ * - the mask must be left contiguous
+ */
+
+boolean good_address (ipaddrtype address, ipaddrtype mask, boolean maskcheck)
+{
+ ipaddrtype basicmask, result;
+
+ if (martian(address, MARTIAN_FLAG_IS_HOST) == TRUE) {
+ return(FALSE);
+ }
+
+ if (maskcheck) {
+ if ((mask == 0L) || (mask == -1L))
+ return(FALSE);
+ if (!mask_contiguous(mask))
+ return(FALSE);
+ basicmask = get_majormask(address);
+ if (!basicmask)
+ return(FALSE);
+ if ((mask | address) == -1)
+ return(FALSE); /* all ones in host part */
+ if ((address & ~mask) == 0)
+ return(FALSE); /* all zeros in host part */
+ if (!subnetzero_enable && (mask > basicmask)) {
+ result = (address & ~basicmask); /* mask off major net bits */
+ if ((result & mask) == 0L) /* mask off host bits */
+ return(FALSE); /* disallow subnet zero */
+ }
+ }
+ return(TRUE);
+}
+
+/*
+ * name_verify
+ * Screen out malformed hostname strings.
+ * Rejects null strings and strings with illegal chars. Note that we don't
+ * do any length checking since domain style names may be arbitrarily long.
+ */
+
+boolean name_verify (char *name)
+{
+ boolean good;
+ char c;
+ boolean non_numeric_seen = FALSE;
+
+ if (null(name))
+ return(FALSE); /* screen out null strings */
+
+ while ((c = *name++) != '\0') {
+ if (((c >= 'A') && (c <= 'Z')) ||
+ ((c >= 'a') && (c <= 'z')) ||
+ (c == '-') || (c == '_')) {
+ good = TRUE;
+ non_numeric_seen = TRUE;
+ } else
+ good = ((c >= '0') && (c <= '9')) || (c == '.');
+
+ if (!good)
+ return(FALSE); /* screen out bad characters */
+ };
+
+ if (!non_numeric_seen) /* Check for strings with only numbers */
+ return(FALSE); /* with possibles dots. Not allowed! */
+
+ return(TRUE); /* string appears well formed */
+}
+
+
+#ifdef IOS_PARSER
+
+void ipaddrmask_action (parseinfo *csb, transition *mine,
+ ipaddrmask_struct * const arg)
+{
+ addrtype *addrp = CSBVAR(csb, arg->addr, addrtype);
+ addrtype *maskp = CSBVAR(csb, arg->mask, addrtype);
+ int i;
+ uint mask_number = 0;
+ static const char short_help[] = "A.B.C.D {IP address A.B.C.D}";
+ static const char prefix_help[] = "IP prefix and prefix mask";
+
+ push_node(csb, mine->alternate);
+ INVALID_NVGEN_CHECK;
+
+ if (help_check(csb)) {
+ save_help_long(csb, short_help, arg->help, csb->priv);
+ return;
+ }
+
+ i = 0;
+ if (match_ip_addr(csb, &csb->line[csb->line_index], &i, addrp,
+ csb->in_help, 0, NULL)) {
+ if (match_char(&csb->line[csb->line_index], &i, '/')) {
+ if (match_number(csb, 0, 32, &i, &mask_number,
+ NUMBER_DEC | NUMBER_WS_OK | NUMBER_HELP_CHECK,
+ "Length of prefix mask")) {
+ uint n = 1<<31;
+
+ while (mask_number--) {
+ maskp->ip_addr |= n;
+ n = n>>1;
+ }
+
+ maskp->type = ADDR_IP;
+ maskp->length = ADDRLEN_IP;
+
+ csb->line_index += i;
+ push_node(csb, mine->accept);
+ csb->line_index -= i;
+ }
+ } else {
+ if (match_whitespace2(&csb->line[csb->line_index],
+ &i, csb->in_help)) {
+ csb->line_index += i;
+ if (help_check(csb)) {
+ save_help_long(csb, short_help, prefix_help, csb->priv);
+ csb->line_index -= i;
+ return;
+ }
+ csb->line_index -= i;
+
+ if (match_ip_addr(csb, &csb->line[csb->line_index], &i, maskp,
+ csb->in_help, 0, NULL)) {
+ if (match_whitespace2(&csb->line[csb->line_index],
+ &i, csb->in_help)) {
+ csb->line_index += i;
+ push_node(csb, mine->accept);
+ csb->line_index -= i;
+ } else {
+ help_or_error(csb, i, prefix_help,
+ NO_COMMAND_COMPLETION);
+ }
+ } else {
+ help_or_error(csb, i, prefix_help,
+ NO_COMMAND_COMPLETION);
+ }
+ } else {
+ /*
+ * Two short helps in one string, don't try
+ * this at home kids
+ */
+ help_or_error(csb, i, "/\tIP prefix mask",
+ NO_COMMAND_COMPLETION);
+ }
+ }
+ } else {
+ help_or_error(csb, i, short_help, NO_COMMAND_COMPLETION);
+ }
+}
+
+
+void ipmask_action (parseinfo *csb, transition *mine,
+ ipmask_struct * const arg)
+{
+ addrtype *maskp = CSBVAR(csb, arg->mask, addrtype);
+ int i;
+ uint mask_number = 0;
+ static const char short_help[] = "/nn or A.B.C.D";
+ static const char prefix_help[] = "IP prefix mask";
+
+ push_node(csb, mine->alternate);
+ INVALID_NVGEN_CHECK;
+
+ if (help_check(csb)) {
+ save_help_long(csb, short_help, arg->help, csb->priv);
+ return;
+ }
+
+ i = 0;
+ if (match_char(&csb->line[csb->line_index], &i, '/')) {
+ if (match_number(csb, 0, 32, &i, &mask_number,
+ NUMBER_DEC | NUMBER_WS_OK | NUMBER_HELP_CHECK,
+ "Length of prefix mask")) {
+ uint n = 1<<31;
+
+ while (mask_number--) {
+ maskp->ip_addr |= n;
+ n = n>>1;
+ }
+
+ maskp->type = ADDR_IP;
+ maskp->length = ADDRLEN_IP;
+
+ csb->line_index += i;
+ push_node(csb, mine->accept);
+ csb->line_index -= i;
+ }
+ } else {
+ if (match_whitespace2(&csb->line[csb->line_index], &i, csb->in_help)) {
+ csb->line_index += i;
+ if (help_check(csb)) {
+ save_help_long(csb, short_help, prefix_help, csb->priv);
+ csb->line_index -= i;
+ return;
+ }
+ csb->line_index -= i;
+
+ if (match_ip_addr(csb, &csb->line[csb->line_index], &i, maskp,
+ csb->in_help, 0, NULL)) {
+ if (match_whitespace2(&csb->line[csb->line_index],
+ &i, csb->in_help)) {
+ csb->line_index += i;
+ push_node(csb, mine->accept);
+ csb->line_index -= i;
+ } else {
+ help_or_error(csb, i, prefix_help, NO_COMMAND_COMPLETION);
+ }
+ } else {
+ help_or_error(csb, i, prefix_help, NO_COMMAND_COMPLETION);
+ }
+ } else {
+ /*
+ * Two short helps in one string, don't try
+ * this at home kids
+ */
+ help_or_error(csb, i, "/\tIP prefix mask", NO_COMMAND_COMPLETION);
+ }
+ }
+}
+
+#endif /* IOS_PARSER */
diff --git a/data/mnet/Common/cli/src/parser.c b/data/mnet/Common/cli/src/parser.c
new file mode 100644
index 0000000..007cbaa
--- /dev/null
+++ b/data/mnet/Common/cli/src/parser.c
@@ -0,0 +1,2062 @@
+#include <vxworks.h>
+#include <stdioLib.h>
+#include <tyLib.h>
+#include <taskLib.h>
+#include <errnoLib.h>
+#include <lstLib.h>
+#include <inetLib.h> /* for INET_ADDR_LEN */
+#include <timers.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <msgQLib.h>
+#include <sigLib.h>
+
+
+#include <../include/cli_parser_private.h>
+#include <../include/pstypes.h>
+#include <../include/psvxif.h>
+#include <../include/imsg.h>
+#include <../include/imc.h>
+#include <../include/address.h>
+#include <../include/parsertypes.h>
+#include <../include/config.h>
+#include <../include/parser_sim.h>
+#include <../include/parser.h>
+#include <../include/parser_defs_exec.h>
+#include <../include/parser_input.h>
+#include <../include/parser_sim.h>
+#include <../include/parser_util.h>
+#include <../include/parser_commands.h>
+#include <../include/nv.h>
+#include <../include/parser_errno.h>
+#include <../include/parser_ModNum.h>
+#include <../include/defs.h>
+#include <../include/parser_init.h>
+#include <../include/macros.h>
+#include <../include/parser_actions.h>
+#include <../include/parser_sim.h>
+#include <../include/ttyutil.h>
+
+
+static MSG_Q_ID callback_Q_Id = NULL;
+
+#define INVALID_UID -1
+
+
+boolean config_prompt = FALSE;
+char *nomemory = "\n%%No memory available";
+
+extern parser_mode *interface_mode;
+
+/*
+ * Local structures and variables
+ */
+static chain_list *cl = NULL; /* Unresolved parse chains */
+static chain_list *llist = NULL; /* Dynamic link points */
+
+/*
+ * Forward declarations
+ */
+
+static boolean word_completion(parseinfo *csb);
+static boolean add_to_unresolved_chains(uint, dynamic_transition *
+#ifdef PARSER_DEBUG_LINKS
+ , const char *
+#endif /* PARSER_DEBUG_LINKS */
+ );
+static void resolve_parse_chains(void);
+static boolean parser_resolve_entry_link_point(chain_link *,
+ dynamic_transition *
+#ifdef PARSER_DEBUG_LINKS
+ , const char *
+#endif /* PARSER_DEBUG_LINKS */
+ );
+static boolean parser_resolve_exit_link_point(chain_link *,
+ dynamic_transition *);
+static boolean parser_add_link_to_list(uint,
+#ifdef PARSER_DEBUG_LINKS
+ const char *,
+#endif /* PARSER_DEBUG_LINKS */
+ dynamic_transition *, uint);
+static parsenode *get_parsenode(parseinfo *);
+static void parser_exec_callback( void );
+static void addSignalHandlers ( void );
+
+
+
+
+
+
+
+static const char *generic_csb_name = "Parser CSB";
+parseinfo *get_csb (const char *name)
+{
+ parseinfo *csb;
+
+ if (!name) {
+ name = generic_csb_name;
+ }
+
+ csb = (parseinfo *)PARSERcalloc(1, sizeof( parseinfo ));
+
+ if (!csb) {
+ return(NULL);
+ }
+
+ /*
+ * Assignments to make purify happy
+ */
+ csb->tokenQ = NULL;
+ csb->privQ = NULL;
+ csb->priv_nvgenQ = NULL;
+ csb->help_save.buf = NULL;
+ csb->comment_save.buf = NULL;
+
+ /* Initialize the parsing stuff */
+ csb->line = csb->line_buffer;
+ csb->break_chars = EXEC_BREAKSET;
+ csb->resolvemethod = RES_NULL;
+ csb->flags = 0;
+ csb->mode = exec_mode;
+ csb->priv = PRIV_MAX;
+ csb->priv_set = PRIV_NULL;
+
+ csb->uid = -1;
+ csb->MoreStatus = RC_OK;
+ csb->savedFd = -1;
+
+ /*
+ * The errno_val will only be valid if return_val is FALSE
+ */
+ csb->return_val = TRUE;
+ csb->errno_val = 0;
+
+ csb->configSemId = PSsemBCreate( PS_DEFAULT_BINARY_SEM_FLAG, SEM_EMPTY );
+ if ( csb->configSemId == NULL )
+ PSpanic("Cannot create configuration semaphore for CSB\n");
+
+ csb->giveConfigSem = FALSE;
+
+ /* Initialize tokenQ */
+ if ((csb->tokenQ = (queuetype *)
+ PARSERmalloc(sizeof(queuetype))) == NULL) {
+ free_csb(&csb);
+ return(NULL);
+ }
+ queue_init(csb->tokenQ, 0);
+
+ return(csb);
+}
+
+
+
+/*
+ * Initialize parser variables
+ */
+static void parse_cmd_init (parseinfo *csb)
+{
+
+ csb->nv_command[0] = '\0';
+
+ csb->error_index = 0;
+ csb->nvgen = 0;
+ csb->sense = TRUE;
+ csb->set_to_default = FALSE;
+ csb->saved_help_used = 0;
+ save_line_init(&csb->help_save);
+ csb->visible_ambig.ambig[0] = '\0';
+ csb->visible_ambig.ambig_save[0] = '\0';
+ csb->hidden_ambig.ambig[0] = '\0';
+ csb->hidden_ambig.ambig_save[0] = '\0';
+ set_multiple_funcs(csb, 0);
+ csb->command_visible = TRUE;
+ csb->unsupported = FALSE;
+ csb->action_func = NULLFUNC;
+ csb->which = 0;
+ csb->func = 0;
+ csb->next = NULL;
+ csb->return_val = TRUE;
+ csb->errno_val = 0;
+
+ /* Clear any lingering flags */
+ csb->flags &= (CONFIG_TERM | CONFIG_HTTP | COMMAND_AUTHORIZE |
+ COMMAND_FUNCTION | HIDE_PASSWORDS | PARSE_EMPTY_STRING |
+ CONFIG_PER_USER | CONFIG_CGI | COMMAND_COMPLETE);
+
+ /* Zap the data area. */
+ memset((void *) &(csb->csb_start_data), 0,
+ (int) ((uchar *) &csb->csb_end_data -
+ (uchar *) &csb->csb_start_data));
+ csb->last_priv = 0;
+ csb->highest_priv = 0;
+
+ parser_ambig_debug = FALSE;
+}
+
+
+
+/*
+ * get_parsenode
+ * Get parsenode structure.
+ */
+static parsenode *get_parsenode (parseinfo *csb)
+{
+ parsenode *pp = NULL;
+
+ /* pp = chunk_malloc(parsenode_chunks); */
+
+ pp = ( parsenode *)PARSERmalloc(sizeof(parsenode));
+
+ if (!pp)
+ return(NULL);
+ pp->next = NULL;
+ pp->visible_ambig[0] = '\0';
+ pp->hidden_ambig[0] = '\0';
+ pp->nv_command[0] = '\0';
+ return(pp);
+}
+
+static void empty_queue (queuetype *qp)
+{
+ void *tmp;
+
+ while (! QUEUEEMPTY(qp)) {
+ tmp = dequeue(qp);
+ PARSERfree(tmp);
+ }
+}
+
+static void free_queue (queuetype **qp)
+{
+ if (*qp) {
+ empty_queue(*qp);
+ PARSERfree(*qp);
+ *qp = NULL;
+ }
+}
+
+/*
+ * free_csb_mem
+ *
+ * Free the memory allocated for the various structures within
+ * the csb. This includes dirty, token and line Qs and help_save,
+ * comment_save fields.
+ */
+void free_csb_mem (parseinfo *csb)
+{
+ if (csb) {
+ free_queue(&csb->tokenQ);
+ free_queue(&csb->privQ);
+ free_queue(&csb->priv_nvgenQ);
+ save_line_init(&csb->help_save); /* Free help text elements */
+ save_line_init(&csb->comment_save); /* Free comment text elements */
+ }
+}
+
+/* Mind our Free's & Q's */
+void free_csb (parseinfo **csbp)
+{
+ parseinfo *csb = *csbp;
+
+ if (csb) {
+ free_csb_mem(csb); /* Free allocated memory hidden in csb */
+ /* chunk_free(parseinfo_chunks, csb);*/
+ if ( csb->configSemId )
+ semDelete( csb->configSemId );
+ PARSERfree( csb );
+ }
+ *csbp = NULL;
+}
+
+
+static int count_help_matches (parseinfo *csb)
+{
+ char *cp;
+ int n = 0;
+
+ for (cp = csb->help_save.buf; cp && *cp; cp++) {
+ if (*cp == '\t' || *cp == '\n'){
+ n++;
+ }
+ }
+ return(n);
+}
+
+
+
+
+/*
+ * Report where we found an error in the command line.
+ * "error" indicates what type of error occured.
+ * If 'reprint' is TRUE, then we have to reprint the line.
+ */
+void report_error (parseinfo * csb, int error, boolean need_reprint)
+{
+ int promptlen;
+ int incomplete = 0;
+
+ char buffer[80];
+ buffer[0] = '\0';
+
+ if (parser_ambig_debug) {
+ need_reprint = TRUE;
+ }
+
+ if (error == PARSE_ERROR_UNKNOWN) {
+ printf("\n%% Unrecognized command\n");
+ parser_return(csb, S_parser_SYNTAX_UNKNOWN);
+ return;
+ }
+
+ if (error == PARSE_ERROR_AMBIG) {
+ printf("\n%% Ambiguous command: \"%s\"\n", csb->line);
+ parser_return(csb, S_parser_SYNTAX_AMBIGUOUS);
+ return;
+ }
+
+ /* error == PARSE_ERROR_NOMATCH */
+ /*
+ * Prepare to designate the error. We have to know the length of the
+ * command line prompt and if configuration is from other than a
+ * terminal, print the command before indicating the error location.
+ */
+ if (csb->flags & CONFIG_TERM) {
+ promptlen = strlen(csb->prompt);
+ /* Reprint if the command is too long. */
+ if (promptlen + strlen(csb->line) >= SCREEN_WIDTH ||
+ need_reprint ||
+ (error & PARSE_ERROR_ALIAS)) {
+ promptlen = 0;
+ need_reprint = TRUE;
+ }
+ } else {
+ promptlen = 0;
+ need_reprint = TRUE;
+ }
+
+ if (csb->line[csb->error_index] == '\0') {
+ if (csb->error_index > 0) {
+ /* NON-blank input line. Handle INCOMPLETE error similarly
+ to other errors, below. */
+ incomplete = 1;
+ }
+ }
+ if (need_reprint) {
+ int length = csb->error_index;
+ int i;
+ int base;
+
+ printf("\n");
+
+ if (SCREEN_WIDTH <= 0) {
+ base = length;
+ } else {
+ base = length / SCREEN_WIDTH;
+ }
+ for (i = 0; csb->line[i]; i++) {
+ printf("%c", csb->line[i]);
+ if ((SCREEN_WIDTH > 0) && ((i+1) % SCREEN_WIDTH == 0)) {
+ /* Next char starts new line. */
+ if (i / SCREEN_WIDTH == base) {
+ /* We just printed the error line. */
+ print_caret(length % SCREEN_WIDTH);
+ } else {
+ /* Not the error line, print a blank line. */
+ printf("\n");
+ }
+ }
+ }
+
+ if (! incomplete) {
+ printf("\n");
+
+ if (SCREEN_WIDTH <= 0) {
+ print_caret(length);
+ } else {
+ if (i / SCREEN_WIDTH == base) {
+ /* We just printed the error line. */
+ print_caret(length % SCREEN_WIDTH);
+ }
+ }
+ }
+ } else {
+ if (! incomplete) {
+ /* No reprint needed, just show caret. */
+ print_caret(promptlen + csb->error_index);
+ }
+ }
+
+ if (incomplete) {
+ printf("\n%% Incomplete command.\n");
+ parser_return(csb, S_parser_SYNTAX_INCOMPLETE);
+ } else {
+ printf("\n%% Invalid input detected at '^' marker.\n");
+ parser_return(csb, S_parser_SYNTAX_INVALID);
+ }
+}
+
+extern void Logout(parseinfo *csb);
+
+/*
+ * exit_exec_command
+ *
+ * Cleanup for an exit from the exec. Call exit_command() to
+ * drop any outstanding connections and set the exit flag.
+ */
+
+void exit_exec_command (parseinfo *csb)
+{
+ Logout(NULL);
+ return;
+ csb->exit_all = TRUE;
+ if ( csb->priv == PRIV_USER )
+ csb->priv = PRIV_NULL;
+ else
+ csb->priv = PRIV_MIN;
+ return;
+}
+
+void set_multiple_funcs (parseinfo *csb, int value)
+{
+ csb->visible_ambig.multiple_funcs = value;
+ csb->hidden_ambig.multiple_funcs = value;
+}
+
+void increment_multiple_funcs (parseinfo *csb, char *str)
+{
+ char *visible_str;
+ int value;
+
+ if (csb->command_visible) {
+ csb->visible_ambig.multiple_funcs++;
+ visible_str = "visible";
+ value = csb->visible_ambig.multiple_funcs;
+ } else {
+ csb->hidden_ambig.multiple_funcs++;
+ visible_str = "hidden";
+ value = csb->hidden_ambig.multiple_funcs;
+ }
+ if (parser_help_debug || parser_ambig_debug) {
+ printf("\nIncreasing %s multiple_funcs to %d in %s",
+ visible_str, value, str);
+ }
+
+}
+
+int test_multiple_funcs (parseinfo *csb, char test, int value)
+{
+ int mf = (csb->visible_ambig.multiple_funcs +
+ csb->hidden_ambig.multiple_funcs);
+
+ switch (test) {
+ case '<': return(mf < value);
+ case '>': return(mf > value);
+ case '=': return(mf == value);
+ default:
+ printf("test_multiple_funcs: %c\n", test);
+ break;
+ }
+ return(0);
+}
+
+int test_visible_multiple_funcs (parseinfo *csb, char test, int value)
+{
+ int mf = csb->visible_ambig.multiple_funcs;
+
+ switch (test) {
+ case '<': return(mf < value);
+ case '>': return(mf > value);
+ case '=': return(mf == value);
+ default:
+ /* errmsg(&msgsym(MULFUNCS, PARSER), test); */
+ printf("test_multiple_visible_funcs : %c\n",test );
+ break;
+ }
+ return(0);
+}
+
+int test_invisible_multiple_funcs (parseinfo *csb, char test, int value)
+{
+ int mf = csb->hidden_ambig.multiple_funcs;
+
+ switch (test) {
+ case '<': return(mf < value);
+ case '>': return(mf > value);
+ case '=': return(mf == value);
+ default:
+ printf("\n%% Unknown test in test_multiple_funcs '%c'", test);
+ break;
+ }
+ return(0);
+}
+
+void print_multiple_funcs (parseinfo *csb)
+{
+ printf("\ncsb->visible_ambig.multiple_funcs = %d",
+ csb->visible_ambig.multiple_funcs);
+ printf("\ncsb->hidden_ambig.multiple_funcs = %d",
+ csb->hidden_ambig.multiple_funcs);
+}
+
+
+static chain_link *get_link_point (uint which_chain)
+{
+ int i = 0;
+ chain_link *cp;
+ chain_list *lp;
+
+ /* Check static link points */
+ cp = &chain_gang[i++];
+ while (cp && (cp->id != PARSE_LIST_END)) {
+ if (cp->id == which_chain) {
+ return(cp);
+ }
+ cp = &chain_gang[i++];
+ }
+ /* Check dynamic link points */
+ lp = llist;
+ while (lp != NULL) {
+ if (lp->cp.id == which_chain) {
+ return(&lp->cp);
+ }
+ lp = lp->next;
+ }
+ /* Didn't find anything */
+ return(NULL);
+}
+
+static boolean parser_add_chains (uint which_chain,
+ dynamic_transition *commands,
+#ifdef PARSER_DEBUG_LINKS
+ const char *module,
+#endif /* PARSER_DEBUG_LINKS */
+ boolean already_on_list)
+{
+ chain_link *where;
+ boolean status = TRUE;
+
+ if ( PSsemTake(parse_chain_sem, WAIT_FOREVER) == ERROR ) {
+ PSpanic("Cannot take parse chain semaphore\n");
+ }
+
+ /*
+ * Make sure we have a place to link this
+ */
+ where = get_link_point(which_chain);
+ if (!where) {
+ if (already_on_list) {
+ /*
+ * point is already on unresolved list, so return FALSE
+ */
+ status = (FALSE);
+ goto SEMRELEASE;
+
+ } else {
+ /*
+ * No place to add it yet, so place on unresolved list
+ */
+ status = (add_to_unresolved_chains(which_chain, commands
+#ifdef PARSER_DEBUG_LINKS
+ , module
+#endif /* PARSER_DEBUG_LINKS */
+ ));
+
+ goto SEMRELEASE;
+ }
+ }
+
+ switch (where->type) {
+ case PARSER_ENTRY_LINK_POINT:
+ status = (parser_resolve_entry_link_point(where, commands
+#ifdef PARSER_DEBUG_LINKS
+ , module
+#endif /* PARSER_DEBUG_LINKS */
+ ));
+ break;
+ case PARSER_EXIT_LINK_POINT:
+ status = (parser_resolve_exit_link_point(where, commands));
+ break;
+ default:
+ status = FALSE;
+ }
+
+
+ SEMRELEASE:
+
+ if ( PSsemGive(parse_chain_sem) == ERROR ) {
+ PSpanic("Cannot give parse chain semaphore\n");
+ }
+
+ return(status);
+
+}
+
+boolean parser_add_commands_func (uint which_chain,
+ dynamic_transition *commands
+#ifdef PARSER_DEBUG_LINKS
+ , const char *module
+#endif /* PARSER_DEBUG_LINKS */
+ )
+{
+ boolean status ;
+
+ if ( PSsemTake(parse_chain_sem, WAIT_FOREVER) == ERROR ) {
+ PSpanic("Cannot take parse chain semaphore\n");
+ }
+
+ status = (parser_add_chains(which_chain, commands,
+#ifdef PARSER_DEBUG_LINKS
+ module,
+#endif /* PARSER_DEBUG_LINKS */
+ FALSE));
+
+ if ( PSsemGive(parse_chain_sem) == ERROR ) {
+ PSpanic("Cannot give parse chain semaphore\n");
+ }
+
+ return(status);
+}
+
+static boolean parser_resolve_entry_link_point (chain_link *where,
+ dynamic_transition *commands
+#ifdef PARSER_DEBUG_LINKS
+ ,const char *module
+#endif /* PARSER_DEBUG_LINKS */
+ )
+{
+ dynamic_transition *tw;
+
+ /*
+ * Check to make sure the chain hasn't already been linked.
+ */
+ tw = where->link_point->accept;
+ while (tw) {
+ if (tw == commands) {
+ /*
+ * Parse chain already linked in, but it's not really
+ * a failure because the parse chain has been linked
+ * in, so we return TRUE.
+ */
+ return(TRUE);
+ }
+ if (tw->alternate == (dynamic_transition *)&pname(link_trans)) {
+ break;
+ }
+ tw = tw->alternate;
+ }
+ if (!tw || (tw->alternate != (dynamic_transition *)&pname(link_trans))) {
+ printf("Parser No Link at %d\n", __LINE__);
+ return(FALSE);
+ }
+
+ if (commands) {
+ /*
+ * At this point last_cmd's alternate points to link_point,
+ * so we have the right place
+ */
+ commands->alternate = (dynamic_transition *)tw->alternate;
+#ifdef PARSER_DEBUG_LINKS
+ commands->args = module;
+#endif /* PARSER_DEBUG_LINKS */
+ tw->alternate = commands;
+ return(TRUE);
+ } else {
+ printf("Parser No Link at %s:%d\n", __FILE__, __LINE__);
+ return(FALSE);
+ }
+}
+
+static boolean parser_resolve_exit_link_point (chain_link *where,
+ dynamic_transition *commands)
+{
+ if (!commands ||
+ !where ||
+ !commands->accept ||
+ (commands->accept->alternate !=
+ (dynamic_transition *)&pname(link_trans))) {
+
+ /*
+ * Transition is broken or already linked
+ */
+ return(FALSE);
+ }
+
+ commands->accept->alternate = where->link_point;
+ return(TRUE);
+}
+
+/*
+ * parser_add_command_list - Add a series of parse chains
+ */
+
+boolean parser_add_command_list_func (parser_extension_request *chain
+#ifdef PARSER_DEBUG_LINKS
+ , const char *module
+#endif /* PARSER_DEBUG_LINKS */
+ )
+{
+ int i;
+ boolean status = TRUE;
+
+ if ( PSsemTake(parse_chain_sem, WAIT_FOREVER) == ERROR ) {
+ PSpanic("Cannot take parse chain semaphore\n");
+ }
+
+ for (i = 0; chain[i].type != PARSE_LIST_END; i++) {
+ if (!parser_add_commands(chain[i].type, chain[i].commands, module)) {
+ status = FALSE;
+ break;
+ }
+ }
+
+ if ( PSsemGive(parse_chain_sem) == ERROR ) {
+ PSpanic("Cannot give parse chain semaphore\n");
+ }
+ return(status);
+}
+
+
+#define ADDR_GROW 3
+addr_func *addr_funcs = NULL;
+static uint addr_funcs_length = 0;
+
+static void parser_add_address_set(addr_func *addr, const uint addr_type,
+ short_help_func get_short_help,
+ match_gen_func func);
+
+/* NO need to protect this with semaphore since it is assumed that
+ * tParser by itself will be Single Threaded...
+ */
+void parser_add_address (const uint addr_type, short_help_func get_short_help,
+ match_gen_func func)
+{
+ int i;
+ addr_func *tmp;
+
+ if (addr_funcs == NULL) {
+ if ((addr_funcs = (addr_func *)PARSERmalloc(ADDR_GROW*sizeof(addr_func))) == NULL) {
+ printf(nomemory);
+ return;
+ }
+ addr_funcs_length = ADDR_GROW;
+ parser_add_address_set(&addr_funcs[0], ADDR_ILLEGAL, NULL, NULL);
+ }
+
+ i = 0;
+ while ((addr_funcs[i].addr_type != ADDR_ILLEGAL) &&
+ (i < addr_funcs_length)) {
+ i++;
+ }
+
+ if (addr_funcs[i].addr_type == ADDR_ILLEGAL) {
+ if ((i+1) >= addr_funcs_length) {
+ if ((tmp = PARSERmalloc((ADDR_GROW + addr_funcs_length) *
+ sizeof(addr_func))) == NULL) {
+ printf(nomemory);
+ return;
+ }
+ bcopy((char *)addr_funcs, (char *)tmp,
+ addr_funcs_length * sizeof(addr_func));
+ PARSERfree(addr_funcs);
+ addr_funcs = tmp;
+ addr_funcs_length += ADDR_GROW;
+ }
+ parser_add_address_set(&addr_funcs[i], addr_type,
+ get_short_help, func);
+ parser_add_address_set(&addr_funcs[i+1], ADDR_ILLEGAL, NULL, NULL);
+ } else {
+ /* something's wrong */
+ printf("\n%% Invalid end to address list, can't add protocol %d",
+ addr_type);
+ }
+}
+
+static void parser_add_address_set (addr_func *addr, const uint addr_type,
+ short_help_func get_short_help,
+ match_gen_func func)
+{
+ addr->addr_type = addr_type;
+ addr->get_short_help = get_short_help;
+ addr->func = func;
+}
+
+
+
+static void resolve_parse_chains (void)
+{
+ if ( PSsemTake(parse_chain_sem, WAIT_FOREVER) == ERROR ) {
+ PSpanic("Cannot take parse chain semaphore\n");
+ }
+
+ {
+ chain_list *cp = cl;
+ chain_list *tmp;
+ chain_list *old = NULL;
+
+ while (cp != NULL) {
+
+ if (!parser_add_chains(cp->cp.id, cp->cp.link_point,
+
+#ifdef PARSER_DEBUG_LINKS
+ cp->cp.name,
+#endif /* PARSER_DEBUG_LINKS */
+ TRUE)) {
+ /*
+ * Failed again, leave on list and try later
+ */
+ old = cp;
+ cp = cp->next;
+ } else {
+ /*
+ * Success, remove and free link
+ */
+ if (cp == cl) {
+ cl = cl->next;
+ }
+ tmp = cp;
+ cp = cp->next;
+ if (old) {
+ old->next = cp;
+ }
+ PARSERfree(tmp);
+ }
+ }
+
+ }
+
+ if ( PSsemGive(parse_chain_sem) == ERROR ) {
+ PSpanic("Cannot give parse chain semaphore\n");
+ }
+
+}
+
+
+
+
+
+static boolean add_to_unresolved_chains (uint which_chain,
+ dynamic_transition *commands
+#ifdef PARSER_DEBUG_LINKS
+ , const char *module
+#endif /* PARSER_DEBUG_LINKS */
+ )
+{
+ chain_list *cp;
+ boolean status = TRUE;
+
+ if ( PSsemTake(parse_chain_sem, WAIT_FOREVER) == ERROR ) {
+ PSpanic("Cannot take parse chain semaphore\n");
+ }
+ /*
+ * Make sure commands isn't alreay on the list
+ */
+ cp = cl;
+ while (cp != NULL) {
+ if ((cp->cp.link_point == commands) &&
+ (cp->cp.id == which_chain)) {
+ /*
+ * It's a duplicate, but we return true because
+ * the link point has been successfully added.
+ */
+ goto SEMRELEASE;
+ }
+ cp = cp->next;
+ }
+
+ if ((cp = (chain_list *)PARSERmalloc(sizeof(chain_list))) == NULL) {
+ printf(nomemory);
+ status = FALSE;
+ } else {
+
+ cp->cp.id = which_chain;
+#ifdef PARSER_DEBUG_LINKS
+ cp->cp.name = module;
+#endif /* PARSER_DEBUG_LINKS */
+ cp->cp.link_point = commands;
+ cp->next = cl;
+ cl = cp;
+ }
+
+ SEMRELEASE:
+
+ if ( PSsemGive(parse_chain_sem) == ERROR ) {
+ PSpanic("Cannot give parse chain semaphore\n");
+ }
+ return(status);
+}
+
+boolean parser_add_link_point_func (uint which_chain,
+#ifdef PARSER_DEBUG_LINKS
+ const char *module,
+#endif /* PARSER_DEBUG_LINKS */
+ transition *lp)
+{
+ dynamic_transition *dp = (dynamic_transition *)lp;
+
+ return(parser_add_link_to_list(which_chain,
+#ifdef PARSER_DEBUG_LINKS
+ module,
+#endif /* PARSER_DEBUG_LINKS */
+ dp, PARSER_ENTRY_LINK_POINT));
+}
+
+boolean parser_add_link_exit_func (uint which_chain,
+#ifdef PARSER_DEBUG_LINKS
+ const char *module,
+#endif /* PARSER_DEBUG_LINKS */
+ transition *lp)
+{
+ dynamic_transition *dp = (dynamic_transition *)lp;
+
+ return(parser_add_link_to_list(which_chain,
+#ifdef PARSER_DEBUG_LINKS
+ module,
+#endif /* PARSER_DEBUG_LINKS */
+ dp, PARSER_EXIT_LINK_POINT));
+}
+
+static boolean parser_add_link_to_list (uint which_chain,
+#ifdef PARSER_DEBUG_LINKS
+ const char *module,
+#endif /* PARSER_DEBUG_LINKS */
+ dynamic_transition *lp, uint type)
+{
+ chain_list *new_lp;
+ boolean status = TRUE;
+
+ if ( PSsemTake(parse_chain_sem, WAIT_FOREVER) == ERROR ) {
+ PSpanic("Cannot take parse chain semaphore\n");
+ }
+
+ if ((new_lp = (chain_list *)PARSERmalloc(sizeof(chain_list))) == NULL) {
+ printf(nomemory);
+ status = FALSE;
+ goto SEMRELEASE;
+ }
+
+ new_lp->cp.id = which_chain;
+#ifdef PARSER_DEBUG_LINKS
+ new_lp->cp.name = module;
+#endif /* PARSER_DEBUG_LINKS */
+ new_lp->cp.link_point = lp;
+ new_lp->cp.type = type;
+ new_lp->next = llist;
+
+ llist = new_lp;
+
+ SEMRELEASE:
+
+ if ( PSsemGive(parse_chain_sem) == ERROR ) {
+ PSpanic("Cannot give parse chain semaphore\n");
+ }
+
+ return(status);
+}
+
+
+
+
+/*****************************************************************
+ *
+ * Func: parser_exec_callback
+ *
+ * Desc: Task entry point for Callback tasks
+ *
+ * Inputs: None
+ *
+ * Result: None
+ *
+ * Algorithm:
+ * Parser identifies callback function for a command
+ * Sends the callback function pointer information to
+ * the callback task, so that it can process other
+ * commands from other I/O sources. This function waits
+ * for intimation from parser and executes the callback
+ * function synchronously
+ *
+ *****************************************************************/
+void parser_exec_callback( void )
+{
+ tINT outFd, inFd, errFd;
+ tUOCTET4 moduleId = 1;
+ tOCTET2 rc = RC_OK;
+ tpCOMSIM pComSim = NULL;
+ tpCALLBACKMSG pCallback = NULL ;
+ tpPARSERSIM pSim = NULL;
+
+ parseinfo *csb = NULL;
+ char *buffer = NULL;
+ parser_mode *prevMode = NULL ;
+ boolean bErrorFlag = FALSE;
+ char *pCwd = NULL;
+
+ addSignalHandlers();
+
+ /* Get the original FDs */
+ inFd = ioTaskStdGet( 0, STD_IN );
+ outFd = ioTaskStdGet( 0, STD_OUT );
+ errFd = ioTaskStdGet( 0, STD_ERR );
+
+
+ FOREVER {
+
+ pCallback = NULL;
+ pSim = NULL;
+ csb = NULL;
+ bErrorFlag = FALSE;
+
+ /* Reset the errno of the callback task */
+ errnoOfTaskSet( 0, OK );
+
+ /* Reset the Signal Flags */
+ /*
+ * RAMS: commented this for now
+
+ setTaskSignalMask(0,0); */
+
+ /* Wait till a command needs to be executed as
+ * determined by the tParser
+ */
+ if ( msgQReceive( callback_Q_Id, (char *)&pCallback,
+ sizeof( tCALLBACKMSG), WAIT_FOREVER )
+ == ERROR ) {
+ printf("tCallback:Cannot receive from Message Q\n");
+ continue;
+ }
+
+ /* Something wrong if we get NULL callback message */
+ if ( pCallback == NULL ) {
+ printf("tCallback:NULL Message obtained from Message Queue\n");
+ continue;
+ }
+
+ /* Get the CSB & SIM associated with the callback message */
+ csb = pCallback->csb;
+ pSim = pCallback->pSim;
+ pComSim = &(pSim->comsim);
+
+ if ( !csb || !pSim ) {
+ printf("NULL Pointer obtained for CSB / SIM \n");
+ bErrorFlag = TRUE;
+ goto cleanup;
+ }
+
+ /*
+ * If this is an interactive command,
+ * the command callback is responsible
+ * for doing any special tty processing
+ * that is needed
+ */
+ if ( csb->flags & TERMINAL_MODE ) {
+ /*
+ * Reset the terminal characteristics to 'TERMINAL' so that
+ * the callback functions need not do echoing etc
+ */
+ if ( !( csb->flags & CONFIG_CGI ) ) {
+ ioSetTerminalMode( csb->inFd, IO_LINE_MODE );
+ }
+
+ /*
+ * Disable tMore processing. We just
+ * redirect the output back to the
+ * original fd and let the parser_input
+ * layer cleanup the tMore task.
+ */
+ if (csb->savedFd >= 0) {
+ csb->outFd = csb->savedFd;
+ }
+ }
+ /*
+ * RAMS: commented this for now
+
+ taskSetTtyAttr(csb->inFd, SECONDARY_TASK, TRUE); */
+
+ /* Redirect the I/O based on the I/O Source */
+ ioTaskStdSet(0, STD_IN, csb->inFd );
+ ioTaskStdSet(0, STD_OUT, csb->outFd );
+ ioTaskStdSet(0, STD_ERR, csb->outFd );
+
+#if 0
+ /* RAMS: no access control check now */
+ /* Do not do access control check if the system is loading
+ * since during intialization all tasks execute in 'root'
+ * user context
+ */
+ if ( !systemloading && ( setUid( csb->uid ) == FALSE ) ) {
+ printf("Invalid UID obtained %d\n", (int)csb->uid);
+ csb->uid = INVALID_UID;
+ bErrorFlag = TRUE;
+ goto cleanup;
+ }
+#endif
+
+ moduleId = pComSim->origid;
+ rc = RC_OK;
+
+ /* Make note of previous mode we are in */
+ prevMode = csb->mode;
+
+ /* pIndex is a pointer to the previous cookie for 'more' */
+ csb->pIndex = pSim->index;
+ csb->maxRecordCount = pSim->maxCount;
+ /*
+ RAMS : commented this for now
+ if (( pCwd = getTaskCWD_k(csb->ioTaskId, &pFreeFunc)) == NULL) {
+ printf("Cannot get Current Working Directory\n");
+ } else {
+ setCWD( pCwd );
+ pFreeFunc( pCwd );
+ }
+ */
+
+ /* Call the 'callback function' */
+ csb->action_func(csb);
+
+ if (csb->mode == exec_mode) {
+ /* Clear all flags except some fixed ones */
+ csb->flags &= ( CONFIG_TERM | KEYWORD_MATCHED | CONFIG_PER_USER
+ | CONFIG_CGI | COMMAND_COMPLETE );
+ }
+
+ /* See if we had something from callback, via 'write_buffer' */
+ /* buffer = read_buffer();*/
+ fflush(stderr);
+ fflush(stdout);
+
+ /* Reset the CSB Line */
+ if (csb->in_help == PARSER_NO_HELP) {
+ *(csb->line) = '\0';
+ /* Indicate to I/O Task that the command was complete
+ * for history mechanism
+ */
+ csb->flags |= COMMAND_COMPLETE;
+ }
+
+ cleanup:
+
+ /* Send response back to the I/O Source ( i.e. proxy tParser )
+ * indicating the command execution is complete
+ */
+ if ( ( rc = parser_send_response( pComSim, buffer, csb->MoreStatus ) )
+ != RC_OK ) {
+ printf("tCallback:Error occured while Posting in tParser\n");
+ }
+
+
+ /* Do cleanup */
+ if ( pSim && pComSim )
+ mFREESIM( pComSim );
+
+ PARSERfree( pCallback );
+
+ /* The I/O Task will be waiting on configuration semaphore
+ * for configuration commands; If the callback function
+ * asked us to do the job ( via csb->giveConfigSem ), lets
+ * give the semaphore.
+ * Also, release the configuration semaphore, during error
+ * conditions.
+ */
+ if ( csb->giveConfigSem || bErrorFlag) {
+ if ( prevMode == config_mode ||
+ csb->mode == config_mode ||
+ prevMode == interface_mode ||
+ csb->mode == interface_mode) {
+ if ( PSsemGive( csb->configSemId ) == ERROR )
+ PSpanic("Cannot Give configuration semaphore\n");
+ }
+ }
+
+ /* Reset the I/O redirection */
+ ioTaskStdSet(0, STD_IN, inFd);
+ ioTaskStdSet(0, STD_OUT, outFd);
+ ioTaskStdSet(0, STD_ERR, errFd);
+ /*
+ * RAMS: commented this for now
+
+ taskSetTtyAttr(csb->inFd, SECONDARY_TASK, FALSE); */
+ }
+
+ return;
+}
+
+/*****************************************************************
+ *
+ * Func: parser_send_response
+ *
+ * Desc: Send a SIM to I/O Source indicating command is complete
+ *
+ * Inputs:
+ * pSim : Input SIM from parser
+ * buffer : Output buffer, if any. NULL, if nothing
+ * The I/O source will free this buffer
+ * status : Passed as SIM Status to I/O Source
+ *
+ * Result: RC_OK : If SIM Posted to I/O Source
+ * RC_ERR : Otherwise
+ *
+ * Algorithm:
+ *
+ *****************************************************************/
+tOCTET2 parser_send_response( tpCOMSIM pSim, char *buffer, tUOCTET4 status )
+{
+ tpCOMSIM pComSim = NULL;
+ tOCTET2 rc = RC_OK;
+
+ pComSim = NULL;
+ pComSim = mGETSIM( sizeof( tCOMSIM ) );
+
+ if (pComSim == NULL)
+ return (RC_ERR);
+
+ mFILL_COM_SIM( pComSim, PARSER_MODULE, pSim->origid,\
+ IO_CMD_COMPLETE_IND, pSim->requestid, buffer, 0, status );
+
+ mPOST_SIM_NIND( pComSim, rc );
+ return ( rc );
+}
+
+
+
+
+static void addSignalHandlers ( void )
+{
+ /*
+ *RAMS: Commented this for now
+
+ signal(SIGINT, defaultSignalHandler);
+ signal(SIGKILL, defaultSignalHandler); */
+}
+
+
+#ifdef IOS_PARSER
+/*
+ * Recurse through instead of using a stack
+ */
+void recurse_node (parseinfo *csb, transition *node)
+{
+ queuetype *t1 = csb->tokenQ;
+ queuetype t2;
+
+ queue_init(&t2, 0);
+ csb->tokenQ = &t2;
+ push_node(csb, node);
+ parse_token(csb);
+ csb->tokenQ = t1;
+}
+
+/*
+ * parse_checklevels
+ * check previous parser levels to see if there is a command match
+ * "up there" somewhere. This used to be part of parse_cmd(), but
+ * I moved it out to save stack space when it's not used.
+ */
+
+static void parse_checklevels (parseinfo *csb, int save_line_index)
+{
+#define MAX_MODE_STACK 5
+ typedef struct parser_mode_stack_ {
+ parser_mode *mode;
+ void *var;
+ boolean leave_subcommand;
+ uint error_index;
+ } parser_mode_stack;
+
+ /*
+ * If the parse at the secondary level fails, we save the secondary state
+ * and reset the system for parsing the at the primary level. If the
+ * primary parse also fails, we report the error for the best match.
+ * The state is set for the best match (i.e. longest error_index).
+ * This prevents an error in an interface command from allowing
+ * the broken command's subcommands to mistakenly operate on
+ * a previous interface. Similarly for other commands which have
+ * subcommands.
+ *
+ * We save (and clear) the IDB pointer so that we can get out of
+ * subinterface state. Ditto the CDB pointer.
+ */
+
+ parser_mode_stack mstack[MAX_MODE_STACK];
+ parser_mode *alt_mode;
+ int i = 0;
+
+ alt_mode = get_alt_mode(csb->mode);
+ while (alt_mode) {
+
+ if (i < MAX_MODE_STACK) {
+ mstack[i].mode = csb->mode;
+ mstack[i].var = mode_save_vars(csb);
+ mstack[i].leave_subcommand = csb->leave_subcommand;
+ mstack[i].error_index = csb->error_index;
+ i++;
+ }
+
+ csb->mode = alt_mode;
+ set_multiple_funcs(csb, 0);
+ csb->error_index = 0;
+ csb->line_index = save_line_index;
+ csb->sense = TRUE;
+ csb->set_to_default = FALSE;
+ /* zero_csb_strings(csb); */
+ csb->leave_subcommand = FALSE;
+
+ push_node(csb, get_mode_top(csb->mode));
+ parse_token(csb);
+
+ if (test_multiple_funcs(csb, '=', 0) || (csb->next == NULL)) {
+ alt_mode = get_alt_mode(csb->mode);
+ } else {
+ alt_mode = NULL;
+ }
+ }
+
+ if (test_multiple_funcs(csb, '=', 0) || (csb->next == NULL)) {
+ while ((i > 0) && (!csb->leave_subcommand) ) {
+ i--;
+ csb->error_index = mstack[i].error_index;
+ csb->leave_subcommand = mstack[i].leave_subcommand;
+ csb->mode = mstack[i].mode;
+ mode_reset_vars(csb, mstack[i].var);
+ }
+ }
+}
+
+void show_parser_unresolved (parseinfo *csb)
+{
+ chain_list *cp = cl;
+
+ printf("\nUnresolved parse chains:");
+ while (cp != NULL) {
+ printf("\n %-3d", cp->cp.id);
+#ifdef PARSER_DEBUG_LINKS
+ printf(" %s", cp->cp.name);
+#endif /* PARSER_DEBUG_LINKS */
+ cp = cp->next;
+ }
+}
+
+#ifdef PARSER_DEBUG_LINKS
+void show_parser_links (parseinfo *csb)
+{
+ chain_link *cp;
+ dynamic_transition *tp;
+ int i = 0;
+ chain_list *lp;
+ static const char *show_links_header =
+ "\n Name ID Addr Type";
+
+ if ( PSsemTake(parse_chain_sem, WAIT_FOREVER) == ERROR ) {
+ PSpanic("Cannot take parse chain semaphore\n");
+ }
+
+ if (!GETOBJ(string,1)[0]) {
+ printf("\nCurrent parser link points:");
+ printf(show_links_header);
+
+ cp = &chain_gang[i++];
+ while (cp && cp->name != NULL) {
+ printf("\n %30s %-4d 0x%6x %-2d",
+ cp->name, cp->id, cp->link_point, cp->type);
+ cp = &chain_gang[i++];
+ }
+ printf("\nAdded at run time:");
+ printf(show_links_header);
+ lp = llist;
+ while (lp != NULL) {
+ printf("\n %30s %-4d 0x%6x %-2d",
+ lp->cp.name, lp->cp.id, lp->cp.link_point, lp->cp.type);
+ lp = lp->next;
+ }
+ printf("\n");
+ goto SEMRELEASE;
+ }
+
+ cp = get_link_point_by_name(GETOBJ(string,1));
+ if (!cp) {
+ printf("\n%% Unknown parser link point '%s'", GETOBJ(string,1));
+ goto SEMRELEASE;
+ }
+
+ if (!cp->link_point ||
+ !cp->link_point->accept ||
+ cp->link_point->accept == (dynamic_transition *)&pname(link_trans)) {
+ printf("\nNo links for link point '%s'", GETOBJ(string,1));
+ goto SEMRELEASE;
+ }
+
+ printf("\nCurrent links for link point '%s':", GETOBJ(string,1));
+ tp = cp->link_point->accept;
+ while (tp && (tp != (dynamic_transition *)&pname(link_trans))) {
+ if (tp->args) {
+ printf("\n %s", tp->args);
+ }
+ tp = tp->alternate;
+ }
+ printf("\n");
+
+
+ SEMRELEASE:
+
+ if ( PSsemGive(parse_chain_sem) == ERROR ) {
+ PSpanic("Cannot give parse chain semaphore\n");
+ }
+}
+
+#ifdef PARSER_DEBUG_LINKS
+/*
+ * Get link point by name
+ */
+static chain_link *get_link_point_by_name (const char *name)
+{
+ int i = 0;
+ chain_link *cp;
+ chain_list *lp;
+
+ /* Check static link points */
+ cp = &chain_gang[i++];
+ while (cp && cp->name != NULL) {
+ if (strcmp(cp->name, name) == 0) {
+ return(cp);
+ }
+ cp = &chain_gang[i++];
+ }
+ /* Check dynamic link points */
+ lp = llist;
+ while (lp != NULL) {
+ if (strcmp(lp->cp.name, name) == 0) {
+ return(&lp->cp);
+ }
+ lp = lp->next;
+ }
+ /* Didn't find anything */
+ return(NULL);
+}
+#endif /* PARSER_DEBUG_LINKS */
+
+/*
+ * parser_link_point_exists
+ * Return TRUE if someone has added the named entry link point.
+ */
+
+boolean parser_link_point_exists (uint which_chain)
+{
+ chain_list *lp;
+ boolean status = FALSE;
+
+ if ( PSsemTake(parse_chain_sem, WAIT_FOREVER) == ERROR ) {
+ PSpanic("Cannot take parse chain semaphore\n");
+ }
+
+ for (lp = llist; lp; lp = lp->next) {
+ if ((which_chain == lp->cp.id) &&
+ (PARSER_ENTRY_LINK_POINT == lp->cp.type))
+ status = (TRUE);
+ break;
+ }
+
+ if ( PSsemGive(parse_chain_sem) == ERROR ) {
+ PSpanic("Cannot give parse chain semaphore\n");
+ }
+ return(status);
+}
+
+#endif /* PARSER_DEBUG_LINKS */
+
+
+/*
+ * exit any configuration mode session block might be in.
+ */
+void exit_config_modes (parseinfo *csb)
+{
+ if ((csb->mode == config_mode) || test_mode_config_subcommand(csb)) {
+ exit_config_command(csb);
+ }
+}
+
+
+#endif /* IOS_PARSER */
+
+
+#define BEL "\007"
+
+/*
+ * word_completion
+ *
+ * Complete a keyword by comparing the current input line and the
+ * contents of the help buffer. If there is only one match in the help
+ * buffer, then verify that the keyword and the match are the same.
+ */
+static boolean word_completion (parseinfo *csb)
+{
+ char *cp, *sp;
+ char *hp, *jp, *ojp, *kp;
+ int help_matches = 0;
+
+ cp = sp = hp = jp = ojp = kp = NULL;
+
+ if ((help_matches = count_help_matches(csb)) == 0) {
+ /* No matches, seeya */
+ return(FALSE);
+ }
+
+ /* Find the start of the last word in the input */
+ for (cp = csb->line; *cp; cp++)
+ ; /* Null body */
+
+ while (cp != csb->line && *(cp-1) != ' ') {
+ cp--;
+ }
+
+ /* Find first help match */
+ for (hp = csb->help_save.buf;
+ hp && *hp && *hp != '\t' && *hp != '\n';
+ hp++) {
+ ; /* Null body */
+ }
+ /* See if we can find anything shorter */
+ jp = hp;
+ while (jp && *jp) {
+ /* move past white space to next help */
+ for (; jp && (*jp == '\t' || *jp == '\n'); jp++) {
+ ; /* Null body */
+ }
+ if (!jp || !*jp) {
+ /* end of help */
+ continue;
+ }
+ /* save pointer to beginning of current help */
+ ojp = jp;
+ /* find length of match */
+ for (kp = csb->help_save.buf;
+ jp && *jp && *jp != '\t' && *jp != '\n' &&
+ (tolower(*kp) == tolower(*jp));
+ jp++, kp++) {
+ ; /* Null body */
+ }
+ /* See if matched length is shorter */
+ if ((hp - csb->help_save.buf) > (jp - ojp)) {
+ hp = csb->help_save.buf + (jp - ojp);
+ }
+ /* Move to next white space */
+ for (; jp && *jp && *jp != '\t' && *jp != '\n'; jp++) {
+ ; /* Null body */
+ }
+ }
+
+ /* move to end of last word in the input */
+ for (sp = csb->help_save.buf;
+ *cp && *sp && (sp != hp) && (*sp != '\t') && (*sp != '\n');
+ cp++,sp++) {
+
+ /* Check that the input and the matched word are the same. */
+ if (tolower(*cp) != tolower(*sp)) {
+ printf("word_completion:Input / Output Did not Match\n");
+ return(FALSE);
+ }
+ }
+ /* We may have been attempting a match at the end of a line.
+ * In this case, we could copy an invalid help string onto the
+ * end of the current line (e.g. adding "<cr>" to the line.)
+ *
+ * This proccedure of using the help mechanism is totally wrong.
+ * Instead, a separate flag should be used for command completion
+ * and only the keyword action routine should add text to the help
+ * buffer. The other action routines should not add anything to
+ * the help buffer in this case.
+ *
+ * Until the above gets done, do not add help text which begins with
+ * a blank.
+ */
+ if (*sp == ' ') {
+ return(FALSE);
+ }
+
+ while (*sp && (sp != hp) && (*sp != '\t') && (*sp != '\n')) {
+ /* copy the rest of the matched word into the input buffer */
+ *cp++ = *sp++;
+ }
+ if (help_matches != 1) {
+ *cp = '\0';
+ return(FALSE);
+ }
+ *cp++ = ' '; /* Add trailing space */
+ *cp = '\0';
+ return(TRUE);
+}
+
+void push_node (parseinfo *csb, transition *node)
+{
+ parsenode *pp;
+
+ if (node->func == (trans_func) NONE_action) {
+ /*
+ * Nothing to do for NONE transitions, so return
+ */
+ return;
+ }
+
+ /* If we fail to obtain memory, we will not push this node onto
+ * the queue and this transition will never happen. We cannot
+ * propagate a return code all the way back up the stack and even
+ * if we did, we'd probably have to just prune this portion of the
+ * parse tree and try to keep going. Doing it here seems the best
+ * overall solution.
+ */
+ if ((pp = get_parsenode(csb)) == NULL) {
+ return;
+ }
+ pp->node = node;
+ pp->line_index = csb->line_index;
+ if (csb->nvgen || (csb->flags & COMMAND_AUTHORIZE)) {
+ strcpy(pp->nv_command, csb->nv_command);
+ }
+ pp->pmp = csb->pmp;
+ strcpy(pp->visible_ambig, csb->visible_ambig.ambig);
+ strcpy(pp->hidden_ambig, csb->hidden_ambig.ambig);
+ pp->command_visible = csb->command_visible;
+ pp->unsupported = csb->unsupported;
+ pp->sense = csb->sense;
+ pp->set_to_default = csb->set_to_default;
+ requeue(csb->tokenQ, pp);
+}
+
+/*
+ * Parse tokens from the top of the token stack. We check our
+ * runtime against the saved runtime and allow other processes
+ * access to the CPU every 250ms. This prevents the starvation
+ * of other processes during NVGEN and other CPU intensive operations.
+ *
+ * While there are tokens on the stack, we pop one off and call the
+ * token specific processing routine. The token specific processing
+ * routine will make sure the top of the stack contains the next
+ * node that should be processed (either by adding one or more nodes to the
+ * stack, or not adding anything to the stack.
+ */
+void parse_token (parseinfo *csb)
+{
+ parsenode *tos; /* Top of the stack */
+
+ while (! QUEUEEMPTY(csb->tokenQ)) {
+
+ tos = (parsenode *)dequeue(csb->tokenQ);
+
+ if (tos) {
+ if (tos->node) {
+ csb->line_index = tos->line_index;
+ csb->pmp = tos->pmp;
+ strcpy(csb->visible_ambig.ambig, tos->visible_ambig);
+ strcpy(csb->hidden_ambig.ambig, tos->hidden_ambig);
+ csb->command_visible = tos->command_visible;
+ csb->unsupported = tos->unsupported;
+ csb->sense = tos->sense;
+ csb->set_to_default = tos->set_to_default;
+ if (csb->nvgen || (csb->flags & COMMAND_AUTHORIZE)) {
+ strcpy(csb->nv_command, tos->nv_command);
+ }
+ if (tos->node->func) {
+ tos->node->func(csb, tos->node, tos->node->args);
+ }
+ }
+ tos->next = NULL;
+ PARSERfree(tos);
+ }
+ }
+}
+
+/*
+ * Parse a command line.
+ */
+int parse_cmd (parseinfo *csb, tpPARSERSIM pSim)
+{
+ int error = PARSE_ERROR_NOERR; /* 0=ERROR_NOERR; ERROR_AMBIG;
+ * ERROR_NOMATCH; ERROR_UNKNOWN;
+ * ERROR_ALIAS;
+ */
+ int save_line_index;
+ static boolean first_time_through = TRUE;
+ boolean alias_was_expanded = FALSE;
+ boolean execCallback = FALSE;
+ int inFd, outFd, errFd;
+ tpCALLBACKMSG pCallback=NULL;
+ tpCOMSIM pComSim = NULL;
+
+
+ inFd = ioTaskStdGet( 0, STD_IN );
+ outFd = ioTaskStdGet( 0, STD_OUT );
+ errFd = ioTaskStdGet( 0, STD_ERR );
+
+ ioTaskStdSet(0, STD_IN, csb->inFd );
+ ioTaskStdSet(0, STD_OUT, csb->outFd );
+ ioTaskStdSet(0, STD_ERR, csb->outFd );
+
+ csb->MoreStatus = RC_OK;
+ csb->giveConfigSem = TRUE;
+
+
+ if (first_time_through) {
+ resolve_parse_chains();
+ parser_modes_init();
+ first_time_through = FALSE;
+ }
+
+ parse_cmd_init(csb);
+
+ /*
+ * Check for empty lines.
+ * Strip leading whitespace.
+ * Save comments if in config mode.
+ */
+ for (csb->line_index = 0; csb->line[csb->line_index] == ' ' ||
+ csb->line[csb->line_index] == '\t'; csb->line_index++)
+ ; /* Null body */
+
+ /* Ignore empty lines which aren't help requests */
+ if ((csb->line[csb->line_index] == '\0') &&
+ !csb->in_help &&
+ !(csb->flags & PARSE_EMPTY_STRING)) {
+ *csb->line = '\0';
+ error = PARSE_ERROR_NOERR;
+ goto SEMRELEASE;
+
+ }
+ if ((csb->line[csb->line_index] == '!' ||
+ csb->line[csb->line_index] == '#' ||
+ csb->line[csb->line_index] == ';')) {
+ /* XXX Need a better algorithm for saving comments. */
+ save_line(csb, &csb->comment_save, "%s\n", csb->line);
+ *csb->line = '\0';
+ /* return(PARSE_ERROR_NOERR);*/ /* comments are always successful */
+ error = PARSE_ERROR_NOERR;
+ goto SEMRELEASE;
+ }
+
+ /* We do not currently support aliases. Need to
+ * include parser_alias.c in Makefile to make this
+ * work
+ if (expand_alias(csb)) {
+ alias_was_expanded = TRUE;
+ }
+ */
+
+ save_line_index = csb->line_index;
+
+ push_node(csb, get_mode_top(csb->mode));
+ parse_token(csb);
+
+ /* If setting privilege levels on commands, csb->priv_set will
+ * be non-zero, and csb->multiple_funcs will be > 1. This is
+ * not an error.
+ */
+ if (csb->priv_set) {
+ error = PARSE_ERROR_NOERR;
+ goto SEMRELEASE;
+ }
+
+ /* Doing help processing.
+ * If there was an ambiguous command match,
+ * print the ambiguous message, otherwise print the help message.
+ * If no help was provided, then tell the user that the command
+ * was unrecognized.
+ */
+ if (csb->in_help) {
+ /*
+ * If the number of visible matches is > 1, or
+ * the number of visible matches == 0 and the
+ * number of invisible matches > 1, then the
+ * command is ambiguous
+ */
+ if (test_visible_multiple_funcs(csb, '>', 1) ||
+ (test_visible_multiple_funcs(csb, '=', 0) &&
+ test_invisible_multiple_funcs(csb, '>', 1))) {
+ DBG_PARSER("\n Ambiguous command");
+ error = PARSE_ERROR_AMBIG;
+ } else {
+
+ /* There are two choices here:
+ * 1. The user asked for help.
+ * 2. The user requested keyword completion.
+ */
+ if (csb->lastchar == '?') {
+ if (csb->help_save.used > 0) {
+
+ csb->action_func = parser_help;
+ /*
+ * Have a callback task run the command.
+ */
+ pCallback = ( tpCALLBACKMSG)
+ PARSERmalloc(sizeof(tCALLBACKMSG));
+ pCallback->csb = csb;
+ pCallback->pSim = pSim;
+ if ((csb->mode != config_mode)) /* ||
+ (csb->mode != interface_mode)) */
+ {
+ csb->giveConfigSem = FALSE;
+ }
+ if ( msgQSend(callback_Q_Id, ( char *)&pCallback,
+ sizeof(tpCALLBACKMSG),
+ WAIT_FOREVER, MSG_PRI_NORMAL) == ERROR )
+ {
+ printf("Cannot send message to "
+ "callback queue\n");
+ error = PARSE_ERROR_NOERR;
+ }
+ execCallback = TRUE;
+
+ } else {
+ error = PARSE_ERROR_UNKNOWN;
+ }
+ } else { /* csb->lastchar == '\t' */
+ if ((word_completion(csb) == FALSE)) {
+ printf("\007");
+ }
+ }
+ }
+ } else {
+
+ /* If not doing help processing, then check whether the
+ * parse uniquely identified a command. If not, report
+ * the error (if no command was matched) or report that
+ * the command was ambiguous (if more than one command matched).
+ */
+
+ /* No commands matched. Report the error */
+ if (test_multiple_funcs(csb, '=', 0) || (csb->next == NULL)) {
+ if (alias_was_expanded) {
+ error = PARSE_ERROR_NOMATCH | PARSE_ERROR_ALIAS;
+ } else {
+ /* DBG_PARSER("\nNO MATCH OF COMMANDS"); */
+ error = PARSE_ERROR_NOMATCH;
+ }
+ }
+
+ /*
+ * If the number of visible matches is > 1, or
+ * the number of visible matches == 0 and the
+ * number of invisible matches > 1, then the
+ * command is ambiguous.
+ *
+ * Multiple functions were identified. This was an
+ * ambiguous command. Report the error.
+ */
+
+ if (test_visible_multiple_funcs(csb, '>', 1)) {
+ error = PARSE_ERROR_AMBIG;
+ } else {
+ if ((test_visible_multiple_funcs(csb, '=', 0) &&
+ test_invisible_multiple_funcs(csb, '>', 1))) {
+ if ((csb->line[csb->error_index] == '\0') &&
+ (csb->error_index > 0) && !csb->next) {
+ error = PARSE_ERROR_NOMATCH;
+ } else {
+ error = PARSE_ERROR_AMBIG;
+ }
+ }
+ }
+ /* If not doing help processing and one function selected,
+ * then we've successfully parsed a command. Restore its
+ * state and call the command function.
+ */
+ if (test_visible_multiple_funcs(csb, '=', 1) ||
+ (test_visible_multiple_funcs(csb, '=', 0) &&
+ test_invisible_multiple_funcs(csb, '=', 1))) {
+ boolean do_hidden_funcs = TRUE;
+
+ /*
+ * If test_visible_multiple_funcs == 1, then
+ * don't execute hidden functions
+ */
+
+ if (test_visible_multiple_funcs(csb, '=', 1)) {
+ do_hidden_funcs = FALSE;
+ }
+
+ while (csb->next != NULL) {
+ parseinfo *thiscsb;
+
+ /* Don't free the csb itself. Must copy its contents
+ * since csb was passed to us and the caller will need to
+ * continue to use this particular structure.
+ */
+ thiscsb = csb->next;
+ *csb = *csb->next; /* Struct copy */
+ /* chunk_free(parseinfo_chunks, thiscsb); */
+ PARSERfree( thiscsb );
+ thiscsb = NULL;
+
+ if (csb->command_visible ||
+ (!csb->command_visible && do_hidden_funcs)) {
+
+ if (csb->flags & COMMAND_FUNCTION) {
+ if (csb->command_function) {
+ csb->command_function(csb);
+ }
+ } else {
+ if (csb->action_func) {
+
+ /*
+ * Have a callback task run the command.
+ */
+ pCallback = ( tpCALLBACKMSG)
+ PARSERmalloc(sizeof(tCALLBACKMSG));
+ pCallback->csb = csb;
+ pCallback->pSim = pSim;
+ csb->giveConfigSem = FALSE;
+ if ( msgQSend(callback_Q_Id, ( char *)&pCallback,
+ sizeof(tpCALLBACKMSG),
+ WAIT_FOREVER, MSG_PRI_NORMAL)
+ == ERROR ) {
+ printf("Cannot send message to "
+ "callback queue\n");
+ error = PARSE_ERROR_NOERR;
+ }
+ execCallback = TRUE;
+ }
+ }
+ }
+ }
+ }
+
+ }
+
+ /* Free any lingering saved parseinfo structures, if needed. */
+ {
+ parseinfo *thiscsb = csb->next;
+ while (thiscsb != NULL) {
+ parseinfo *nextpd = thiscsb->next;
+ /* chunk_free(parseinfo_chunks, thiscsb); */
+ PARSERfree( thiscsb );
+ thiscsb = nextpd;
+ }
+ csb->next = NULL;
+ }
+
+ /* Reset prompt_lead if needed. This has to be done here because
+ * a primary config command may cause the parser to switch from
+ * a subcommand set. Only here do we know that this switch has
+ * occurred and only by examining the top of the active parse tree.
+ * This also has to be done for handling configuration from
+ * memory or net so that we aren't left with the prompt
+ * indicating the wrong command level.
+ */
+ if ( ( execCallback == FALSE ) && (csb->mode == exec_mode)) {
+ /* Clear all flags except some fixed ones */
+ csb->flags &= ( CONFIG_TERM | KEYWORD_MATCHED | CONFIG_PER_USER
+ | CONFIG_CGI | COMMAND_COMPLETE );
+ }
+
+ /* The only errors that we can report are parse errors. The commands
+ * are expected to report their internal errors.
+ */
+
+ SEMRELEASE:
+
+ if ( execCallback == FALSE ) {
+
+ /* Indicate to I/O Task that the command was complete
+ * for history mechanism
+ */
+ if ( csb->in_help == PARSER_NO_HELP )
+ csb->flags |= COMMAND_COMPLETE;
+
+ pComSim = &(pSim->comsim);
+
+ if ( error != PARSE_ERROR_NOERR && !(csb->flags & CONFIG_HTTP ) ) {
+ report_error(csb,error , FALSE);
+ }
+ if (csb->in_help == PARSER_NO_HELP) {
+ *(csb->line) = '\0';
+ }
+ parser_send_response(pComSim, NULL, csb->MoreStatus );
+ mFREESIM(pComSim);
+
+ if ( csb->giveConfigSem &&
+ ((csb->mode == config_mode) || (csb->mode == interface_mode)))
+ {
+ if ( PSsemGive( csb->configSemId ) == ERROR )
+ {
+ PSpanic("Cannot Give configuration semaphore\n");
+ }
+ }
+
+ }
+
+ ioTaskStdSet(0, STD_IN, inFd);
+ ioTaskStdSet(0, STD_OUT, outFd);
+ ioTaskStdSet(0, STD_ERR, errFd);
+
+ return(error);
+}
+
+
+/*
+ * bad_parser_subcommand
+ * Common code fragment for handling a bad subcommands with the new parser
+ */
+void bad_parser_subcommand (parseinfo *csb, uint var)
+{
+ printf("Bad Parser Sub-command : %s\n",
+ (csb->nvgen)?csb->nv_command:csb->line);
+}
+
+
+/*****************************************************************
+ *
+ * Func: ParserCallbackInit
+ *
+ * Desc: Initialize all parser callback tasks
+ *
+ * Inputs: None
+ *
+ * Result: None
+ *
+ * Algorithm:
+ *
+ *****************************************************************/
+extern int ParserCallBackTask[3];
+void ParserCallbackInit( void )
+{
+#define MAX_CALLBACK_TASKS 3
+
+ tINT index;
+ char tname[32];
+
+ /* Create the Message Queue. The parser (tParser) communicates
+ * with the callback tasks (tCallback) via this message queue
+ */
+ callback_Q_Id = msgQCreate( 1, sizeof(tpCALLBACKMSG), MSG_Q_FIFO);
+
+ if ( callback_Q_Id == NULL ) {
+ PSpanic("Cannot create callback message queue\n");
+ }
+
+ /* Spawn all the callback tasks */
+ for ( index = 0; index < MAX_CALLBACK_TASKS; index++) {
+ sprintf(tname, "tCallback%d", index);
+ ParserCallBackTask[index]=taskSpawn(tname,PARSER_TASK_PRIORITY, PARSER_TASK_OPTION, PARSER_TASK_STACK_SIZE,
+ (FUNCPTR)parser_exec_callback, 0,0,0,0,0,0,0,0,0,0);
+ if(ParserCallBackTask[index] == ERROR ) {
+ PSpanic("Cannot spawn callback tasks\n");
+ }
+
+ }
+}
+void ParserCallbackRestart(int index){
+
+ char tname[32];
+ /* Create the Message Queue. The parser (tParser) communicates
+ * with the callback tasks (tCallback) via this message queue
+ */
+ callback_Q_Id = msgQCreate( 1, sizeof(tpCALLBACKMSG), MSG_Q_FIFO);
+
+ if ( callback_Q_Id == NULL ) {
+ PSpanic("Cannot create callback message queue\n");
+ }
+ /* Spawn all the callback tasks */
+ sprintf(tname, "tCallback%d", index);
+ ParserCallBackTask[index]=taskSpawn(tname,PARSER_TASK_PRIORITY, PARSER_TASK_OPTION, PARSER_TASK_STACK_SIZE,
+ (FUNCPTR)parser_exec_callback, 0,0,0,0,0,0,0,0,0,0);
+ if(ParserCallBackTask[index] == ERROR ) {
+ PSpanic("Cannot spawn callback tasks\n");
+ }
+
+}
diff --git a/data/mnet/Common/cli/src/parser_actions.c b/data/mnet/Common/cli/src/parser_actions.c
new file mode 100644
index 0000000..0dc9583
--- /dev/null
+++ b/data/mnet/Common/cli/src/parser_actions.c
@@ -0,0 +1,3486 @@
+#include <vxworks.h>
+#include <stdioLib.h>
+#include <tyLib.h>
+#include <taskLib.h>
+#include <errnoLib.h>
+#include <lstLib.h>
+#include <inetLib.h> /* for INET_ADDR_LEN */
+#include <timers.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <msgQLib.h>
+#include <sigLib.h>
+
+
+#include <../include/cli_parser_private.h>
+#include <../include/pstypes.h>
+#include <../include/psvxif.h>
+#include <../include/imsg.h>
+#include <../include/imc.h>
+#include <../include/address.h>
+#include <../include/parsertypes.h>
+#include <../include/config.h>
+#include <../include/parser_sim.h>
+#include <../include/parser.h>
+#include <../include/parser_defs_exec.h>
+#include <../include/parser_input.h>
+#include <../include/parser_sim.h>
+#include <../include/parser_util.h>
+#include <../include/parser_commands.h>
+#include <../include/nv.h>
+#include <../include/parser_errno.h>
+#include <../include/parser_ModNum.h>
+#include <../include/defs.h>
+#include <../include/parser_init.h>
+#include <../include/macros.h>
+#include <../include/parser_actions.h>
+#include <../include/parser_privilege.h>
+/*#include <limits.h>
+ /#include <clock.h> */
+
+#define DAYS_IN_WEEK 7
+#define MONTHS_IN_YEAR 12
+
+#define CHECK_RANGE_BOUNDS()\
+ if (arg->upper >= arg->lower) {\
+ lower = arg->lower;\
+ upper = arg->upper;\
+ } else {\
+ lower = arg->upper;\
+ upper = arg->lower;\
+ }
+
+#define CHECK_RANGE_BOUNDS_ALIST()\
+ if (arg->upper >= arg->lower) {\
+ lower = arg->lower;\
+ upper = arg->upper;\
+ } else {\
+ lower = arg->upper;\
+ upper = arg->lower;\
+ }\
+ if (arg->upper2 >= arg->lower2) {\
+ lower2 = arg->lower2;\
+ upper2 = arg->upper2;\
+ } else {\
+ lower2 = arg->upper2;\
+ upper2 = arg->lower2;\
+ }
+
+/********************************/
+/* Module Local Data */
+/********************************/
+
+const char *const month_name[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
+ "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
+const char *const day_name[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri",
+ "Sat"};
+const char *const long_month_name[] = {"January", "February", "March",
+ "April", "May", "June", "July",
+ "August", "September", "October",
+ "November", "December"};
+const char *const long_day_name[] = {" ", "Sunday", "Monday", "Tuesday",
+ "Wednesday", "Thursday", "Friday",
+ "Saturday"};
+
+
+#ifdef IOS_PARSER
+
+/*
+ * Local variables
+ * Uncomment this when it is necessary
+ */
+keyword_options permitdeny_options[] = {
+ { "deny", "Specify packets to reject", FALSE },
+ { "permit", "Specify packets to forward", TRUE },
+ { NULL, NULL, 0 }
+};
+
+static boolean match_spaces(char *buf, int *pi);
+static char *hex_to_byte(char *s, char *out);
+
+#endif /* IOS_PARSER */
+
+/*
+ * Forward declarations
+ */
+static void parser_bail_out(parseinfo *, void (*)(parseinfo *), const char *);
+static void set_error_index(parseinfo *);
+static boolean match_signed_dec(char *, int, int, int *, int *);
+
+static void save_ambig_int(parseinfo *, const char *, int);
+static void save_ambig_uint(parseinfo *, const char *, uint);
+static void save_ambig_nstring(parseinfo *, const char *, const char *, uint);
+static void save_ambig_string_flag(parseinfo *, const char *, const char *, boolean);
+static void save_help_short(parseinfo *, const char *, boolean);
+static void save_help_msg(parseinfo *, const char *);
+static void nvgen_action(parseinfo *, transition *, void (*)(parseinfo *));
+void func_action (parseinfo *csb, transition *mine, void (*func) (parseinfo *));
+/* The parser match routines use simpler C routines to match the smaller
+ * pieces of tokens. These sub-routines come in two flavors:
+ *
+ * XXX_match returns (int) the number of chars it matched;
+ * use conclude_match to back over a successful match
+ * XXX_check returns (boolean) the status of the check;
+ * consumes no input
+ */
+
+/* These simple match and check routines could be made inline:
+ *
+ * terminator_check Did user hit RETURN, start a comment, or request help?
+ * eol_check Did user hit RETURN or start a comment here?
+ * help_check Did user request help here?
+ * Don't use this directly, try one of the next ones;
+ * long_help_check Did user request long help here?
+ * i.e, is this BOL or was last char W/S?
+ * short_help_check Did user request short help here?
+ * Opposite of long_help_check
+ */
+
+static boolean terminator_check (parseinfo *csb)
+{
+ return(is_terminator(csb->line[csb->line_index]));
+}
+
+boolean eol_check (parseinfo *csb)
+{
+ return(!csb->in_help && terminator_check(csb));
+}
+
+ boolean help_check (parseinfo *csb)
+{
+ return(csb->in_help && !csb->nvgen && terminator_check(csb));
+}
+
+static boolean long_help_check (parseinfo *csb)
+{
+ return(help_check(csb) &&
+ (csb->line_index == 0 || isspace(csb->line[csb->line_index - 1])));
+}
+
+static boolean short_help_check (parseinfo *csb)
+{
+ return(help_check(csb) && !long_help_check(csb));
+}
+
+static boolean priv_check (parseinfo *csb, trans_priv *priv)
+{
+ /*
+ * Only process keywords which are visible to the user at their current
+ * priv level.
+ */
+ if (csb->priv < priv->cur_priv) {
+ return(FALSE);
+ }
+
+ if ((TRANS_PRIV_FLAGS_GET(priv->flags) & PRIV_INTERACTIVE)) {
+ if (csb->flags & CONFIG_HTTP) {
+ return(FALSE);
+ }
+ }
+
+ /* Modify the current keyword privilege
+ * Don't allow internal commands unless they are enabled.
+ */
+
+ if ((TRANS_PRIV_FLAGS_GET(priv->flags) & PRIV_INTERNAL)
+ /* && !internal_cmd_enable */ ) {
+ return(FALSE);
+ }
+
+ /* Don't allow keywords not applicable to synalc
+ */
+
+ if ((TRANS_PRIV_FLAGS_GET(priv->flags) & PRIV_PSYNALC)
+ /* && (cpu_type == CPU_SYNALC) */
+ ) {
+ return(FALSE);
+ }
+
+ if (csb->in_help) {
+ /* Don't display keywords which are hidden */
+ if (TRANS_PRIV_FLAGS_GET(priv->flags) &
+ (PRIV_HIDDEN | PRIV_UNSUPPORTED)) {
+ return(FALSE);
+ }
+ }
+ /* Don't do NV generation on keywords that are obsolete */
+ if (csb->nvgen &&
+ !csb->priv_set &&
+ (TRANS_PRIV_FLAGS_GET(priv->flags) & PRIV_NONVGEN)) {
+ return(FALSE);
+ }
+
+ if ((TRANS_PRIV_FLAGS_GET(priv->flags) &
+ (PRIV_HIDDEN | PRIV_UNSUPPORTED)) ||
+ ((TRANS_PRIV_FLAGS_GET(priv->flags) & PRIV_NOHELP) &&
+ (csb->in_help == PARSER_NO_HELP))) {
+ csb->command_visible = FALSE;
+ }
+ if (TRANS_PRIV_FLAGS_GET(priv->flags) & PRIV_UNSUPPORTED) {
+ csb->unsupported = TRUE;
+ }
+
+ return(TRUE);
+}
+
+static void keyword_flag_modify (parseinfo *csb, trans_priv *priv, uint *flags)
+{
+ /* If this is a duplicate keyword, as indicated by PRIV_DUPLICATE in
+ * the keyword privileges, then reset KEYWORD_HELP_CHECK. This will
+ * prevent match_partial_keyword() from supplying any help for this
+ * keyword.
+ */
+
+ if ((TRANS_PRIV_FLAGS_GET(priv->flags) & PRIV_DUPLICATE) ||
+ (TRANS_PRIV_FLAGS_GET(priv->flags) & PRIV_NOHELP) ||
+ ((TRANS_PRIV_FLAGS_GET(priv->flags) & PRIV_USER_HIDDEN) &&
+ (csb->priv == PRIV_USER) &&
+ !(csb->flags & CONFIG_HTTP))) {
+ *flags &= ~KEYWORD_HELP_CHECK;
+ }
+}
+
+boolean match_char (char *cp, int *offset, char c)
+{
+ if (*(cp + *offset) == c) {
+ (*offset)++;
+ return(TRUE);
+ }
+ return(FALSE);
+}
+
+/*
+ * In effect, combines the match_whitespace ... csb->line_index += j; if
+ * (j | eol_check) sequences.
+ */
+boolean match_whitespace2 (char *cp, int *offset, boolean in_help)
+{
+ if (isspace(cp[*offset])) {
+ while (isspace(cp[*offset])) {
+ (*offset)++;
+ }
+ return(TRUE);
+ }
+ if ((!in_help) && is_terminator(cp[*offset])) {
+ return(TRUE);
+ }
+ return(FALSE);
+}
+
+boolean get_name (char *buf, char *name, int *pi, int buflen)
+{
+ char *sp, *dp;
+ int i;
+
+ /* Copy the name into local working storage */
+ sp = buf;
+ dp = name;
+ for (i = 0; i < buflen; i++) {
+ if (*sp == ' ' || *sp == '\0') {
+ break;
+ }
+ *dp++ = *sp++;
+ }
+ *dp = '\0';
+ if (i == 0)
+ return(FALSE);
+ if (i == buflen && (*sp != ' ' || *sp != '\0')) {
+ return(FALSE);
+ }
+
+ *pi = i;
+ return(TRUE);
+}
+
+/* NONE does just what its name implies */
+
+void NONE_action (parseinfo *csb)
+{
+}
+
+/* link_point is a place holder. It should never be reached. */
+
+void link_point_action (parseinfo *csb)
+{
+ printf("link_point_action(): Error\n");
+}
+
+/*
+ * no_alt is used at the end of a list of alternative tokens.
+ *
+ * There are several actions performed in no-alt-action, depending on the
+ * state of the parser.
+ *
+ * If performing NV generation, we return(i.e. do nothing).
+ *
+ * If providing help, we must check to see if more than one command has
+ * provided help (i.e. the command is ambiguous.) However, we can have
+ * multiple options generated by a single command. We keep track of all
+ * this by storing, each time through no_alt, the length of the help text
+ * generated so far. If the length has increased since the last no_alt,
+ * we increment csb->multiple_funcs. Thus we count how many token chains
+ * have generated help.
+ *
+ * If no-alt-action is called when setting keyword privileges, then
+ * don't treat it as an error. Increment csb->multiple_funcs so that
+ * token chains that have to check for previously matched tokens
+ * will work correctly.
+ *
+ * When no-alt-action is encountered in normal processing, increase
+ * error_index to our current line position if it's smaller.
+ * This indicates the deepest character in the command line we reached.
+ * parse_cmd() checks csb->multiple_funcs first to determine if an error
+ * occured. It will be zero if no command match occurred, and greater
+ * than one if the command input is ambiguous. If no command matched,
+ * error_index is deepest character we reached in the parse, and tells
+ * where to put an error marker.
+ */
+
+void no_alt_action (parseinfo *csb)
+{
+ ambig_struct *ap;
+
+ if (csb->command_visible) {
+ ap = &csb->visible_ambig;
+ } else {
+ ap = &csb->hidden_ambig;
+ }
+
+ /* NV generation */
+ if (csb->nvgen) {
+ return;
+ }
+
+ /*
+ * Priv set processing. If csb->priv_set is not PRIV_NULL, then don't
+ * treat being called as an error. Increment csb->multiple_funcs and
+ * return.
+ */
+ if (csb->priv_set) {
+ increment_multiple_funcs(csb, "no_alt_action 1");
+ return;
+ }
+
+ /* Help processing. Check the ambiguity buffers against one another.
+ * If ambig is non-null, we've matched some input and need to
+ * compare against ambig_save to see if it is ambiguous.
+ * This yields two cases:
+ * 1. ambig_save == NULL, indicating that this is the first match
+ * and that multiple_funcs should be incremented.
+ * 2. ambig_save != NULL, indicating that this is ambiguous and
+ * that multiple_funcs should be incremented again.
+ */
+ if (parser_ambig_debug) {
+ printf("\n1 Ambig buf '%s'", ap->ambig);
+ printf("\n1 Ambig_save buf '%s'", ap->ambig_save);
+ }
+ /***************************************************************************
+ ***************************************************************************
+ *
+ *
+ * Before you touch the ambiguity code, make sure you know what you
+ * are doing, or else it will break
+ *
+ * Here are some cases to case the behavior of the code
+
+ en
+
+ ! output should "interface internals"
+ show ip ospf int?
+
+ ! ambiguous
+ show ip ospf int ?
+
+ conf term
+ ! output should be "x25 x29 xns"
+ service pad
+ x?
+ ! ambiguous
+ x ?
+ ! output should be "x25 x29"
+ x2?
+ ! ambiguous
+ x2 ?
+ ! output should be "route routing"
+ xns rout?
+ ! ambiguous
+ xns rout ?
+ ! output should be "default-gateway default-network"
+ ip default?
+ ! ambiguous
+ ip default ?
+
+ end
+ !
+ !
+ ! To test the hidden keyword ambiguity stuff
+ ! output should be "where"
+ disable
+ w?
+ ! should match "where"
+ w
+ ! this command should also work
+ who
+ !
+ ! output should be "snap"
+ enable
+ conf term
+ interface Ethernet 0
+ arp s?
+ ! should match "arp snap"
+ arp s
+ ! this command should also work
+ arp smds
+ !
+ ! broken
+ slip /compressed ?
+
+ *
+ *
+ *
+ ***************************************************************************
+ ***************************************************************************/
+
+ if (ap->ambig[0]) {
+ if (ap->ambig_save[0]) {
+ int i = strlen(ap->ambig_save);
+ boolean ambig_save_longer = FALSE;
+
+ if (strlen(ap->ambig) < i) {
+ ambig_save_longer = TRUE;
+ i = strlen(ap->ambig);
+ }
+
+ if (strncmp(ap->ambig, ap->ambig_save, i) != 0) {
+ if (parser_ambig_debug) {
+ printf("\nAmbig case 1");
+ }
+ /*
+ * If there is something in the ambig_save buffer
+ * and it is NOT the same as the ambig_save
+ * buffer, so the keyword is matches or and we
+ * increase multiple_funcs and copy the ambig
+ * buffer to ambig_save buffer.
+ */
+ increment_multiple_funcs(csb, "no_alt_action 2");
+
+ /* Copy everything */
+ strcpy(ap->ambig_save, ap->ambig);
+
+ /* Clear ambig */
+ ap->ambig[0] = '\0';
+
+ } else {
+ if (parser_ambig_debug) {
+ printf("\nAmbig case 2");
+ }
+ /*
+ * If there is something in the ambig buffer
+ * and it is the same as in the ambig_save buffer,
+ * then we have a duplicate keyword and everything
+ * is ok, but we need to copy the longer string to
+ * ambig_save.
+ */
+ if (!ambig_save_longer) {
+ strcpy(ap->ambig_save, ap->ambig);
+ }
+ }
+ } else {
+ if (parser_ambig_debug) {
+ printf("\nAmbig case 3");
+ }
+ /*
+ * We didn't match anything before, so this is
+ * the first match, and multiple_funcs has already
+ * been set.
+ */
+ if (csb->in_help) {
+ increment_multiple_funcs(csb, "no_alt_action 3");
+ }
+
+ /* Copy everything */
+ strcpy(ap->ambig_save, ap->ambig);
+
+ /* Clear ambig */
+ ap->ambig[0] = '\0';
+
+ }
+ } else {
+ if (parser_ambig_debug) {
+ printf("\nAmbig case 4");
+ }
+ /*
+ * If the ambig buffer is empty,
+ * then we are at the end of a parse chain,
+ * so clear the ambig_save buffer
+ */
+ ap->ambig_save[0] = '\0';
+ }
+ if (parser_ambig_debug) {
+ printf("\n2 Ambig buf '%s'", ap->ambig);
+ printf("\n2 Ambig_save buf '%s'", ap->ambig_save);
+ }
+ if ((parser_help_debug && csb->in_help) || parser_ambig_debug) {
+ print_multiple_funcs(csb);
+ printf("\nCurrent help string:\n");
+ print_buf(csb->help_save, TRUE, TRUE, 0, 0);
+ printf("\n");
+ }
+ /* Normal Error processing */
+ set_error_index(csb);
+}
+void func_action (parseinfo *csb, transition *mine, void (*func) (parseinfo *))
+{
+ INVALID_NVGEN_CHECK;
+
+ if (!csb->in_help && func) {
+ (void) func(csb);
+ }
+ push_node(csb, mine->accept);
+}
+/*
+ * NOP - Generally used as a label
+ *
+ * Differs from NONE action in that it takes it's accepting state.
+ */
+
+void NOP_action (parseinfo *csb, transition *mine)
+{
+ push_node(csb, mine->alternate);
+ push_node(csb, mine->accept);
+};
+
+ /*
+ * KEYWORD matches a unique substring of a specified string
+ *
+ * arg->minmatch is the minimum required number of matching characters
+ *
+ */
+void keyword_action (parseinfo *csb, transition *mine,
+ keyword_struct * const arg)
+{
+ general_keyword_struct argout = {
+ arg->str, arg->help, arg->priv, -1, 0, 0,
+ (KEYWORD_WS_OK | KEYWORD_HELP_CHECK)};
+ general_keyword_action(csb, mine, &argout);
+}
+
+void keyword_mm_action (parseinfo *csb, transition *mine,
+ keyword_mm_struct * const arg)
+{
+ general_keyword_struct argout = {
+ arg->str, arg->help, arg->priv, -1, 0, arg->minmatch,
+ (KEYWORD_WS_OK | KEYWORD_HELP_CHECK)};
+ general_keyword_action(csb, mine, &argout);
+}
+
+void keyword_id_action (parseinfo *csb, transition *mine,
+ keyword_id_struct * const arg)
+{
+ general_keyword_struct argout = {
+ arg->str, arg->help, arg->priv, arg->offset, arg->val, 0,
+ (KEYWORD_WS_OK | KEYWORD_HELP_CHECK)};
+ general_keyword_action(csb, mine, &argout);
+}
+
+void keyword_orset_action (parseinfo *csb, transition *mine,
+ keyword_id_struct * const arg)
+{
+ general_keyword_struct argout = {
+ arg->str, arg->help, arg->priv, arg->offset, arg->val, 0,
+ (KEYWORD_WS_OK | KEYWORD_HELP_CHECK | KEYWORD_OR_SET)};
+ general_keyword_action(csb, mine, &argout);
+}
+
+void keyword_optws_action (parseinfo *csb, transition *mine,
+ keyword_struct * const arg)
+{
+ general_keyword_struct argout = {
+ arg->str, arg->help, arg->priv, -1, 0, 0,
+ (KEYWORD_WS_OK | KEYWORD_NO_WS_OK | KEYWORD_HELP_CHECK)};
+ general_keyword_action(csb, mine, &argout);
+}
+
+
+void general_keyword_action (parseinfo *csb, transition *mine,
+ general_keyword_struct * const arg)
+{
+ int i = 0;
+ uint flags;
+
+
+ /* Setup to check the alternates. */
+ push_node(csb, mine->alternate);
+
+ if ((arg->flags & KEYWORD_TEST) &&
+ (arg->offset != -1)) {
+ if (arg->flags & KEYWORD_OR_SET) {
+ if (*CSBVAR(csb, arg->offset, uint) & arg->val) {
+ return;
+ }
+ } else {
+ if (*CSBVAR(csb, arg->offset, uint)) {
+ return;
+ }
+ }
+ }
+
+ /* Check for privilege to use this keyword */
+ if (priv_check(csb, arg->priv) == FALSE) {
+ return;
+ }
+
+ if (csb->nvgen) {
+ /*
+ * Doing NV generation. Save the transition struct and the keyword
+ * text for the NV generation function.
+ */
+
+ if (arg->offset != -1) {
+ if (arg->flags & KEYWORD_OR_SET) {
+ *CSBVAR(csb, arg->offset, uint) |= arg->val;
+ } else {
+ *CSBVAR(csb, arg->offset, uint) = arg->val;
+ }
+ }
+ if (!csb->priv_set || nvgen_privilege(csb, arg->priv, arg->str)) {
+ nvgen_token(csb, mine, arg->str);
+ } else {
+ printf("\n privilege check failed in keyword action");
+ }
+ return;
+ }
+
+ /* Make a copy of the flags word because it may originate in ROM
+ * and we may need to modify the flags before matching the keyword.
+ */
+ flags = arg->flags;
+ keyword_flag_modify(csb, arg->priv, &flags);
+
+ /*
+ * If we are at the end of the input stream and we're doing help, add the
+ * long help message, which is just the concatenation of the search string
+ * and the help text. We fall-through in any case. If long help is being
+ * requested, nothing matches and we return.
+ *
+ * Otherwise, we are expecting to process a token. If the token matching
+ * fails, due to an unexpected end of the input stream or due to a
+ * different command, we will fall through the test and transition to the
+ * alternates.
+ *
+ * The alternates are processed in any case so that we
+ * exhaustively check all possible commands against the input
+ * stream. See the parser README for more information on how the
+ * commands are uniquely matched.
+ */
+
+ /*
+ * Check to see if the input matches this token. If there is no match,
+ * we skip processing this token and try the alternates.
+ */
+
+ i = 0;
+ if (match_partial_keyword(csb, arg->str, &i, arg->help,
+ arg->minmatch, flags, arg->priv->cur_priv)) {
+ csb->line_index += i;
+
+ if (csb->priv_set) {
+ /*
+ * Modify the current keyword privilege
+ */
+ priv_push(csb, arg->priv);
+ }
+ csb->last_priv = arg->priv->cur_priv;
+ if (csb->last_priv > csb->highest_priv) {
+ csb->highest_priv = csb->last_priv;
+ }
+ if (arg->offset != -1) {
+ if (arg->flags & KEYWORD_OR_SET) {
+ *CSBVAR(csb, arg->offset, uint) |= arg->val;
+ } else {
+ *CSBVAR(csb, arg->offset, uint) = arg->val;
+ }
+ }
+#ifdef DEBUG_KEYWORD
+ printf("\nkeyword_action: Pushing accept");
+#endif DEBUG_KEYWORD
+ push_node(csb, mine->accept);
+ csb->line_index -= i;
+ } else {
+ if (parser_ambig_debug && i) {
+ printf("\nDidn't match keyword '%s'", arg->str);
+ }
+#ifdef DEBUG_KEYWORD
+ printf("\nkeyword_action: match_partial_keyword returned FALSE");
+#endif DEBUG_KEYWORD
+ }
+}
+
+/* EOL prints help and does func call at EOL
+ *
+ * A push-down stack of parseinfo structures is used to save the state of
+ * the current parse. A new parseinfo struct is used for each possible
+ * command so that successive partial matching commands do not overwrite
+ * data stored in the parseinfo struct of a fully matching command.
+ */
+
+void eol_action (parseinfo *csb, transition *mine, void (*func) (parseinfo *))
+{
+ parseinfo *savepd;
+ char *short_help = "<cr>";
+
+ if (parser_ambig_debug && !csb->nvgen) {
+ printf("\nEol Action");
+ }
+ /*
+ * If setting a command's privileges, indicate that the command was
+ * successful and return.
+
+ if (csb->priv_set) {
+ increment_multiple_funcs(csb, "eol_action 1");
+ return;
+ }*/
+ if (csb->nvgen) {
+ if (func) {
+ (void) func(csb);
+ }
+ } else {
+ if (csb->in_help) {
+ if (help_check(csb)) {
+ if (csb->flags & CONFIG_HTTP) {
+ save_help_long(csb, "CR", NULL, csb->priv);
+ } else {
+ save_help_long(csb, short_help, NULL, csb->priv);
+ }
+ save_ambig_string_flag(csb, short_help, short_help, FALSE);
+ no_alt_action(csb);
+ }
+ return;
+ }
+ if (eol_check(csb)) {
+
+ increment_multiple_funcs(csb, "eol_action 2");
+
+ /* savepd = chunk_malloc(parseinfo_chunks); */
+ savepd = ( parseinfo *)PARSERmalloc(sizeof(parseinfo) );
+ if (savepd == NULL) {
+ parser_bail_out(csb, func, "eol_action");
+ return;
+ }
+
+ /*
+ * Make a copy of the current parse data (savepd) before
+ * modifying current info. This implements a push-down
+ * stack where the top of the stack is the current
+ * (possibly invalid) parse state. Any elements below the
+ * top are parse data from matching commands. Only one
+ * element should be on the stack if a command matches the
+ * input.
+ */
+
+ save_ambig_string_flag(csb, short_help, short_help, FALSE);
+
+ *savepd = *csb; /* Struct copy */
+
+ csb->next = savepd;
+ savepd->action_func = func;
+ } else {
+
+ /*
+ * This command did not accept. Remove it from the linked list of
+ * accepting command states. Don't discard the current error_index
+ * since it indicates that we came this far in the input before
+ * failing.
+ */
+ set_error_index(csb);
+ }
+ no_alt_action(csb);
+ } /* if (csb->nvgen) */
+}
+
+/* EOLS - prints help and does func call at EOL. Sets csb->which with
+ * the EVAL macro so that 'val' is not constrained to be a constant.
+ */
+
+void eols_action (parseinfo *csb, transition *mine,
+ eols_struct * const arg)
+{
+ csb->which = arg->subfunc;
+ eol_action(csb, mine, arg->func);
+}
+
+void eolns_action (parseinfo *csb, transition *mine, void (*func) (parseinfo *))
+{
+ csb->which = 0;
+ eol_action(csb, mine, func);
+}
+
+/*
+ * EOLI - EOL for interactive command. Sets TERMINAL_MODE flag
+ * that gets saved if this command match succeeds.
+ */
+void eoli_action (parseinfo *csb, transition *mine,
+ eols_struct * const arg)
+{
+ csb->flags |= TERMINAL_MODE;
+ csb->which = arg->subfunc;
+ eol_action(csb, mine, arg->func);
+
+ /*
+ * Clear TERMINAL_MODE so the next command doesn't
+ * get it by mistake.
+ */
+ csb->flags &= ~TERMINAL_MODE;
+}
+
+void general_number_short_help_http (uint *flags, uint lower, uint upper,
+ char *help, boolean doing_http)
+{
+ char *open_bracket = "<";
+ char *close_bracket = ">";
+
+ if (doing_http) {
+ open_bracket = close_bracket = "";
+ }
+
+ switch (*flags & (NUMBER_HEX|NUMBER_OCT|NUMBER_DEC)) {
+ default:
+ case 0:
+ printf("general_number_short_help_http: NUMHELP\n");
+ *flags |= (NUMBER_HEX|NUMBER_OCT|NUMBER_DEC);
+ case NUMBER_HEX | NUMBER_OCT | NUMBER_DEC:
+ case NUMBER_HEX | NUMBER_OCT:
+ case NUMBER_HEX | NUMBER_DEC:
+ case NUMBER_OCT | NUMBER_DEC:
+ case NUMBER_DEC:
+ sprintf(help, "%s%u-%u%s", open_bracket, lower, upper, close_bracket);
+ break;
+
+ case NUMBER_HEX:
+ switch (*flags & (HEX_ZEROX_OK|HEX_NO_ZEROX_OK)) {
+ default:
+ case 0:
+ /* errmsg(&msgsym(NUMHELP, PARSER), "hex"); */
+ printf("NUMBER_HEX : Error !\n");
+ *flags |= HEX_ZEROX_OK;
+ case HEX_ZEROX_OK:
+ case HEX_ZEROX_OK | HEX_NO_ZEROX_OK: /* why not just put this case here */
+ sprintf(help, "%s0x%x-0x%x%s",
+ open_bracket, lower, upper, close_bracket);
+ break;
+ case HEX_NO_ZEROX_OK:
+ sprintf(help, "%s%x-%x%s", open_bracket,
+ lower, upper, close_bracket);
+ break;
+ }
+ break;
+
+ case NUMBER_OCT:
+ switch (*flags & (OCT_ZERO_OK|OCT_NO_ZERO_OK)) {
+ default:
+ case 0:
+ /* errmsg(&msgsym(NUMHELP, PARSER), "octal");*/
+ printf("NUMBER_OCT : Error!\n");
+ *flags |= OCT_ZERO_OK;
+ case OCT_ZERO_OK:
+ case OCT_ZERO_OK | OCT_NO_ZERO_OK: /* why not just put this case here */
+ sprintf(help, "%s0%o-0%o%s", open_bracket,
+ lower, upper, close_bracket);
+ break;
+ case OCT_NO_ZERO_OK:
+ sprintf(help, "%s%o-%o%s", open_bracket, lower, upper,
+ close_bracket);
+ break;
+ }
+ break;
+ }
+}
+
+/*
+ * GENERAL_NUMBER matches a ranged, unsigned number, minimum one digit, and
+ * assigns it to a int. It also handles help and whitespace. If the
+ * input begins with '0x' and contains at least one hex digit, the
+ * conversion is from Hex. If the leading digit is '0', and the
+ * number is considered octal. The <types> field of the number_struct
+ * is a flag variable
+ * indicating what types of input (hex, octal, decimal) are allowed.
+ *
+ * The following function takes additional structure arguments that
+ * allow whitespace and help checking to be turned off.
+ */
+
+/* Scan a number and accept. Types of numbers (hex, decimal, octal) and
+ * allowable range are specified via <*arg>. <*arg> also specifies via
+ * another field whether whitespace after is to be tested for (required)
+ * or not. Yet another field specifies whether help checks are to be
+ * done.
+ */
+
+void general_number_action (parseinfo *csb, transition *mine,
+ number_struct * const arg)
+{
+ int i = 0;
+ uint num = 0;
+ char short_help[11];
+ uint lower;
+ uint upper;
+
+ push_node(csb, mine->alternate);
+
+ CHECK_RANGE_BOUNDS();
+
+ if ((arg->flags & NUMBER_NV_RANGE) && csb->nvgen) {
+ queuetype *t1 = csb->tokenQ;
+ queuetype t2;
+ uint l = strlen(csb->nv_command);
+
+ for (i=lower; i<= upper; i++) {
+ *CSBVAR(csb, arg->offset, uint) = i;
+ sprintf(short_help, "%d", i);
+
+ csb->nv_command[l] = '\0';
+ csb->tokenQ = &t2;
+ queue_init(csb->tokenQ, 0);
+ nvgen_token(csb, mine, short_help);
+ parse_token(csb);
+ csb->tokenQ = t1;
+ }
+ return;
+ }
+
+ /*
+ * We should never be called for NV generation
+ */
+ INVALID_NVGEN_CHECK;
+
+ /* match the number */
+ if (match_number(csb, lower, upper, &i, &num, arg->flags, arg->help)) {
+#ifdef DEBUG_NUMBER
+ printf("\ngeneral_number_action: matched number %d", num);
+#endif DEBUG_NUMBER
+
+ *CSBVAR(csb, arg->offset, uint) = num;
+
+ csb->line_index += i;
+ push_node(csb, mine->accept);
+ csb->line_index -= i;
+
+ }
+}
+
+void signed_number_action (parseinfo *csb, transition *mine,
+ signed_number_struct * const arg)
+{
+ int i = 0;
+ int num = 0;
+ char short_help[32];
+ int lower;
+ int upper;
+
+ push_node(csb, mine->alternate);
+ /*
+ * We should never be called for NV generation
+ */
+ INVALID_NVGEN_CHECK;
+
+ CHECK_RANGE_BOUNDS();
+
+ sprintf(short_help,"<%d - %d>", lower, upper);
+
+ if (help_check(csb)) {
+ save_help_long(csb, short_help, arg->help, csb->priv);
+ return;
+ }
+
+ /* match the number */
+ i = 0;
+ if (match_signed_dec(&csb->line[csb->line_index],
+ lower, upper, &i, &num) &&
+ match_whitespace2(&csb->line[csb->line_index], &i, csb->in_help)) {
+
+ *CSBVAR(csb, arg->offset, int) = num;
+
+ save_ambig_int(csb, short_help, num);
+
+ csb->line_index += i;
+ push_node(csb, mine->accept);
+ csb->line_index -= i;
+ } else {
+ help_or_error(csb, i, short_help, NO_COMMAND_COMPLETION);
+ }
+}
+
+/*
+ * HELP
+ */
+
+void help_action (parseinfo *csb, transition *mine,
+ help_struct * const arg)
+{
+ /*
+ * If doing NV generation, go to alternate (skip help output). If we're not
+ * in help mode, then obviously skip to alternate. If not at the end of
+ * line, we're not doing help, so go to alternate. Otherwise, this is a
+ * valid help request and we add the current text to the help output
+ * buffer. But the text is only added if it exists. Transition to
+ * alternate when the help string is saved to allow other tokens at this
+ * level to generate help output.
+ */
+
+ if (help_check(csb)) {
+ if (csb->flags & CONFIG_HTTP) {
+ save_line(csb, &csb->help_save, "<DT>%s", arg->str);
+ } else {
+ save_help_msg(csb, arg->str);
+ }
+ }
+ push_node(csb, mine->alternate);
+}
+
+
+
+
+/* SET takes a pointer to a variable and a constant expression to set
+ * that variable to. It is considerably more efficient than EVAL.
+ *
+ * Likewise, TESTVAR tests a variable for its relation with a constant
+ * expression. It, in turn, is more efficient than ASSERT.
+ */
+
+void set_action (parseinfo *csb, transition *mine,
+ set_struct * const arg)
+{
+ *CSBVAR(csb, arg->offset, uint) = arg->val;
+ push_node(csb, mine->accept);
+}
+
+/* Use a temporary variable in case the variable changes during the
+ * parse (such as checking csb->multiple_funcs when searching for help
+ * strings).
+ */
+void test_action (parseinfo *csb, transition *mine,
+ test_struct * const arg)
+{
+ uint tmp = *CSBVAR(csb, arg->offset, uint);
+
+ push_node(csb, mine->alternate);
+ if (tmp == arg->val)
+ push_node(csb, arg->equal);
+ if (tmp != arg->val)
+ push_node(csb, arg->notequal);
+ if (tmp < arg->val)
+ push_node(csb, arg->lt);
+ if (tmp > arg->val)
+ push_node(csb, arg->gt);
+}
+
+void general_string_action (parseinfo *csb, transition *mine,
+ general_string_struct * const arg)
+{
+ int i;
+ boolean ws;
+ const char *short_help = (arg->flags & STRING_WS_OK) ?
+ "LINE" : "WORD";
+
+ push_node(csb, mine->alternate);
+ INVALID_NVGEN_CHECK;
+
+ if (help_check(csb)) {
+ if (arg->flags & STRING_HELP_CHECK) {
+ save_help_long(csb, short_help, arg->help, csb->priv);
+ }
+ return;
+ }
+
+ i = copy_varstring(csb->line + csb->line_index,
+ CSBVAR(csb, arg->offset, char),
+ PARSEBUF, arg->flags);
+
+ if (i) {
+ ws = match_whitespace2(csb->line + csb->line_index, &i, csb->in_help);
+ if (ws || (csb->flags & CONFIG_HTTP) || (arg->flags & STRING_WS_OK)) {
+ save_ambig_string(csb, short_help, CSBVAR(csb, arg->offset, char));
+ csb->line_index += i;
+ push_node(csb, mine->accept);
+ csb->line_index -= i;
+ }
+
+ if (!ws || (arg->flags & STRING_WS_OK)) {
+ if (arg->flags & STRING_HELP_CHECK) {
+ help_or_error(csb, i, short_help, NO_COMMAND_COMPLETION);
+ } else {
+ csb->line_index += i;
+ set_error_index(csb);
+ csb->line_index -= i;
+ }
+ }
+ }
+}
+
+/*
+ * NVGEN - nvgen_action
+ *
+ * Call the NV generation function.
+ */
+void nvgen_action (parseinfo *csb, transition *mine, void (*func)(parseinfo *))
+{
+
+ if (csb->nvgen) {
+ /*
+ * If csb->priv_set is set, we currently don't go farther than
+ * we can NV generate, so stop here!
+ */
+
+ if (csb->sense && func) {
+ (void) func(csb);
+ }
+ } else {
+ push_node(csb, mine->accept);
+ }
+}
+
+/*
+ * NVGENS - nvgens_action
+ *
+ *
+ */
+void nvgens_action (parseinfo *csb, transition *mine,
+ nvgens_struct * const arg)
+{
+ csb->which = arg->subfunc;
+ nvgen_action(csb, mine, arg->func);
+}
+
+void nvgenns_action (parseinfo *csb, transition *mine, void (*func)(parseinfo *))
+{
+ csb->which = 0;
+ nvgen_action(csb, mine, func);
+}
+
+/*
+ * nvgen_token
+ *
+ * Find the end of the existing command and a space if this isn't the
+ * first token in the command. Then
+ * add the token to the command line. Continue the generation by
+ * transitioning to the accepting node.
+ * When we return, reset the command line to its state before this token
+ * was added and transition to the alternate node.
+ */
+void nvgen_token (parseinfo *csb, transition *mine, const char *token)
+{
+ char *cp;
+
+ if (!csb->nvgen) {
+ /* errmsg(&msgsym(NVGEN, PARSER) */
+ printf("nvgen_token : NVGEN\n");
+ return;
+ }
+
+ /*
+ * The alternate transition should have already been pushed onto the stack
+ * before calling nvgen_token.
+ */
+ for (cp = csb->nv_command; *cp; cp++); /* Null body */
+
+ /* Add the current token and go to the accepting node */
+ if (cp != csb->nv_command) {
+ *cp = ' '; /* Add a space unless at beginning */
+ strcpy(cp+1, token);
+ } else {
+ strcpy(cp, token);
+ }
+ push_node(csb, mine->accept);
+ *cp = '\0'; /* Restore prior state */
+ return;
+}
+
+/* NOPREFIX
+ * Go to 'accept' if there isn't a 'no' prefix.
+ * Consume the remainder of the input and go to 'alternate' if there
+ * was a 'no' prefix.
+ */
+
+void noprefix_action (parseinfo *csb, transition *mine)
+{
+ int i;
+
+ if (csb->nvgen) {
+ push_node(csb, mine->accept);
+ return;
+ }
+
+ if ((csb->sense == TRUE) && (csb->set_to_default == FALSE)) {
+ push_node(csb, mine->accept);
+ } else {
+ for (i = 0; csb->line[csb->line_index + i] != '\n' &&
+ csb->line[csb->line_index + i]; i++) {
+ }
+ csb->line_index += i;
+ push_node(csb, mine->alternate);
+ csb->line_index -= i;
+ }
+}
+
+/*
+ * Match a decimal short unsigned int in a range
+ */
+boolean match_decimal (char *buf, uint low, uint high, int *pi, ushort *pvalue)
+{
+ ushort value = 0;
+ uint i;
+
+ buf += *pi;
+ *pvalue = 0;
+
+ i = 0;
+ if (buf[i] == '+')
+ i++;
+
+ for (; isdigit(buf[i]); i++) {
+ if ((value > USHRT_MAX / 10) ||
+ ((value == USHRT_MAX / 10) &&
+ ((buf[i] - '0') > USHRT_MAX % 10))) {
+ *pi += i;
+ return(FALSE);
+ }
+ value = 10 * value + buf[i] - '0';
+ if (value > high) {
+ *pi += i;
+ return(FALSE);
+ }
+ }
+
+ if (i && (value >= low)) {
+ *pi += i;
+ *pvalue = value;
+ return(TRUE);
+ }
+ return(FALSE);
+}
+
+/*
+ * Try to match an signed int,
+ * with value between (or equal to) <low> and
+ * <high>. <*pi> is incremented by the number of characters in
+ * the match.
+ *
+ * Here's a command to test this function with
+ int e0
+ ip irdp
+ ip irdp address 1.1.1.1 -2147483649 ! fail
+ ip irdp address 1.1.1.2 -2147483648 ! succeed
+ ip irdp address 1.1.1.3 -1 ! succeed
+ ip irdp address 1.1.1.4 -0 ! succeed
+ ip irdp address 1.1.1.5 - ! fail
+ ip irdp address 1.1.1.6 ! fail
+ ip irdp address 1.1.1.7 0 ! succeed
+ ip irdp address 1.1.1.8 1 ! succeed
+ ip irdp address 1.1.1.9 2147483647 ! succeed
+ ip irdp address 1.1.1.10 2147483648 ! fail
+ */
+static boolean match_signed_dec (char *buf, int low, int high,
+ int *pi, int *pvalue)
+{
+ int i;
+ int value = 0;
+ char c;
+ int sign;
+
+ buf += *pi;
+ *pvalue = 0;
+
+ i = 0;
+ if (buf[i] == '-') {
+ sign = -1;
+ i++;
+ } else {
+ sign = 1;
+ }
+ if (buf[i] == '+')
+ i++;
+
+ for (c = buf[i]; isdigit(c); c = buf[++i]) {
+ if (((value*10 + (c - '0')) < value) &&
+ ((sign != -1) || ((value*10 + (int)(c - '0')) != 1<<31))) {
+ /* Too many chars, max out. */
+ *pi += i;
+ return(FALSE);
+ }
+ value = value * 10 + (int) (c - '0');
+ if ((value*sign) > high) {
+ *pi += i;
+ return(FALSE);
+ }
+ }
+
+ *pi += i;
+ /*
+ * if (number is positive and we parsed one or more numbers) or
+ * (number is negative and we parsed '-' plus one or more numbers)
+ */
+ if (((sign == 1) && (i > 0)) ||
+ ((sign == -1) && (i > 1))) {
+
+ /*
+ * if (number is greater than or equal to the lower boundary)
+ */
+ if ((value*sign) >= low) {
+ *pvalue = value*sign;
+ return(TRUE);
+ }
+ }
+ return(FALSE);
+}
+
+
+/* ------------------------------------------------------------ */
+
+boolean match_partial_keyword (parseinfo *csb, const char *keyword,
+ int *pi, const char *help,
+ int minmatch, uint flags, uint priv)
+{
+ int i;
+ char *buf = csb->line + csb->line_index + *pi;
+ int old_line_index = 0;
+ char *bufptr = NULL;
+
+ if ( ( bufptr = strchr(buf, ' ') ) == NULL )
+ old_line_index = strlen(buf) - 1;
+ else
+ old_line_index = ( bufptr - buf ) - 1;
+
+#ifdef DEBUG_KEYWORD
+ printf("\nmatch_partial_keyword: Entering");
+#endif DEBUG_KEYWORD
+ csb->line_index += *pi;
+ if (long_help_check(csb)) {
+ if (flags & KEYWORD_HELP_CHECK) {
+ save_help_long(csb, keyword, help, priv);
+ }
+#ifdef DEBUG_KEYWORD
+ printf("\nmatch_partial_keyword: Long help");
+#endif DEBUG_KEYWORD
+ csb->line_index -= *pi;
+ return(FALSE);
+ }
+ csb->line_index -= *pi;
+
+ for (i = 0; (toupper(buf[i]) == toupper(keyword[i])) && buf[i]; i++) {
+ ; /* Null body */
+ }
+ (*pi) += i;
+#ifdef DEBUG_KEYWORD
+ printf("\nmatch_partial_keyword: Matched %d letters of keyword %s", i, keyword);
+#endif DEBUG_KEYWORD
+ if (i > 0) {
+ if ((!minmatch || (i >= minmatch)) &&
+ (((flags & KEYWORD_WS_OK) &&
+ match_whitespace2(csb->line + csb->line_index, pi, csb->in_help))
+ || (flags & KEYWORD_NO_WS_OK && old_line_index <= i))) {
+
+#ifdef DEBUG_KEYWORD
+ printf("\nmatch_partial_keyword: Matched whitespace");
+#endif DEBUG_KEYWORD
+ csb->line_index += *pi;
+ if ((flags & KEYWORD_NO_WS_OK) && (short_help_check(csb))) {
+ if (flags & KEYWORD_HELP_CHECK) {
+ save_help_short(csb, keyword, SUPPORT_COMMAND_COMPLETION);
+ }
+ csb->line_index -= *pi;
+ return(FALSE);
+ }
+ if (parser_ambig_debug) {
+ printf("\nMatched keyword '%s'", keyword);
+ printf("\ncsb->command_visible = %d", csb->command_visible);
+ }
+ save_ambig_string(csb, keyword, keyword);
+ csb->line_index -= *pi;
+ csb->flags |= KEYWORD_MATCHED;
+ return(TRUE);
+
+ } else {
+#ifdef DEBUG_KEYWORD
+ printf("\nmatch_partial_keyword: Didn't match whitespace");
+#endif DEBUG_KEYWORD
+ if ((flags & KEYWORD_HELP_CHECK) && (flags & KEYWORD_WS_OK)) {
+ help_or_error(csb, *pi, keyword, SUPPORT_COMMAND_COMPLETION);
+ } else {
+ csb->line_index += *pi;
+ set_error_index(csb);
+ csb->line_index -= *pi;
+ }
+ }
+ } else {
+ /* didn't match any characters, set error index */
+ csb->line_index += *pi;
+ set_error_index(csb);
+ csb->line_index -= *pi;
+ }
+ return(FALSE);
+}
+
+static void string_escape (char **from, char **to, uint *i)
+{
+ uint count;
+ uint value;
+ char *pfrom = *from;
+ uint pi = *i;
+
+ switch (**from) {
+ default:
+ /* Put back backslash */
+ **to = '\\';
+ (*to)++;
+ if (!*from) {
+ break;
+ }
+ /* Fall through */
+ case '"':
+ **to = **from;
+ (*to)++;
+ (*from)++;
+ (*i)++;
+ break;
+ case 'x':
+ pfrom++;
+ pi++;
+ count = 0;
+ value = 0;
+ while ((count < 2) && *pfrom && isxdigit(*pfrom)) {
+ value = (value*16) + CVHTOB(*pfrom);
+ pfrom++;
+ pi++;
+ count++;
+ }
+ if (count != 2) {
+ **to = '\\';
+ (*to)++;
+ **to = **from;
+ (*from)++;
+ (*i)++;
+ } else {
+ **to = value;
+ *from = pfrom;
+ *i = pi;
+ }
+ (*to)++;
+ break;
+ case '0': case '1': case '2': case '3':
+ case '4': case '5': case '6': case '7':
+ value = 0;
+ count = 0;
+ while ((count < 3) && *pfrom &&
+ (*pfrom >= '0') && (*pfrom <= '7')) {
+ value = (value*8) + (*pfrom - '0');
+ pfrom++;
+ pi++;
+ count++;
+ }
+ if (count != 3) {
+ **to = '\\';
+ (*to)++;
+ **to = **from;
+ (*from)++;
+ (*i)++;
+ } else {
+ **to = value;
+ *from = pfrom;
+ *i = pi;
+ }
+ (*to)++;
+ break;
+ }
+}
+/*
+ * Copies at most <maxchar-1> non-whitespace characters from input buffer
+ * to output buffer. Returns string length. If the string is quoted,
+ * then it may contain any character, including whitespace.
+ */
+uint copy_varstring (char *from, char *to, uint maxchar, uint flags)
+{
+ uint i; /* The number of characters matched */
+
+ if ((*from == '"') &&
+ (flags & STRING_QUOTED) &&
+ (!(flags & STRING_WS_OK))) {
+
+ /* Quoted string */
+ from++;
+ for (i = 1; i < maxchar; i++) {
+ if (*from == '\0') {
+ printf("\nWarning: Assumed end-quote for quoted string");
+ break;
+ }
+ /* If we find a quote, it must be backslash escaped to be kept.
+ * Terminate the string otherwise.
+ */
+ if (*from == '"') {
+ i++; /* advance past trailing quote */
+ i = min(i, (maxchar - 1));
+ *to = '\0';
+ return(i);
+ }
+ if (*from == '\\') {
+ from++;
+ string_escape(&from, &to, &i);
+ } else {
+ *to++ = *from++;
+ }
+ }
+ } else {
+ /* Just get the next token */
+ for (i = 0; (i < maxchar) && *from; i++) {
+ if (*from == '\\') {
+ from++;
+ string_escape(&from, &to, &i);
+ } else {
+ if (!(flags & STRING_WS_OK) && isspace(*from)) {
+ break;
+ }
+ *to++ = *from++;
+ }
+ }
+ }
+
+ i = min(i, (maxchar - 1));
+ *to = '\0';
+
+ return(i);
+}
+
+void help_or_error (parseinfo *csb, int count, const char *msg,
+ boolean do_command_completion)
+{
+ csb->line_index += count;
+ if (help_check(csb)) {
+ save_help_short(csb, msg, do_command_completion);
+ } else {
+ /* Not doing help. This is an error. */
+ set_error_index(csb);
+ }
+ csb->line_index -= count;
+}
+
+static void set_error_index (parseinfo *csb)
+{
+ if (csb->error_index < csb->line_index) {
+ csb->error_index = csb->line_index;
+ }
+}
+
+static void match_number_hex (char *buf, uint low, uint high,
+ int *pi, uint *pvalue, uint *flags)
+{
+ char c;
+ int i = 0;
+ uint ret = 0;
+
+ buf += *pi;
+ *pvalue = 0;
+ *flags &= ~NUMBER_HEX;
+
+#ifdef DEBUG_NUMBER
+ printf("\nmatch_number_hex: Entering");
+ printf("\nmatch_number_hex: buf = '%s'", buf);
+#endif DEBUG_NUMBER
+ if ((buf[0] == '0') && (toupper(buf[1]) == 'X')) {
+ if (*flags & HEX_ZEROX_OK) {
+ /* saw '0x' and it is ok */
+ i += 2;
+#ifdef DEBUG_NUMBER
+ printf("\nmatch_number_hex: matched '0x'");
+#endif DEBUG_NUMBER
+ ret = HEX_ZEROX_MATCHED;
+ } else {
+ /* saw '0x' and it is not ok, return false */
+#ifdef DEBUG_NUMBER
+ printf("\nmatch_number_hex: matched '0x' and not ok");
+#endif DEBUG_NUMBER
+ return;
+ }
+ } else {
+ if (*flags & HEX_NO_ZEROX_OK) {
+ /* didn't see '0x' and that is ok */
+#ifdef DEBUG_NUMBER
+ printf("\nmatch_number_hex: didn't match '0x'");
+#endif DEBUG_NUMBER
+ ret = HEX_ZEROX_NOT_MATCHED;
+ } else {
+ /* didn't see '0x' and it is not ok, return false */
+#ifdef DEBUG_NUMBER
+ printf("\nmatch_number_hex: didn't match '0x' and not ok");
+#endif DEBUG_NUMBER
+ return;
+ }
+ }
+
+#ifdef DEBUG_NUMBER
+ printf("\nmatch_number_hex: trying char '%c'", buf[i]);
+#endif DEBUG_NUMBER
+ /* i has already been initialized */
+ for (c = toupper(buf[i]); isxdigit(c); i++, c = toupper(buf[i])) {
+ if (*pvalue > ULONG_MAX / 16) {
+ /* Too many non-zero digits, max out. */
+#ifdef DEBUG_NUMBER
+ printf("\nmatch_number_hex: too many chars %d", i);
+#endif DEBUG_NUMBER
+ *pi += i;
+ return;
+ }
+ *pvalue = *pvalue * 16 + CVHTOB(c);
+ if (*pvalue > high) {
+#ifdef DEBUG_NUMBER
+ printf("\nmatch_number_hex: value > high i = %d", i);
+#endif DEBUG_NUMBER
+ *pi += i;
+ return;
+ }
+#ifdef DEBUG_NUMBER
+ printf("\nmatch_number_hex: trying char '%c'", buf[i+1]);
+#endif DEBUG_NUMBER
+ }
+
+ if (i && (*pvalue >= low)) {
+ *pi += i;
+ *flags |= ret;
+ *flags |= NUMBER_HEX;
+#ifdef DEBUG_NUMBER
+ printf("\nmatch_number_hex: matched number 0x%x", *pvalue);
+#endif DEBUG_NUMBER
+ return;
+ }
+#ifdef DEBUG_NUMBER
+ if (!i) {
+ printf("\nmatch_number_hex: matched 0 numbers");
+ } else {
+ printf("\nmatch_number_hex: value < low");
+ }
+#endif DEBUG_NUMBER
+ return;
+}
+
+static void match_number_oct (char *buf, uint low, uint high,
+ int *pi, uint *pvalue, uint *flags)
+{
+ int i = 0;
+ uint ret = 0;
+
+ buf += *pi;
+ *pvalue = 0;
+ *flags &= ~NUMBER_OCT;
+
+#ifdef DEBUG_NUMBER
+ printf("\nmatch_number_oct: Entering");
+ printf("\nmatch_number_oct: buf = '%s'", buf);
+#endif DEBUG_NUMBER
+ if (buf[0] == '0') {
+ if (*flags & OCT_ZERO_OK) {
+#ifdef DEBUG_NUMBER
+ printf("\nmatch_number_oct: matched '0'");
+#endif DEBUG_NUMBER
+ ret = OCT_ZERO_MATCHED;
+ } else {
+#ifdef DEBUG_NUMBER
+ printf("\nmatch_number_oct: matched '0' and not ok");
+#endif DEBUG_NUMBER
+ return;
+ }
+ } else {
+ if (*flags & OCT_NO_ZERO_OK) {
+#ifdef DEBUG_NUMBER
+ printf("\nmatch_number_oct: didn't match '0'");
+#endif DEBUG_NUMBER
+ ret = OCT_ZERO_NOT_MATCHED;
+ } else {
+#ifdef DEBUG_NUMBER
+ printf("\nmatch_number_oct: didn't match '0' and not ok");
+#endif DEBUG_NUMBER
+ return;
+ }
+ }
+
+#ifdef DEBUG_NUMBER
+ printf("\nmatch_number_oct: trying char '%c'", buf[i]);
+#endif DEBUG_NUMBER
+ for (i=0; isodigit(buf[i]); i++) {
+ /* Make sure we don't have a 33-rd bit */
+ if (*pvalue > ULONG_MAX / 8) {
+ *pi += i;
+#ifdef DEBUG_NUMBER
+ printf("\nmatch_number_oct: too many chars %d", i);
+#endif DEBUG_NUMBER
+ return;
+ }
+ *pvalue = 8 * *pvalue + buf[i] - '0';
+ if (*pvalue > high) {
+ *pi += i;
+#ifdef DEBUG_NUMBER
+ printf("\nmatch_number_oct: value > high i = %d", i);
+#endif DEBUG_NUMBER
+ return;
+ }
+#ifdef DEBUG_NUMBER
+ printf("\nmatch_number_oct: trying char '%c'", buf[i+1]);
+#endif DEBUG_NUMBER
+ }
+ if (i && (*pvalue >= low)) {
+ *pi += i;
+ *flags |= ret;
+ *flags |= NUMBER_OCT;
+#ifdef DEBUG_NUMBER
+ printf("\nmatch_number_oct: matched num 0%o", *pvalue);
+#endif DEBUG_NUMBER
+ return;
+ }
+#ifdef DEBUG_NUMBER
+ if (!i) {
+ printf("\nmatch_number_oct: matched 0 numbers");
+ } else {
+ printf("\nmatch_number_oct: value < low");
+ }
+#endif DEBUG_NUMBER
+ return;
+}
+
+static void match_number_dec (char *buf, uint low, uint high,
+ int *pi, uint *pvalue, uint *flags)
+{
+ int i = 0;
+
+ buf += *pi;
+ *pvalue = 0;
+ *flags &= ~NUMBER_DEC;
+
+#ifdef DEBUG_NUMBER
+ printf("\nmatch_number_dec: Entering");
+ printf("\nmatch_number_dec: buf = '%s'", buf);
+ printf("\nmatch_number_dec: trying char '%c'", buf[i]);
+#endif DEBUG_NUMBER
+ for (i=0; isdigit(buf[i]); i++) {
+ if ((*pvalue > ULONG_MAX / 10) ||
+ ((*pvalue == ULONG_MAX / 10) && ((buf[i] - '0') > ULONG_MAX % 10))) {
+ /* Too many chars, max out. */
+ *pi += i;
+#ifdef DEBUG_NUMBER
+ printf("\nmatch_number_dec: too many chars %d", i);
+#endif DEBUG_NUMBER
+ return;
+ }
+ *pvalue = *pvalue * 10 + (uint) (buf[i] - '0');
+ if (*pvalue > high) {
+ *pi += i;
+#ifdef DEBUG_NUMBER
+ printf("\nmatch_number_dec: value > high i = %d", i);
+#endif DEBUG_NUMBER
+ return;
+ }
+#ifdef DEBUG_NUMBER
+ printf("\nmatch_number_dec: trying char '%c'", buf[i+1]);
+#endif DEBUG_NUMBER
+ }
+
+ if (i && (*pvalue >= low)) {
+ *pi += i;
+ *flags |= NUMBER_DEC;
+#ifdef DEBUG_NUMBER
+ printf("\nmatch_number_dec: matched number '%d", *pvalue);
+#endif DEBUG_NUMBER
+ return;
+ }
+#ifdef DEBUG_NUMBER
+ if (!i) {
+ printf("\nmatch_number_dec: matched 0 numbers");
+ } else {
+ printf("\nmatch_number_dec: value < low");
+ }
+#endif DEBUG_NUMBER
+ return;
+}
+
+boolean match_number (parseinfo *csb, uint low, uint high, int *pi,
+ uint *pvalue, uint flags, const char *long_help)
+{
+ char *buf;
+ uint hex_num, oct_num, dec_num;
+ int hex_pi, oct_pi, dec_pi;
+ char short_help[SHORTHELP_LEN];
+ boolean matched;
+
+ buf = csb->line + csb->line_index;
+
+ /*
+ * Construct short help message, in case we need it
+ */
+ general_number_short_help_http(&flags, low, high, short_help,
+ (csb->flags & CONFIG_HTTP));
+
+ /* Do initial, long help check */
+ csb->line_index += *pi; /* Needed for help_check */
+ if ((flags & NUMBER_HELP_CHECK) && help_check(csb)) {
+
+ save_help_long(csb, short_help, long_help, csb->priv);
+ csb->line_index -= *pi;
+ return(FALSE);
+ }
+ csb->line_index -= *pi;
+
+ hex_pi = oct_pi = dec_pi = *pi;
+
+#ifdef DEBUG_NUMBER
+ printf("\nmatch_number: entering");
+ printf("\nmatch_number: buf = '%s'", buf);
+ printf("\nmatch_number: buf = 0x%x pi = %d buf[0] = '%c'", buf, *pi, buf[0]);
+#endif DEBUG_NUMBER
+ if (flags & NUMBER_HEX) {
+ match_number_hex(buf, low, high, &hex_pi, &hex_num, &flags);
+ }
+ if (flags & NUMBER_OCT) {
+ match_number_oct(buf, low, high, &oct_pi, &oct_num, &flags);
+ }
+ if (flags & NUMBER_DEC) {
+ match_number_dec(buf, low, high, &dec_pi, &dec_num, &flags);
+ }
+
+#define MATCH_NUMBER_SET(val, index, ret)\
+ *pvalue = val;\
+ *pi = index;\
+ matched = ret
+
+#define MAX3(n1, n2, n3)\
+ ((n1 > n2) ? ((n1 > n3) ? n1 : n3) : ((n2 > n3) ? n2 : n3))
+
+#ifdef DEBUG_NUMBER
+ printf("\nmatch_number: Dec matched %d chars", dec_pi);
+ printf("\nmatch_number: Oct matched %d chars", oct_pi);
+ printf("\nmatch_number: Hex matched %d chars", hex_pi);
+#endif DEBUG_NUMBER
+
+ switch (flags & (NUMBER_HEX|NUMBER_OCT|NUMBER_DEC)) {
+ default:
+ case 0: /* No Matches */
+#ifdef DEBUG_NUMBER
+ printf("\nmatch_number: No matches");
+#endif DEBUG_NUMBER
+ MATCH_NUMBER_SET(0, MAX3(hex_pi, oct_pi, dec_pi), FALSE);
+ break;
+
+ case NUMBER_HEX: /* Hex Only */
+#ifdef DEBUG_NUMBER
+ printf("\nmatch_number: Matched hex");
+ printf("\nmatch_number: Returning hex");
+#endif DEBUG_NUMBER
+ MATCH_NUMBER_SET(hex_num, hex_pi, TRUE);
+ break;
+
+ case NUMBER_OCT: /* Octal Only */
+#ifdef DEBUG_NUMBER
+ printf("\nmatch_number: Matched oct");
+ printf("\nmatch_number: Returning oct");
+#endif DEBUG_NUMBER
+ MATCH_NUMBER_SET(oct_num, oct_pi, TRUE);
+ break;
+
+ case NUMBER_DEC: /* Decimal Only */
+#ifdef DEBUG_NUMBER
+ printf("\nmatch_number: Matched decimal");
+ printf("\nmatch_number: Returning decimal");
+#endif DEBUG_NUMBER
+ MATCH_NUMBER_SET(dec_num, dec_pi, TRUE);
+ break;
+
+ case NUMBER_HEX | NUMBER_OCT: /* Hex and Octal */
+#ifdef DEBUG_NUMBER
+ printf("\nmatch_number: Matched hex and octal");
+#endif DEBUG_NUMBER
+ if (flags & HEX_ZEROX_MATCHED) {
+ /* This case is impossible unless whitespace is optional */
+#ifdef DEBUG_NUMBER
+ printf("\nmatch_number: Returning hex");
+#endif DEBUG_NUMBER
+ MATCH_NUMBER_SET(hex_num, hex_pi, TRUE);
+ } else if (flags & OCT_ZERO_MATCHED) {
+#ifdef DEBUG_NUMBER
+ printf("\nmatch_number: Returning oct");
+#endif DEBUG_NUMBER
+ MATCH_NUMBER_SET(oct_num, oct_pi, TRUE);
+ } else {
+ /*
+ * We matched a hex and octal, but didn't get a '0' or '0x',
+ * so we have no idea which one it could be, so I'm going
+ * to guess an Octal. If anyone wants to change this,
+ * go right ahead.
+ */
+#ifdef DEBUG_NUMBER
+ printf("\nmatch_number: Returning oct");
+#endif DEBUG_NUMBER
+ MATCH_NUMBER_SET(oct_num, oct_pi, TRUE);
+ }
+ break;
+
+ case NUMBER_HEX | NUMBER_DEC: /* Hex and Decimal */
+#ifdef DEBUG_NUMBER
+ printf("\nmatch_number: Matched hex and decimal");
+#endif DEBUG_NUMBER
+ if (flags & HEX_ZEROX_MATCHED) {
+#ifdef DEBUG_NUMBER
+ printf("\nmatch_number: Returning hex");
+#endif DEBUG_NUMBER
+ MATCH_NUMBER_SET(hex_num, hex_pi, TRUE);
+ } else {
+ /*
+ * Pretty simple.
+ */
+#ifdef DEBUG_NUMBER
+ printf("\nmatch_number: Returning decimal");
+#endif DEBUG_NUMBER
+ MATCH_NUMBER_SET(dec_num, dec_pi, TRUE);
+ }
+ break;
+
+ case NUMBER_OCT | NUMBER_DEC: /* Octal and Decimal */
+#ifdef DEBUG_NUMBER
+ printf("\nmatch_number: Matched octal and decimal");
+#endif DEBUG_NUMBER
+ if (flags & OCT_ZERO_MATCHED) {
+#ifdef DEBUG_NUMBER
+ printf("\nmatch_number: Returning oct");
+#endif DEBUG_NUMBER
+ MATCH_NUMBER_SET(oct_num, oct_pi, TRUE);
+ } else {
+ /*
+ * Straightforward
+ */
+#ifdef DEBUG_NUMBER
+ printf("\nmatch_number: Returning decimal");
+#endif DEBUG_NUMBER
+ MATCH_NUMBER_SET(dec_num, dec_pi, TRUE);
+ }
+ break;
+
+ case NUMBER_HEX | NUMBER_OCT | NUMBER_DEC: /* All three */
+#ifdef DEBUG_NUMBER
+ printf("\nmatch_number: Matched hex, octal, and decimal");
+#endif DEBUG_NUMBER
+ if (flags & HEX_ZEROX_MATCHED) {
+#ifdef DEBUG_NUMBER
+ printf("\nmatch_number: Returning hex");
+#endif DEBUG_NUMBER
+ MATCH_NUMBER_SET(hex_num, hex_pi, TRUE);
+ } else if (flags & OCT_ZERO_MATCHED) {
+#ifdef DEBUG_NUMBER
+ printf("\nmatch_number: Returning oct");
+#endif DEBUG_NUMBER
+ MATCH_NUMBER_SET(oct_num, oct_pi, TRUE);
+ } else {
+#ifdef DEBUG_NUMBER
+ printf("\nmatch_number: Returning decimal");
+#endif DEBUG_NUMBER
+ MATCH_NUMBER_SET(dec_num, dec_pi, TRUE);
+ }
+ break;
+ }
+
+ if (matched) {
+ if (((flags & NUMBER_WS_OK) &&
+ match_whitespace2(buf, pi, csb->in_help)) ||
+ (flags & NUMBER_NO_WS_OK)) {
+#ifdef DEBUG_NUMBER
+ printf("\nmatch_number: Matched whitespace");
+#endif DEBUG_NUMBER
+ save_ambig_uint(csb, short_help, *pvalue);
+ return(TRUE);
+ } else {
+ /*
+ * We didn't match whitespace, so throw the matches
+ * out the window and return the max number of
+ * characters matched
+ */
+ *pi = MAX3(hex_pi, oct_pi, dec_pi);
+#ifdef DEBUG_NUMBER
+ printf("\nmatch_number: Didn't match whitespace");
+#endif DEBUG_NUMBER
+ }
+ }
+ if (flags & NUMBER_HELP_CHECK) {
+ help_or_error(csb, *pi, short_help, NO_COMMAND_COMPLETION);
+ } else {
+ csb->line_index += *pi;
+ set_error_index(csb);
+ csb->line_index -= *pi;
+ }
+ return(FALSE);
+}
+
+
+void generic_addr_noflag_action (parseinfo *csb, transition *mine,
+ addrparse_nf_struct * const arg)
+{
+ addrparse_struct out_arg = {arg->offset, arg->help, arg->type, 0};
+
+ generic_addr_action(csb, mine, &out_arg);
+}
+
+
+static boolean match_general_addr (parseinfo *csb, int *pi, void *addrp,
+ uint addr_type, uint flag,
+ const char *long_help)
+{
+ char *short_help = NULL;
+ match_gen_func func = NULL;
+ int i;
+ void *idb = NULL;
+
+ for (i=0; addr_funcs[i].addr_type != ADDR_ILLEGAL; i++) {
+ if (addr_type == addr_funcs[i].addr_type) {
+ short_help = addr_funcs[i].get_short_help(csb, flag, idb);
+ func = addr_funcs[i].func;
+ break;
+ }
+ }
+
+ if (addr_funcs[i].addr_type == ADDR_ILLEGAL) {
+ /* No sir, I don't like it */
+ return(FALSE);
+ }
+
+ if (help_check(csb)) {
+ save_help_long(csb, short_help, long_help, csb->priv);
+ return(FALSE);
+ }
+
+ if ((*func)(csb, &csb->line[csb->line_index],pi,addrp,
+ csb->in_help, flag, idb)) {
+ i = *pi;
+ if (match_whitespace2(&csb->line[csb->line_index], pi, csb->in_help)) {
+ save_ambig_nstring(csb, short_help,
+ &(csb->line[csb->line_index]), i);
+ return(TRUE);
+ }
+ }
+ ((addrtype *)addrp)->type = 0;
+ ((addrtype *)addrp)->length = 0;
+ if (!(flag & ADDR_NO_SHORT_HELP)) {
+ help_or_error(csb, *pi, short_help, NO_COMMAND_COMPLETION);
+ }
+ return(FALSE);
+}
+
+
+
+void generic_addr_action (parseinfo *csb, transition *mine,
+ addrparse_struct * const arg)
+{
+ void *addrp;
+ int i;
+
+ push_node(csb, mine->alternate);
+
+ INVALID_NVGEN_CHECK;
+
+ addrp = CSBVAR(csb, arg->offset, void);
+
+ i = 0;
+ if (match_general_addr(csb, &i, addrp, arg->type, arg->flag, arg->help)) {
+ csb->line_index += i;
+ push_node(csb, mine->accept);
+ csb->line_index -= i;
+
+ }
+}
+
+void multiple_funcs_action (parseinfo *csb, transition *mine,
+ test_struct * const arg)
+{
+ push_node(csb, mine->alternate);
+ if (test_multiple_funcs(csb, '=', 0)) {
+ push_node(csb, arg->equal);
+ } else {
+ push_node(csb, arg->notequal);
+ }
+}
+
+void save_ambig_string (parseinfo *csb, const char *help, const char *str)
+{
+ save_ambig_string_flag(csb, help, str, TRUE);
+}
+
+static void save_ambig_nstring (parseinfo *csb, const char *help,
+ const char *str, uint size)
+{
+ char *tmp = NULL;
+ uint length;
+
+ if (csb->flags & COMMAND_AUTHORIZE) {
+ length = strlen(str);
+ if (length > size) {
+ length = size;
+ }
+ tmp = (char *)PARSERmalloc(length + 1);
+ if (tmp) {
+ strncpy(tmp, str, length+1);
+ }
+ } else {
+ tmp = NULL;
+ }
+
+ save_ambig_string_flag(csb, help, tmp, TRUE);
+ if (tmp) {
+ PARSERfree(tmp);
+ }
+}
+
+static void save_ambig_int (parseinfo *csb, const char *help, int num)
+{
+ char str[12];
+
+ sprintf(str, "%d", num);
+ save_ambig_string_flag(csb, help, str, TRUE);
+}
+
+static void save_ambig_uint (parseinfo *csb, const char *help, uint num)
+{
+ char str[12];
+
+ sprintf(str, "%u", num);
+ save_ambig_string_flag(csb, help, str, TRUE);
+}
+
+static void save_ambig_string_flag (parseinfo *csb, const char *help,
+ const char *ambig_string, boolean space)
+{
+ ambig_struct *ap;
+ char *str;
+ uint new_length = strlen(help) + (space ? 1 : 0);
+ uint old_length;
+
+ if (csb->command_visible) {
+ ap = &csb->visible_ambig;
+ } else {
+ ap = &csb->hidden_ambig;
+ }
+
+ if (parser_ambig_debug) {
+ printf("\nsaving string '%s' in ambig buffer '%s'", help, ap->ambig);
+ }
+
+ old_length = strlen(ap->ambig);
+ str = ap->ambig + old_length;
+ if ((ap->ambig != str) && (*(str-1) == (char)-1)) {
+ /* Already marked as too big, so skip */
+ } else {
+ if ((new_length + old_length + 2) >= PARSEBUF) {
+ /* Too big, mark as too big and skip */
+ if ((old_length + 2) >= PARSEBUF) {
+ str = ap->ambig + PARSEBUF - 2;
+ }
+ *str++ = -1;
+ *str = '\0';
+ } else {
+ strcat(str, help);
+ if (space) {
+ strcat(str, " ");
+ }
+ }
+ if (csb->flags & COMMAND_AUTHORIZE) {
+ old_length = strlen(csb->nv_command);
+ new_length = strlen(ambig_string);
+ if ((new_length + old_length + 2) < PARSEBUF) {
+ strcat(csb->nv_command, ambig_string);
+ if (space) {
+ strcat(csb->nv_command, " ");
+ }
+ }
+ }
+ }
+}
+
+static void save_help_msg (parseinfo *csb, const char *help)
+{
+ if (csb->in_help == PARSER_HELP) {
+ save_line(csb, &csb->help_save, "%s", help);
+ }
+}
+
+static void save_help_short (parseinfo *csb, const char *help,
+ boolean do_command_completion)
+{
+ if ((csb->in_help == PARSER_HELP) ||
+ (do_command_completion == SUPPORT_COMMAND_COMPLETION)) {
+ save_line(csb, &csb->help_save, "%s\t", help);
+ }
+}
+
+void save_help_long (parseinfo *csb, const char *short_help,
+ const char *long_help, uint priv)
+{
+ if (csb->in_help == PARSER_HELP) {
+ save_line(csb, &csb->help_save, " %s", short_help);
+ if (long_help) {
+ save_line(csb, &csb->help_save, "\t%s", long_help);
+ }
+ save_line(csb, &csb->help_save, "\n");
+ }
+}
+
+
+static void parser_bail_out (parseinfo *csb, void (*func)(parseinfo *),
+ const char *func_name)
+{
+ if ( func )
+ func(csb);
+}
+
+
+void priv_action (parseinfo *csb, transition *mine, priv_struct * const arg)
+{
+ push_node(csb, mine->alternate);
+ if (priv_check(csb, arg->priv)) {
+ if (csb->priv_set) {
+ priv_push(csb, arg->priv);
+ }
+ csb->last_priv = arg->priv->cur_priv;
+ if (csb->last_priv > csb->highest_priv) {
+ csb->highest_priv = csb->last_priv;
+ }
+ push_node(csb, mine->accept);
+ } else {
+ push_node(csb, arg->fail);
+ }
+}
+
+void month_action (parseinfo *csb, transition *mine,
+ month_struct * const arg)
+{
+ int *var = CSBVAR(csb, arg->offset, int);
+ int i;
+ static const char *short_help = "MONTH";
+
+ push_node(csb, mine->alternate);
+
+ INVALID_NVGEN_CHECK;
+
+ if (help_check(csb)) {
+ save_help_long(csb, short_help, arg->help, csb->priv);
+ return;
+ }
+
+ for (i=0; i < MONTHS_IN_YEAR; i++) {
+ int j = 0;
+ if (match_partial_keyword(csb, long_month_name[i], &j, NULL, 3,
+ KEYWORD_WS_OK, csb->priv)) {
+ csb->line_index += j;
+ *var = i + 1;
+ push_node(csb, mine->accept);
+ csb->line_index -= j;
+ break;
+ }
+ }
+}
+
+
+void day_action (parseinfo *csb, transition *mine,
+ day_struct * const arg)
+{
+ int *var = CSBVAR(csb, arg->offset, int);
+ int i;
+ static const char *short_help = "DAY";
+
+ push_node(csb, mine->alternate);
+
+ INVALID_NVGEN_CHECK;
+
+ if (help_check(csb)) {
+ save_help_long(csb, short_help, arg->help, csb->priv);
+ return;
+ }
+
+ for (i=0; i < DAYS_IN_WEEK + 1; i++) {
+ int j = 0;
+ if (match_partial_keyword(csb, long_day_name[i], &j, NULL, 3,
+ KEYWORD_WS_OK, csb->priv)) {
+ csb->line_index += j;
+ *var = i;
+ push_node(csb, mine->accept);
+ csb->line_index -= j;
+ break;
+ }
+ }
+}
+
+
+void timesec_action (parseinfo *csb, transition *mine, timesec_struct *arg)
+{
+ uint *var1 = CSBVAR(csb, arg->var1, uint);
+ uint *var2 = CSBVAR(csb, arg->var2, uint);
+ uint *var3;
+ char *short_help;
+ uint i;
+ static uint flags = NUMBER_DEC | NUMBER_NO_WS_OK;
+
+ push_node(csb, mine->alternate);
+
+ INVALID_NVGEN_CHECK;
+
+ if (arg->var3 == MAXUINT) {
+ short_help = "hh:mm";
+ var3 = 0;
+ } else {
+ short_help = "hh:mm:ss";
+ var3 = CSBVAR(csb, arg->var3, uint);
+ }
+
+ if (help_check(csb)) {
+ save_help_long(csb, short_help, arg->help, csb->priv);
+ }
+
+ i = 0;
+ if (match_number(csb, 0, 23, &i, var1, flags, NULL) &&
+ match_char(&csb->line[csb->line_index], &i, ':') &&
+ match_number(csb, 0, 59, &i, var2, flags, NULL) &&
+ ((arg->var3 == MAXUINT) ||
+ (match_char(&csb->line[csb->line_index], &i, ':') &&
+ match_number(csb, 0, 59, &i, var3, flags, NULL))) &&
+ match_whitespace2(&csb->line[csb->line_index], &i, csb->in_help)) {
+ csb->line_index += i;
+ push_node(csb, mine->accept);
+ csb->line_index -= i;
+ return;
+ }
+
+ if (i) {
+ help_or_error(csb, i, short_help, NO_COMMAND_COMPLETION);
+ }
+}
+
+
+void comment_action (parseinfo *csb, transition *mine)
+{
+ push_node(csb, mine->accept);
+ if (csb->nvgen && !csb->priv_set) {
+ /*
+ *RAMS: commented this for now
+
+ nv_write(TRUE, "!"); */
+ }
+}
+
+void testexpr_action (parseinfo *csb, transition *mine, testexpr_struct * const arg)
+{
+ /* always push the alternate */
+ push_node(csb, mine->alternate);
+
+ if (csb->priv_set || (csb->flags & COMMAND_FUNCTION)) {
+ /*
+ * Parser state may not be what test expression expects,
+ * so avoid testing the expression.
+ */
+ push_node(csb, mine->accept);
+ push_node(csb, arg->fal);
+ } else {
+ if (arg->func(csb, mine)) {
+ push_node(csb, mine->accept);
+ } else {
+ push_node(csb, arg->fal);
+ }
+ }
+}
+
+
+
+
+void keyword_option_action (parseinfo *csb,
+ transition *mine,
+ keyword_option_struct * const arg)
+{
+ uint i;
+ uint o;
+ uint *var = CSBVAR(csb, arg->offset, uint);
+ boolean matched;
+ uint flags = KEYWORD_HELP_CHECK | KEYWORD_WS_OK;
+
+ push_node(csb, mine->alternate);
+
+ INVALID_NVGEN_CHECK;
+
+ if (priv_check(csb, arg->priv) == FALSE) {
+ return;
+ }
+
+ keyword_flag_modify(csb, arg->priv, &flags);
+
+ o = 0;
+ matched = FALSE;
+ while (arg->options[o].keyword && !matched) {
+ if (arg->flags & KEYWORD_TEST) {
+ if (arg->flags & KEYWORD_OR_SET) {
+ if (*var & arg->options[o].val) {
+ o++;
+ continue;
+ }
+ } else {
+ if (*var) {
+ o++;
+ continue;
+ }
+ }
+ }
+ i = 0;
+ if (match_partial_keyword(csb, arg->options[o].keyword, &i,
+ arg->options[o].help, 0, flags,
+ arg->priv->cur_priv)) {
+ csb->line_index += i;
+ if (csb->priv_set) {
+ priv_push(csb, arg->priv); /* change priv level */
+ }
+ csb->last_priv = arg->priv->cur_priv;
+ if (csb->last_priv > csb->highest_priv) {
+ csb->highest_priv = csb->last_priv;
+ }
+ if (arg->offset != -1) {
+ if (arg->flags & KEYWORD_OR_SET) {
+ *var |= arg->options[o].val;
+ } else {
+ *var = arg->options[o].val;
+ }
+ }
+ push_node(csb, mine->accept);
+ csb->line_index -= i;
+ matched = TRUE;
+ } else {
+ if (parser_ambig_debug) {
+ printf("\nDidn't match keyword '%s'", arg->options[o].keyword);
+ }
+ }
+ o++;
+ }
+}
+
+
+
+
+
+
+
+#ifdef IOS_PARSER
+
+
+
+/* WHITESPACE matches at least one whitespace char, maybe more
+ * EOL is acceptable as whitespace.
+ */
+
+void whitespace_action (parseinfo *csb, transition *mine)
+{
+ int i;
+
+ push_node(csb, mine->alternate);
+ if (csb->nvgen) {
+ /*
+ * Don't add whitespace here. This function is often called between
+ * tokens which don't generate any output.
+ */
+ push_node(csb, mine->accept);
+
+ return;
+ }
+ i = 0;
+
+ if (match_whitespace2(&csb->line[csb->line_index], &i, csb->in_help)) {
+ csb->line_index += i;
+ push_node(csb, mine->accept);
+ csb->line_index -= i;
+ }
+ /* No point to setting error_index: if the above fails we haven't
+ scanned any whitespace successfully. */
+}
+
+
+/* PRINT always matches and prints its string, followed by a newline */
+
+void print_action (parseinfo *csb, transition *mine,
+ print_struct * const arg)
+{
+ push_node(csb, mine->accept);
+ if (csb->nvgen) {
+ return;
+ }
+
+ if (arg->str) {
+ printf(arg->str);
+ }
+}
+
+/* Display places its message into the help buffer no matter what.
+ * It's used mostly in cases where we've decided to discard the rest of
+ * the input line and produce a generic help/error message.
+ * THIS FUNCTION PRODUCES HELP WHEN in_help IS NOT SET.
+ */
+
+void display_action (parseinfo *csb, transition *mine,
+ help_struct * const arg)
+{
+ save_help_msg(csb, arg->str);
+ push_node(csb, mine->alternate);
+ return;
+}
+
+
+/* CHARACTER matches a single character */
+
+void char_action (parseinfo *csb, transition *mine,
+ char_struct * const arg)
+{
+ char ch[2];
+
+ push_node(csb, mine->alternate);
+
+ /* Long help is the responsibility of the calling macro. */
+
+ INVALID_NVGEN_CHECK;
+
+ if (csb->line[csb->line_index] == arg->character) {
+
+ ch[0] = arg->character;
+ ch[1] = '\0';
+ if (parser_ambig_debug) {
+ printf("\nMatched character '%c'", arg->character);
+ printf("\ncsb->command_visible = %d", csb->command_visible);
+ }
+ save_ambig_string(csb, ch, ch);
+
+ csb->line_index++;
+ push_node(csb, mine->accept);
+ csb->line_index--;
+ }
+
+ /*
+ * Note that short help check and error processing
+ * are NOT appropriate here.
+ */
+}
+
+
+/*
+ * CHAR_NUMBER takes either a character or an integer value
+ * representing a character
+ */
+void char_number_action (parseinfo *csb, transition *mine,
+ number_struct * const arg)
+{
+ char short_help[32];
+ int i = 0;
+ uint num;
+ uint lower;
+ uint upper;
+
+ push_node(csb, mine->alternate);
+ INVALID_NVGEN_CHECK;
+
+ CHECK_RANGE_BOUNDS();
+
+ sprintf(short_help, "CHAR or <%d-%d>", lower, upper);
+
+ if (help_check(csb)) {
+ save_help_long(csb, short_help, arg->help, csb->priv);
+ return;
+ }
+
+ /* Try to match the number first */
+ num = 0;
+ if (! match_number(csb, lower, upper, &i, &num,
+ (NUMBER_HEX | HEX_ZEROX_OK | NUMBER_OCT | OCT_ZERO_OK |
+ NUMBER_DEC | NUMBER_NO_WS_OK | NUMBER_HELP_CHECK),
+ NULL)) {
+
+ /* No number, try a character */
+ if (csb->line[csb->line_index] &&
+ !isspace(csb->line[csb->line_index])) {
+
+ /* We have a Non-null character, try accepting it */
+ num = (int) csb->line[csb->line_index];
+ i = 1;
+ }
+ }
+
+ if (i) {
+ if (match_whitespace2((csb->line + csb->line_index),
+ &i, csb->in_help)) {
+
+ *CSBVAR(csb, arg->offset, uint) = num;
+
+ csb->line_index += i;
+ push_node(csb, mine->accept);
+ csb->line_index -= i;
+
+ return;
+ }
+ }
+ help_or_error(csb, i, short_help, NO_COMMAND_COMPLETION);
+}
+
+/*
+ * FUNC calls the named function if we're doing NV generation, or
+ * saves the * pointer to the function and
+ * the current arguments strucuture if we're
+ * consuming input.
+ *
+ * If we're consuming, try the accepting chain, then check csb->multiple_funcs.
+ * If it changed, then EOL was encountered and we leave the argument struct
+ * on the parsedata list. Otherwise, we didn't see an EOL, so remove the
+ * structure from the list. This ensures that the only structures in
+ * the list are those corresponding to FUNCs along the chain leading to
+ * an accepted EOL.
+ *
+ * If we're doing NV generation, call the function directly. This allows the
+ * function at the end of commands which are only keyword based to to
+ * automatically perform NV generation without having to explicitly include an
+ * NVGEN() transition in the command chain definition.
+ */
+
+void func_action (parseinfo *csb, transition *mine, void (*func) (parseinfo *))
+{
+ INVALID_NVGEN_CHECK;
+
+ if (!csb->in_help && func) {
+ (void) func(csb);
+ }
+ push_node(csb, mine->accept);
+}
+
+void test_boolean_action (parseinfo *csb, transition *mine,
+ test_bool_struct * const arg)
+{
+ push_node(csb, mine->alternate);
+ if (*(arg->var)) {
+ push_node(csb, arg->nonzero);
+ } else {
+ push_node(csb, arg->zero);
+ }
+}
+
+void test_int_action (parseinfo *csb, transition *mine,
+ test_int_struct * const arg)
+{
+ push_node(csb, mine->alternate);
+ if (*(arg->var)) {
+ push_node(csb, arg->nonzero);
+ } else {
+ push_node(csb, arg->zero);
+ }
+}
+
+void test_func_action (parseinfo *csb, transition *mine,
+ test_func_struct * const arg)
+{
+ push_node(csb, mine->alternate);
+ if (arg->func()) {
+ push_node(csb, arg->nonzero);
+ } else {
+ push_node(csb, arg->zero);
+ }
+}
+
+void keyword_nows_action (parseinfo *csb, transition *mine,
+ keyword_struct * const arg)
+{
+ general_keyword_struct argout = {
+ arg->str, arg->help, arg->priv, -1, 0, 0,
+ (KEYWORD_NO_WS_OK | KEYWORD_HELP_CHECK)};
+ general_keyword_action(csb, mine, &argout);
+}
+
+void keyword_id_mm_action (parseinfo *csb, transition *mine,
+ keyword_id_mm_struct * const arg)
+{
+ general_keyword_struct argout = {
+ arg->str, arg->help, arg->priv, arg->offset, arg->val, arg->minmatch,
+ (KEYWORD_WS_OK | KEYWORD_HELP_CHECK)};
+ general_keyword_action(csb, mine, &argout);
+}
+
+void keyword_trans_action (parseinfo *csb, transition *mine,
+ keyword_struct * const arg)
+{
+ if (mine && mine->accept && mine->accept->accept &&
+ (mine->accept->accept->alternate != &pname(link_trans))) {
+ keyword_action(csb, mine, arg);
+ } else {
+ push_node(csb, mine->alternate);
+ }
+}
+
+void keyword_ortest_action (parseinfo *csb, transition *mine,
+ keyword_id_struct * const arg)
+{
+ general_keyword_struct argout = {
+ arg->str, arg->help, arg->priv, arg->offset, arg->val, 0,
+ (KEYWORD_WS_OK | KEYWORD_HELP_CHECK | KEYWORD_OR_SET | KEYWORD_TEST)};
+ general_keyword_action(csb, mine, &argout);
+}
+
+void keyword_option_action (parseinfo *csb,
+ transition *mine,
+ keyword_option_struct * const arg)
+{
+ uint i;
+ uint o;
+ uint *var = CSBVAR(csb, arg->offset, uint);
+ boolean matched;
+ uint flags = KEYWORD_HELP_CHECK | KEYWORD_WS_OK;
+
+ push_node(csb, mine->alternate);
+
+ INVALID_NVGEN_CHECK;
+
+ if (priv_check(csb, arg->priv) == FALSE) {
+ return;
+ }
+
+ keyword_flag_modify(csb, arg->priv, &flags);
+
+ o = 0;
+ matched = FALSE;
+ while (arg->options[o].keyword && !matched) {
+ if (arg->flags & KEYWORD_TEST) {
+ if (arg->flags & KEYWORD_OR_SET) {
+ if (*var & arg->options[o].val) {
+ o++;
+ continue;
+ }
+ } else {
+ if (*var) {
+ o++;
+ continue;
+ }
+ }
+ }
+ i = 0;
+ if (match_partial_keyword(csb, arg->options[o].keyword, &i,
+ arg->options[o].help, 0, flags,
+ arg->priv->cur_priv)) {
+ csb->line_index += i;
+ if (csb->priv_set) {
+ priv_push(csb, arg->priv); /* change priv level */
+ }
+ csb->last_priv = arg->priv->cur_priv;
+ if (csb->last_priv > csb->highest_priv) {
+ csb->highest_priv = csb->last_priv;
+ }
+ if (arg->offset != -1) {
+ if (arg->flags & KEYWORD_OR_SET) {
+ *var |= arg->options[o].val;
+ } else {
+ *var = arg->options[o].val;
+ }
+ }
+ push_node(csb, mine->accept);
+ csb->line_index -= i;
+ matched = TRUE;
+ } else {
+ if (parser_ambig_debug) {
+ printf("\nDidn't match keyword '%s'", arg->options[o].keyword);
+ }
+ }
+ o++;
+ }
+}
+
+void number_func_action (parseinfo *csb, transition *mine,
+ number_func_struct * const arg)
+{
+ dynamic_number_struct new_arg =
+ {
+ arg->offset, 0, -1, arg->help,
+ (NUMBER_HEX | HEX_ZEROX_OK | NUMBER_OCT | OCT_ZERO_OK |
+ NUMBER_DEC | NUMBER_WS_OK | NUMBER_HELP_CHECK)
+ };
+
+ if (!csb->priv_set &&
+ !(csb->flags & COMMAND_FUNCTION) &&
+ arg->func) {
+ arg->func(csb, &(new_arg.lower), &(new_arg.upper));
+ }
+ general_number_action(csb, mine, &new_arg);
+}
+
+void number_help_func_action (parseinfo *csb, transition *mine,
+ number_help_func_struct * const arg)
+{
+ dynamic_number_struct new_arg =
+ {
+ arg->offset, 0, -1, "",
+ (NUMBER_HEX | HEX_ZEROX_OK | NUMBER_OCT | OCT_ZERO_OK |
+ NUMBER_DEC | NUMBER_WS_OK | NUMBER_HELP_CHECK)
+ };
+
+ if (!csb->priv_set &&
+ !(csb->flags & COMMAND_FUNCTION) &&
+ arg->func) {
+ arg->func(csb, &new_arg.lower, &new_arg.upper, &new_arg.help);
+ }
+ general_number_action(csb, mine, &new_arg);
+}
+
+void params_action (parseinfo *csb, transition *mine,
+ params_struct * const arg)
+{
+ char *cp,
+ *cp_save;
+ int i = 0,
+ k = 0;
+ uint num;
+ uint lower;
+ uint upper;
+ uint flags = KEYWORD_WS_OK | KEYWORD_HELP_CHECK;
+
+ /* Make sure we process any alternates */
+ push_node(csb, mine->alternate);
+
+ /* Check for privilege to use this keyword */
+ if (priv_check(csb, arg->priv) == FALSE) {
+ return;
+ }
+
+ if (csb->nvgen) {
+ if (csb->priv_set) {
+ if (nvgen_privilege(csb, arg->priv, arg->str)) {
+ /*
+ * The next token is a number, but we are currently
+ * stopping at NVGEN points, which a number is, so stop!
+ */
+ }
+ return;
+ }
+ for (cp = csb->nv_command; *cp; cp++) {
+ ; /* Null body */
+ }
+ cp_save = cp;
+
+ /* Add a space if needed */
+ if (cp != csb->nv_command) {
+ *cp++ = ' ';
+ *cp = 0;
+ }
+
+ /*
+ * Add the current token and call the command action routine
+ */
+ strcpy(cp, arg->str);
+
+ csb->which = arg->subfunc;
+ nvgen_action(csb, mine, arg->func);
+
+ /*
+ * Restore the original command line before processing alternates
+ */
+ *cp_save = 0;
+ return;
+ }
+
+ /********** KEYWORD **********/
+ /*
+ * Check to see if the input matches this token. If there is no match,
+ * we skip processing this token and try the alternates.
+ */
+ keyword_flag_modify(csb, arg->priv, &flags);
+ if (match_partial_keyword(csb, arg->str, &i, arg->keyhelp, 0,
+ flags, arg->priv->cur_priv)) {
+ csb->line_index += i;
+
+ if (csb->priv_set) {
+ /*
+ * Modify the current keyword privilege
+ */
+ priv_push(csb, arg->priv);
+ }
+ csb->last_priv = arg->priv->cur_priv;
+ if (csb->last_priv > csb->highest_priv) {
+ csb->highest_priv = csb->last_priv;
+ }
+ /******** NVGENS **********/
+ csb->which = arg->subfunc;
+
+ if ((csb->sense == FALSE) && (arg->flags & NO_NUMBER)) {
+ /******** NOPREFIX *********/
+ /*
+ * We've parsed a 'no' prefix and must consume the remainder of
+ * the line, then look for EOL.
+ */
+ for (k = 0; csb->line[csb->line_index + k] != '\n' &&
+ csb->line[csb->line_index + k]; k++) {
+ /* Null body */
+ }
+ /******** EOLS ***********/
+ csb->line_index += k;
+ csb->which = arg->subfunc;
+ eol_action(csb, mine, arg->func);
+ csb->line_index -= k;
+ /****** End EOLS *********/
+ /******** End NOPREFIX ********/
+ } else {
+ /******** DECIMAL **********/
+ k = 0;
+
+ CHECK_RANGE_BOUNDS();
+
+ if (match_number(csb, lower, upper, &k, &num,
+ arg->flags, arg->varhelp)) {
+
+ *CSBVAR(csb, arg->offset, uint) = num;
+
+ /******** EOLS ***********/
+ csb->line_index += k;
+ csb->which = arg->subfunc;
+ eol_action(csb, mine, arg->func);
+ csb->line_index -= k;
+ /****** End EOLS *********/
+ } else {
+ /******** NO_ALT ***********/
+ csb->line_index += k;
+ no_alt_action(csb);
+ csb->line_index -= k;
+ /********* End NO_ALT **********/
+ }
+ /********* End DECIMAL **********/
+ }
+
+ csb->line_index -= i;
+ /********* End NVGENS **********/
+ }
+}
+
+void params_action_alist (parseinfo *csb, transition *mine,
+ params_struct_alist * const arg)
+{
+ char *cp,
+ *cp_save;
+ int i = 0,
+ k = 0;
+ uint num;
+ uint lower, lower2;
+ uint upper, upper2;
+ uint flags = KEYWORD_WS_OK | KEYWORD_HELP_CHECK;
+
+ /* Make sure we process any alternates */
+ push_node(csb, mine->alternate);
+
+ /* Check for privilege to use this keyword */
+ if (priv_check(csb, arg->priv) == FALSE) {
+ return;
+ }
+
+ if (csb->nvgen) {
+ if (csb->priv_set) {
+ if (nvgen_privilege(csb, arg->priv, arg->str)) {
+ /*
+ * The next token is a number, but we are currently
+ * stopping at NVGEN points, which a number is, so stop!
+ */
+ }
+ return;
+ }
+ for (cp = csb->nv_command; *cp; cp++) {
+ ; /* Null body */
+ }
+ cp_save = cp;
+
+ /* Add a space if needed */
+ if (cp != csb->nv_command) {
+ *cp++ = ' ';
+ *cp = 0;
+ }
+
+ /*
+ * Add the current token and call the command action routine
+ */
+ strcpy(cp, arg->str);
+
+ csb->which = arg->subfunc;
+ nvgen_action(csb, mine, arg->func);
+
+ /*
+ * Restore the original command line before processing alternates
+ */
+ *cp_save = 0;
+ return;
+ }
+
+ /********** KEYWORD **********/
+ /*
+ * Check to see if the input matches this token. If there is no match,
+ * we skip processing this token and try the alternates.
+ */
+ keyword_flag_modify(csb, arg->priv, &flags);
+ if (match_partial_keyword(csb, arg->str, &i, arg->keyhelp, 0,
+ flags, arg->priv->cur_priv)) {
+ csb->line_index += i;
+
+ if (csb->priv_set) {
+ /*
+ * Modify the current keyword privilege
+ */
+ priv_push(csb, arg->priv);
+ }
+ csb->last_priv = arg->priv->cur_priv;
+ if (csb->last_priv > csb->highest_priv) {
+ csb->highest_priv = csb->last_priv;
+ }
+ /******** NVGENS **********/
+ csb->which = arg->subfunc;
+
+ if ((csb->sense == FALSE) && (arg->flags & NO_NUMBER)) {
+ /******** NOPREFIX *********/
+ /*
+ * We've parsed a 'no' prefix and must consume the remainder of
+ * the line, then look for EOL.
+ */
+ for (k = 0; csb->line[csb->line_index + k] != '\n' &&
+ csb->line[csb->line_index + k]; k++) {
+ /* Null body */
+ }
+ /******** EOLS ***********/
+ csb->line_index += k;
+ csb->which = arg->subfunc;
+ eol_action(csb, mine, arg->func);
+ csb->line_index -= k;
+ /****** End EOLS *********/
+ /******** End NOPREFIX ********/
+ } else {
+ /******** DECIMAL **********/
+ k = 0;
+
+ CHECK_RANGE_BOUNDS_ALIST();
+
+ if (match_number(csb, lower, upper, &k, &num,
+ arg->flags, arg->varhelp)) {
+
+ *CSBVAR(csb, arg->offset, uint) = num;
+
+ /******** EOLS ***********/
+ csb->line_index += k;
+ csb->which = arg->subfunc;
+ eol_action(csb, mine, arg->func);
+ csb->line_index -= k;
+ /****** End EOLS *********/
+ } else if (match_number(csb, lower2, upper2, &k, &num,
+ arg->flags & ~NUMBER_HELP_CHECK,
+ NULL)) {
+
+ /* Convert to other numbering scheme and save */
+ *CSBVAR(csb, arg->offset, uint) = num + lower - lower2;
+
+ /******** EOLS ***********/
+ csb->line_index += k;
+ csb->which = arg->subfunc;
+ eol_action(csb, mine, arg->func);
+ csb->line_index -= k;
+ /****** End EOLS *********/
+ } else {
+ /******** NO_ALT ***********/
+ csb->line_index += k;
+ no_alt_action(csb);
+ csb->line_index -= k;
+ /********* End NO_ALT **********/
+ }
+ /********* End DECIMAL **********/
+ }
+
+ csb->line_index -= i;
+ /********* End NVGENS **********/
+ }
+}
+
+
+void hexdata_action (parseinfo *csb, transition *mine,
+ hexdata_struct * const arg)
+{
+ int i;
+ int stored = 0;
+ char short_help[] = "Hex-data";
+
+ push_node(csb, mine->alternate);
+
+ INVALID_NVGEN_CHECK;
+
+ if (help_check(csb)) {
+ save_help_long(csb, short_help, arg->help, csb->priv);
+ return;
+ }
+
+ i = match_hex_digits(csb->line + csb->line_index,
+ CSBVAR(csb, arg->bufoffset, char),
+ arg->bufmax, &stored);
+ if (i) {
+ (void) match_whitespace2(csb->line + csb->line_index,
+ &i, csb->in_help);
+ }
+
+ /*
+ * The following catches all help ?'s in the middle of a stream.
+ */
+
+ csb->line_index += i;
+ if (help_check(csb)) {
+ save_help_short(csb, short_help, NO_COMMAND_COMPLETION);
+ } else {
+ if (stored > 0) {
+ /* success */
+ /* string output stored already */
+ *CSBVAR(csb, arg->numoffset, uint) = stored;
+ push_node(csb, mine->accept);
+ } else {
+ set_error_index(csb);
+ }
+ }
+ csb->line_index -= i;
+}
+
+/*
+ * Like char_action, but deals with characters which might be taken
+ * as designating end of line (like '#'), confusing any (prior)
+ * help_check full help check. These characters can only be correctly
+ * processed by not allowing alternative interpretations !!!
+ */
+void literal_char_action (parseinfo *csb, transition *mine,
+ char_struct2 * const arg)
+{
+ push_node(csb, mine->alternate);
+
+ INVALID_NVGEN_CHECK;
+
+ if (csb->line[csb->line_index] == arg->character) {
+ csb->line_index++;
+ push_node(csb, mine->accept);
+ csb->line_index--;
+ } else {
+ /* Can only have help if the character is NOT found. */
+ if (help_check(csb)) {
+ save_help_short(csb, arg->help, NO_COMMAND_COMPLETION);
+ }
+ }
+}
+
+static boolean match_spaces (char *buf, int *pi)
+{
+ int k;
+
+ buf += *pi;
+ for (k = 0; isspace(buf[k]); k++) {
+ ; /* Null body */
+ }
+
+ *pi += k;
+
+ return((k > 0) ? TRUE : FALSE);
+}
+
+
+
+/*
+ * Converts one or two hex digits from s to a hex number, and stores it in
+ * out. Returns pointer to next non-consumed char (NULL if first char is
+ * not a hex digit or if it is end of string).
+ */
+static char *hex_to_byte (char *s, char *out)
+{
+ int i = 0;
+
+ match_spaces(s, &i);
+ s += i;
+ *out = 0;
+
+ if ((*s == '\0') || !isxdigit(*s)) {
+ return(NULL);
+ }
+
+ *out = CVHTOB(*s);
+ s++;
+
+ if ((*s != '\0') && isxdigit(*s)) {
+ *out = (*out << 4) + CVHTOB(*s);
+ s++;
+ }
+ return(s);
+}
+
+/*
+ * Recognize single or paired hex digits in buf. Convert each pair to a
+ * byte, and store that byte in outbuf. maxlen is the most chars that can
+ * be stored in outbuf.
+ *
+ * RETURNS: number of characters matched. *pchars is the number of chars
+ * stored.
+ *
+ */
+static int match_hex_digits (char *buf, char *outbuf, int maxlen, int *pchars)
+{
+ int i;
+ char *s;
+ char *ptr = buf;
+
+ for (i = 0; i < maxlen; i++) {
+ s = hex_to_byte(ptr, outbuf);
+ if (s == NULL) {
+ break;
+ }
+ ptr = s;
+ outbuf++;
+ }
+ *pchars = i;
+ return(ptr - buf);
+}
+
+/* ALT_HELP does func call at EOL which
+ * prints platform specific help.
+ */
+
+void alt_help_action (parseinfo *csb, transition *mine, void (*func) (parseinfo *))
+{
+ if (csb->in_help) {
+ if (help_check(csb)) {
+ if (func) {
+ (void) func(csb);
+ return;
+ }
+ }
+ }
+
+ no_alt_action(csb);
+}
+
+/* ALT_HELPS - does platform specific func call at EOL. Sets csb->which with
+ * the EVAL macro so that 'val' is not constrained to be a constant.
+ */
+void alt_helps_action (parseinfo *csb, transition *mine,
+ eols_struct * const arg)
+{
+ csb->which = arg->subfunc;
+ alt_help_action(csb, mine, arg->func);
+}
+
+
+void general_number_short_help (uint *flags, uint lower,
+ uint upper, char *help)
+{
+ general_number_short_help_http(flags, lower, upper, help, FALSE);
+}
+
+boolean match_minusone (char *buf, int *pi)
+{
+ if ((buf[*pi] == '-') && (buf[1 + *pi] == '1')) {
+ (*pi) += 2;
+ return(TRUE);
+ }
+ return(FALSE);
+}
+
+/*
+ * Scan octal as an unsigned int. Error if too many
+ * octal digits
+ */
+boolean match_octal (char *buf, uint low, uint high, int *pi, ushort * pvalue)
+{
+ uint i = 0;
+ ulong value = 0L;
+
+ /* Fail if there is not at least one octal digit */
+ *pvalue = 0L;
+ buf += *pi;
+
+ if (!isodigit(buf[i])) {
+ return(FALSE);
+ }
+
+ for (; isodigit(buf[i]); i++) {
+ if (value > USHRT_MAX / 8) {
+ *pi += i;
+ return(FALSE);
+ }
+ value = 8 * value + buf[i] - '0';
+ if (value > high) {
+ *pi += i;
+ return(FALSE);
+ }
+ }
+ if (i && (value >= (ulong) low)) {
+ *pvalue = (ushort) value;
+ *pi += i;
+ return(TRUE);
+ }
+ return(FALSE);
+}
+
+/*
+ * ASSUMES: no leading 0x.
+ *
+ */
+boolean match_hexadecimal (char *buf, int *pi, ushort * pvalue)
+{
+ int i;
+ char c;
+ ushort value = 0;
+
+ buf += *pi;
+ *pvalue = 0;
+
+ for (i = 0, c = toupper(buf[i]); isxdigit(c); i++, c = toupper(buf[i])) {
+ if (value > USHRT_MAX / 16) {
+ *pi += i;
+ return(FALSE);
+ }
+ value = value * 16 + CVHTOB(c);
+ }
+
+ if (i > 0) {
+ (*pi) += i;
+ *pvalue = value;
+ return(TRUE);
+ }
+ return(FALSE);
+}
+
+
+/*
+ * Try to match an hexadecimal ulong, with value
+ * between (or equal to) <low> and <high>. <*pi> is incremented
+ * by the number of characters in the match.
+ *
+ * ASSUMES: no leading 0x.
+ *
+ */
+boolean match_ulong_hexadecimal (char *buf, ulong low, ulong high,
+ int *pi, ulong *pvalue)
+{
+ int i;
+ ulong value = 0L;
+ char c;
+
+ buf += *pi;
+ *pvalue = 0L;
+
+ for (i = 0, c = toupper(buf[i]); isxdigit(c); i++, c = toupper(buf[i])) {
+ if (value > ULONG_MAX / 16) {
+ /* Too many non-zero digits, max out. */
+ *pi += i;
+ return(FALSE);
+ }
+ value = value * 16 + CVHTOB(c);
+ if (value > high) {
+ *pi += i;
+ return(FALSE);
+ }
+ }
+
+ if (i && (value >= low)) {
+ *pvalue = value;
+ *pi += i;
+ return(TRUE);
+ }
+ return(FALSE);
+}
+
+
+
+/*
+ * Scan octal as an unsigned LONG int. Error if too many octal
+ * digits.
+ */
+boolean match_ulong_octal (char *buf, ulong low,
+ ulong high, int *pi, ulong *pvalue)
+{
+ uint i = 0;
+ ulong value = 0L;
+
+ /* Fail if there is not at least one octal digit */
+ *pvalue = 0L;
+ buf += *pi;
+
+ if (!isodigit(buf[i])) {
+ return(FALSE);
+ }
+
+ for (; isodigit(buf[i]); i++) {
+ /* Make sure we don't have a 33-rd bit */
+ if (value > ULONG_MAX / 8) {
+ *pi += i;
+ return(FALSE);
+ }
+ value = 8 * value + buf[i] - '0';
+ if (value > high) {
+ *pi += i;
+ return(FALSE);
+ }
+ }
+ if (i && (value >= low)) {
+ *pvalue = value;
+ *pi += i;
+ return(TRUE);
+ }
+ return(FALSE);
+}
+
+/*
+ * Try to match an unsigned LONG int,
+ * with value between (or equal to) <low> and
+ * <high>. <*pi> is incremented by the number of characters in
+ * the match.
+ */
+boolean match_ulong_decimal (char *buf,ulong low, ulong high,
+ int *pi, ulong *pvalue)
+{
+ int i;
+ ulong value = 0L;
+ char c;
+
+ buf += *pi;
+ *pvalue = 0L;
+
+ i = 0;
+ if (buf[i] == '+')
+ i++;
+
+ for (c = buf[i]; isdigit(c); c = buf[++i]) {
+ if ((value > ULONG_MAX / 10)
+ || ((value == ULONG_MAX / 10) && ((c - '0') > ULONG_MAX % 10))) {
+ /* Too many chars, max out. */
+ *pi += i;
+ return(FALSE);
+ }
+ value = value * 10 + (ulong) (c - '0');
+ if (value > high) {
+ *pi += i;
+ return(FALSE);
+ }
+ }
+
+ if (i && (value >= low)) {
+ *pvalue = value;
+ *pi += i;
+ return(TRUE);
+ }
+ return(FALSE);
+}
+
+
+#ifdef DEBUG_PARSER
+void print_tokenQ (parseinfo *csb)
+{
+ parsenode *tos;
+ for (tos = (parsenode *) csb->tokenQ->qhead; tos; tos = tos->next) {
+ printf("\nNode:\n");
+ printf("\tcommand '%s'\n", tos->nv_command);
+ printf("\tOBJ(int,1) %d OBJ(idb,1) 0x%x '%s'\n",
+ tos->val1, tos->idb1, tos->idb1 ? tos->idb1->namestring : "");
+ if (tos->val1 == PDB_OSI) {
+ printf("\tpdb1 0x%x '%s'\n", tos->pdb1,
+ tos->pdb1 ? ((clns_pdbtype *) tos->pdb1)->name : "");
+ } else {
+ printf("\tpdb1 0x%x '%s'\n", tos->pdb1,
+ tos->pdb1 ? ((pdbtype *) tos->pdb1)->name : "");
+ }
+ }
+}
+#endif /* DEBUG_PARSER */
+#endif /* IOS_PARSER */
diff --git a/data/mnet/Common/cli/src/parser_input.c b/data/mnet/Common/cli/src/parser_input.c
new file mode 100644
index 0000000..2d82d1c
--- /dev/null
+++ b/data/mnet/Common/cli/src/parser_input.c
@@ -0,0 +1,1432 @@
+#include <vxworks.h>
+#include <stdioLib.h>
+#include <tyLib.h>
+#include <taskLib.h>
+#include <errnoLib.h>
+#include <lstLib.h>
+#include <inetLib.h> /* for INET_ADDR_LEN */
+#include <timers.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <msgQLib.h>
+#include <sigLib.h>
+#include <logLib.h>
+#include <wdLib.h>
+
+
+#include <../include/pstypes.h>
+#include <../include/psvxif.h>
+#include <../include/platdef.h>
+#include <../include/ttyutil.h>
+
+#include <../include/imsg.h>
+#include <../include/imc.h>
+
+#include <../include/parsertypes.h>
+#include <../include/address.h>
+#include <../include/config.h>
+#include <../include/parser_defs_exec.h>
+#include <../include/parser_input.h>
+#include <../include/parser_sim.h>
+#include <../include/parser_util.h>
+#include <../include/parser_commands.h>
+#include <../include/nv.h>
+#include <../include/parser_ModNum.h>
+#include <../include/parser_errno.h>
+#include <../include/defs.h>
+#include <../include/parser.h>
+#include <../include/cli_parser_private.h>
+#include <../include/parser_actions.h>
+
+
+#define DEVELOPMENT
+#define ROOT_UID 0
+#define USER_UID 1
+#define INVALID_UID -1
+#define PS_TASK_NAME taskName(taskIdSelf())
+#define bool boolean
+
+/********* Global variables *********/
+static char longCmdErrMsg[] ="\nCommand too long\n";
+tpIOINFO pIoInfo = NULL;
+char taskid[50];
+boolean terminalEcho=TRUE;
+boolean doneAuth;
+
+char current_user[MAX_USERNAME_LEN];
+char current_password[MAX_PASSWD_LEN];
+
+/********* Function declarations ***********/
+void func(int fd,char* str);
+static void process_del_char (tOCTET2 );
+bool AuthenticateUser(parseinfo *csb);
+tOCTET2 getInput( tINT outfd,tINT infd, char *pPrompt, char *pInput,
+ tINT len, boolean hideInput );
+extern BOOL load_running_config;
+extern int backInFd;
+
+
+/*
+ * Write to fd in maxsz chunks. This accomodates
+ * the message oriented nature of vxWorks' pipes.
+ */
+static STATUS
+io_write_buffer(tINT fd, const char *buf, size_t sz, size_t maxsz)
+{
+ STATUS ret = OK;
+ int i;
+ ssize_t cc;
+
+ for (i = 0; i < sz; i += cc) {
+ cc = sz - i > maxsz ? maxsz : sz - i;
+
+
+ cc = write(fd, (void *)&buf[i], cc);
+
+ if (cc <= 0) {
+ ret = ERROR;
+ break;
+ }
+ }
+ return ret;
+}
+
+/*****************************************************************
+ *
+ * Func: io_process_response
+ *
+ * Desc: Wait for and process response for command request
+ *
+ * Inputs:
+ *
+ *
+ * Result: RC_OK : Command was executed successfuly
+ * RC_ERR : Error occured while processing command
+ * RC_MORE : 'more' processing required
+ *
+ * Algorithm:
+ *
+ *****************************************************************/
+static tOCTET2 io_process_response(tOCTET2 fd, tOCTET4 maxCount,tpIOINFO pIoInfo)
+{
+ tOCTET2 rc = RC_OK;
+ tpCOMSIM pComSim;
+ char buffer[256];
+ char *pOutput = NULL;
+
+ /* Wait till we get an indication of response from Parser */
+ if ( PSsemTake( pIoInfo->ioSemId, WAIT_FOREVER ) == ERROR ) {
+ PSpanic("io_process_reponse:Cannot wait on Console Semaphore\n");
+ }
+
+
+ pComSim = NULL;
+
+ /* Get the interaction for us */
+ mGET_WORK_SIM(pComSim, pIoInfo->ioModuleId );
+
+ sprintf(buffer, "%s:", taskName(taskIdSelf()));
+
+ if ( pComSim != NULL ) {
+ /* This carries any output from modules */
+ pOutput = ( char *)(pComSim->pLayerSim);
+
+ /* Check if it is Request or Indication */
+ if ( IS_INDICATION(pComSim->serviceid)) {
+ if (pComSim->requestid == pIoInfo->requestId ) {
+ rc = pComSim->status;
+
+ if ( pComSim->pLayerSim ) {
+ io_write_buffer(fd, pOutput, strlen(pOutput), BUFSIZ);
+ }
+ if ( rc == RC_WAIT ) {
+ /* Wait till we are done with More Processing
+ * or TCL Shell
+ */
+ do {
+ mFREESIM( pComSim );
+ pComSim = NULL;
+ /* Wait for indication from TCL Shell
+ * or tMore task
+ */
+ if ( PSsemTake( pIoInfo->ioSemId, WAIT_FOREVER )
+ == ERROR ) {
+ logMsg("Semaphore was deleted\n",0,0,0,0,0,0);
+ break;
+ }
+
+ mGET_WORK_SIM(pComSim, pIoInfo->ioModuleId );
+ rc = pComSim->status;
+
+ } while ( pComSim->serviceid != IO_WAIT_COMPLETE_IND);
+
+
+ /* TCL Sets the terminal to TERMINAL mode
+ * So reset the terminal characteristcs
+ */
+ ioSetTerminalMode( fd, IO_RAW_MODE );
+ }
+ } else {
+ sprintf(buffer,"io_process_response: Got %ld Expecting %ld\n",
+ pComSim->requestid, pIoInfo->requestId );
+ write( fd, buffer, strlen( buffer ) );
+ }
+
+ } else if (IS_REQUEST(pComSim->serviceid)) {
+ /* Who will send a request to us via IMC ? */
+ strcat(buffer, " I/O Task cannot process request!\n" );
+ write(fd, buffer, strlen(buffer));
+ } else {
+ /* What kind of service is this ? */
+ strcat(buffer, " io_process_response : Invalid Service Id\n");
+ write(fd, buffer, strlen(buffer));
+ }
+ /* Done.. See ya */
+ if ( pComSim )
+ mFREESIM( pComSim );
+
+ } else {
+ /* Hmm..We get an indication but a NULL SIM ? */
+ strcat(buffer, " io_process_response : NULL SIM from GETWORK\n");
+ write(fd, buffer, strlen(buffer));
+ }
+
+ return ( rc );
+}
+/*****************************************************************
+ *
+ * Func: io_send_request
+ *
+ * Desc: Send a request to execute command to parser
+ *
+ * Inputs:
+ * line : Command to be executed
+ * lastchar : is last char '?', '\t', '\n';
+ * index : cookie for 'more' processing
+ * maxCount : Maximum lines to be displayed
+ *
+ * Result: None
+ *
+ * Algorithm:
+ *
+ *****************************************************************/
+static void io_send_request(char *line, char lastchar, void *index,
+ tOCTET4 maxCount,tpIOINFO pIoInfo )
+{
+ tOCTET2 rc = RC_OK;
+ tpPARSERSIM pSim = NULL;
+ int uid;
+ parseinfo *csb = pIoInfo->csb;
+
+ /* Get the interaction module for parser */
+ pSim = (tpPARSERSIM ) mGETSIM( sizeof( tPARSERSIM ) );
+ if ( csb == NULL ) {
+ PSpanic("Error occurred while sending Request !\n");
+ }
+
+ if ( !pSim ) {
+ PSpanic("No Memory to allocate SIM\n");
+ }
+
+ /* NULL Command */
+ if ( !line ) {
+ printf("NULL Command sent as request\n");
+ }
+
+ /* Keep track of request */
+ ++(pIoInfo->requestId);
+
+ /* User Id on whose context to run */
+ uid = csb->uid;
+
+ /* Fill parser interaction module */
+ mFILL_PARSER_SIM(pSim, csb, pIoInfo->ioModuleId, \
+ PARSER_MODULE, PARSER_CMD_PROC_REQ, pIoInfo->requestId, \
+ line, lastchar, index, maxCount );
+
+ /* Send it to parser */
+ mPOST_SIM_NREQ(((tpCOMSIM)pSim), rc );
+
+ if ( rc != RC_OK ) {
+ printf("Error occured while processing cosole_send_request\n");
+ }
+
+}
+/*****************************************************************
+ *
+ * Func: io_reset_cmdline
+ *
+ * Desc: Erase the previously entered command
+ *
+ * Inputs:
+ * fd : Output file descriptor
+ * currentPos : Current Cursor Position
+ * line : Current Command entered
+ * delPos : Cursor position to delete from
+ *
+ * Result: None
+ *
+ * Algorithm:
+ *
+ *****************************************************************/
+static void io_reset_cmdline( tINT fd, tINT currentPos, tpOCTET line,
+ tINT delPos)
+{
+ tINT index = 0;
+
+ /* Go back to the end of the entered command... */
+ for(index = currentPos ;
+ index < strlen(line); index++ ){
+ if ( line[index] != '\0' ) {
+ write(fd, &line[index], 1);
+ } else
+ break;
+ }
+
+ /* ...And erase the entire command */
+ for( index = delPos; index < strlen(line); index++)
+ process_del_char( fd );
+
+}
+
+/*****************************************************************
+ *
+ * Func: process_special_char
+ *
+ * Desc: Process special characters for parser
+ *
+ * Inputs:
+ * csb : CSB for the source
+ * ch : Character to be checked
+ * line : Input string so far
+ * historyIndex : Pointer to History Index
+ * currentIndex : Current History Index
+ * currentPos : Current Cursor Position
+ *
+ * Result: RC_OK : To echo and continue processing
+ * RC_CONT : do not echo; go back and read input
+ * Algorithm:
+ *
+ *****************************************************************/
+static tOCTET2 process_special_char( parseinfo *csb, char *ch, char *line,
+ tINT *historyIndex, tINT currentIndex,
+ tINT *currentPos ,tpIOINFO pIoInfo)
+{
+ tOCTET2 status = RC_OK;
+ char chr[PARSEBUF + 1];
+ int index = 0;
+ char *pCmd = NULL;
+ char ich = 0;
+ boolean ringBell = TRUE;
+
+ tpOCTET *history = NULL;
+
+ extern parser_mode *interface_mode;
+
+ if ( line == NULL )
+ return(RC_CONT);
+
+ /* Point to the correct 'history' array */
+ if ((csb->mode == config_mode) ||
+ (csb->mode == interface_mode))
+ history = pIoInfo->configHistory;
+ else
+ history = pIoInfo->execHistory;
+
+ /* Following is the methodology used to handle arrow keys etc.
+ *
+ * historyIndex points to the previous command to be displayed
+ * currentIndex is the index where the most recently entered command
+ * will be stored.
+ * currentPos points to the current cursor position
+ *
+ * Upon an arrow key ( Detected using 'ESC+[' ( or 'ESC+O' for MSFT ?)
+ *
+ * UP : Display the history pointed to by historyIndex, and update it
+ * Clear the previously entered command and re-write the new one
+ * DOWN : Update the historyIndex to point to next command, clear the
+ * previously entered command,
+ * LEFT : Write a back-space and update the cursor position
+ * RIGHT : Echo back character in the next cursor position & update the
+ * cursor position
+ */
+
+ switch (*ch ) {
+
+ /* Typically 'Arrow' keys have the encoding as follows
+ * UP-ARROW <ESC>[A
+ * DOWN-ARROW <ESC>[B
+ * LEFT-ARROW <ESC>[C
+ * RIGHT-ARROW <ESC>[D
+ *
+ * Read to see if <ESC> is followed by '[' or else put it back
+ */
+ case CH_ESC:
+ status = RC_CONT;
+ if ( stdin ) {
+ /* Somehow Microsoft Telnet Clients send ESC + O instead
+ * of ESC + [
+ */ read(csb->inFd,&ich,1);
+ if ( ( ich ) == CH_LT_SQ_BRACE ||
+ ( ich == 'O') ) {
+
+ index = *historyIndex;
+ read(csb->inFd,&ich,1);
+ switch( ich ) {
+ case 'A': /* UP Arrow */
+
+ /* Get the next Index */
+ index = (index + MAX_HISTORY - 1) % MAX_HISTORY;
+
+ /* Display most recently entered command*/
+ pCmd = history[*historyIndex];
+
+ if ( line && pCmd && *pCmd) {
+
+ if (*(history[index]) != '\0' ) {
+ *historyIndex = index;
+ }
+
+ ringBell = FALSE;
+
+ /* Reset the command previously entered */
+ io_reset_cmdline(csb->outFd, *currentPos, line, 0);
+
+ /* Rewrite the command from history */
+ strcpy(line, pCmd );
+ write(csb->outFd, pCmd, strlen(pCmd));
+
+ /* Update the current cursor position */
+ if ( currentPos )
+ *currentPos = strlen(line);
+
+ }
+ break;
+
+ case 'B': /* DOWN Arrow */
+ index = ( index + 1 ) % MAX_HISTORY;
+
+ if (*(history[index]) != '\0' ) {
+ *historyIndex = index;
+ pCmd = history[*historyIndex];
+ }
+
+ /* Reset the command previously entered */
+ io_reset_cmdline(csb->outFd, *currentPos, line, 0);
+
+ if ( line && pCmd && *pCmd) {
+ ringBell = FALSE;
+
+ /* Rewrite the command from history */
+ strcpy(line, pCmd );
+ write(csb->outFd, pCmd, strlen(pCmd));
+
+ if ( currentPos )
+ *currentPos = strlen(line);
+ } else {
+ ringBell = TRUE;
+
+ strcpy(line, "" );
+ if ( currentPos )
+ *currentPos = 0;
+ }
+ break;
+
+ case 'C':
+
+ if ( line && *line && currentPos &&
+ (*currentPos < strlen(line)) ) {
+ ringBell = FALSE;
+
+ /* Echo back the current character */
+ chr[0] = line[*currentPos];
+ chr[1] = '\0';
+ ++(*currentPos);
+ write( csb->outFd, chr, 1 );
+ }
+ break;
+
+ case 'D':
+ if ( line && *line && currentPos &&
+ (*currentPos != 0) ) {
+ chr[0] = CH_BS;
+ chr[1] = '\0';
+
+ --(*currentPos);
+
+ /* Write a 'BACKSPACE' */
+ write( csb->outFd, chr, 1 );
+ ringBell = FALSE;
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+ }
+ break;
+
+ /* Backspace & DEL characters */
+ case CH_BS :
+ case CH_DEL:
+
+ if ( currentPos && *currentPos > 0 && strlen(line) > 0 ) {
+
+ io_reset_cmdline(csb->outFd, *currentPos, line,
+ (*currentPos - 1 ) );
+
+ /* Get the buffer from current position till end */
+ strncpy( chr, &(line[*currentPos]), PARSEBUF - 1);
+ chr[PARSEBUF] = '\0';
+
+ /* Now that we have erased old command after cursor
+ * position, rewrite the updated part of command from
+ * next to cursor till end
+ */
+ write(csb->outFd, chr, strlen(chr));
+
+ /* Update the command buffer */
+ strncpy( &(line[*currentPos - 1]), chr, (PARSEBUF - *currentPos));
+ line[PARSEBUF] = '\0';
+ (*currentPos)--;
+
+ chr[0] = CH_BS;
+ chr[1] = '\0';
+
+ /* Move the cursor position to the new place */
+ for ( index = strlen(line); index > *currentPos; index-- ){
+ write(csb->outFd, chr, 1);
+ }
+ ringBell = FALSE;
+ }
+ status = RC_CONT;
+
+ break;
+
+
+ default:
+
+ ich = *ch;
+
+ /* We are Ok with '\t', '\n' etc... */
+ /* if ( !(isspace( ich ) )) {
+
+ if ( iscntrl( ich ) ) {
+ if ( ich == CH_EXT )
+ read(csb->inFd, chr, 2 );
+ status = RC_CONT;
+ } else if ( !isprint( ich ) ) {
+
+
+ status = RC_CONT;
+ }
+ }
+ ringBell = FALSE;*/
+
+ if ( currentPos )
+ (*currentPos)++;
+
+ break;
+ }
+
+ /* Beep if the entered key is other than backspace
+ * and go back and read input
+ */
+ /* if ( ringBell ) {
+ ch = CH_BEL;
+ write(csb->outFd,&ch,1);
+ }*/
+ return ( status );
+}
+
+
+
+/*****************************************************************
+ *
+ * Func: process_del_char
+ *
+ * Desc: Actions for backspace/delete key
+ *
+ * Inputs:
+ * ioFd : fd to read from and write to
+ *
+ * Result: None
+ *
+ * Algorithm:
+ *
+ *****************************************************************/
+static void process_del_char( tOCTET2 ioFd )
+{
+ char ch;
+
+ /* When Backspace / Delete entered
+ * the character displayed already
+ * has to be erased too
+ * BS/DEL = <BS> <SPC> <BS>
+ */
+ ch = CH_BS;
+ write(ioFd,&ch,1);
+
+ ch = CH_SPC;
+ write(ioFd,&ch,1);
+
+ ch = CH_BS;
+ write(ioFd,&ch,1);
+
+}
+
+extern void ParserCallbackInit(void);
+/*****************************************************************
+ *
+ * Func: parser_io_init
+ *
+ * Desc: Initialize CSB etc for I/O task
+ *
+ * Inputs: None
+ *
+ * Result: None
+ *
+ * Algorithm:
+ *
+ *****************************************************************/
+static void parser_io_init(tpIOINFO pIoInfo )
+{
+ parseinfo *csb = NULL;
+ tpCOMSIM pComSim = NULL;
+ int callbackTaskID;
+ int index=0;
+ /* Let IMC Know that a module id be assigned */
+ pIoInfo->ioModuleId = ASSIGN_MODULE_ID;
+ pIoInfo->requestId=0;
+ /* Semaphore that will indicate presence of message */
+ pIoInfo->ioSemId = PSsemCCreate( PS_DEFAULT_COUNT_SEM_FLAG , 0 );
+
+ /* Add to IMC */
+ if ( imc_add( &(pIoInfo->ioModuleId), pIoInfo->ioSemId,
+ taskIdSelf() == RC_ERR ) ) {
+ PSpanic("Could not create IMC for IO Task!\n");
+ }
+
+ /* Did IMC return valid module Id ? */
+ if ( pIoInfo->ioModuleId < 0 ) {
+ printf("parser_io_init:Negative Module Id\n");
+ }
+ else {
+
+ /* Get CSB to interact with Parser */
+ csb = pIoInfo->csb = get_csb(PS_TASK_NAME);
+
+ if ( !csb )
+ printf("parser_io_init: Unable to obtain CSB\n");
+
+ /* Set some CSB Flags */
+ csb->flags = CONFIG_TERM;
+ csb->priv = DEFAULT_PRIV;
+ *(csb->line) = '\0';
+
+ }
+ do{
+ mGET_WORK_SIM(pComSim, pIoInfo->ioModuleId );
+ }while(pComSim != NULL);
+}
+
+
+
+/* BuildPrompt
+ * Build promt at csb->prompt.
+ * This routine is global as it is used by SNA network management
+ */
+void BuildPrompt (parseinfo *csb, tt_soc *tty)
+{
+ int prompt_length; /* leftover length of prompt */
+
+ char Pprompt[MAXPROMPTLEN + 1];
+
+
+ gethostname(Pprompt,MAXPROMPTLEN);
+ Pprompt[MAXPROMPTLEN] = '\0';
+
+
+
+ /* Build the prompt. */
+ if (config_prompt || (csb->mode == exec_mode) ||
+ !(csb->flags & CONFIG_TERM)) {
+ const char *src;
+ char *dst, trailer;
+
+ trailer = (csb->priv > PRIV_USER) ? '#' : '>';
+ dst = csb->prompt;
+ src = Pprompt;
+ prompt_length = MAXPROMPTLEN;
+ while (*src && prompt_length--) {
+ *dst++ = *src++;
+ }
+
+ /* dst += reg_invoke_parse_cli_prompt(tty->parse_cli_type,
+ csb, dst, &prompt_length);
+ */
+ src = get_mode_prompt(csb);
+ if (src && (prompt_length > 3)) {
+ prompt_length -= 3;
+ *dst++ = '(';
+ while (*src && prompt_length--) {
+ *dst++ = *src++;
+ }
+ *dst++ = ')';
+ } else {
+ /*
+ * Prompt is too long, so cut off end
+ */
+ if (prompt_length <= 0) {
+ dst = &csb->prompt[MAXPROMPTLEN-1];
+ }
+ }
+ *dst++ = trailer;
+ *dst = '\0';
+ } else {
+ csb->prompt[0] = '\0';
+ }
+}
+/*****************************************************************
+ *
+ * Func: io_cleanup
+ *
+ * Desc: Cleanup the I/O Task
+ *
+ * Inputs: tpIOINFO
+ *
+ * Result: None
+ *
+ * Algorithm:
+ *
+ *****************************************************************/
+
+ void io_cleanup( int TaskID)
+{
+
+ parseinfo *csb = NULL;
+ int index = 0 ;
+
+
+ if ( pIoInfo == NULL ){
+ return;
+ }
+
+ csb = pIoInfo->csb;
+ if ( csb == NULL ){
+
+ return;
+ }
+ free_csb(&csb);
+
+ /* Delete all associated semaphores */
+ if ( PSsemDelete( pIoInfo->ioSemId ) == ERROR ) {
+ printf("ioWork: Cannot delete semaphore\n");
+ }
+ /* Close socket for telnet connections
+ if ( (pIoInfo->sockFd > 0) &&
+ (iosFdValue (pIoInfo->sockFd) != ERROR)) {
+ close ( pIoInfo->sockFd );
+ }*/
+
+
+
+
+ /* Delete History Array */
+ for( index = 0; index < MAX_HISTORY; index++ ) {
+ /* Exec Level History */
+ if ( pIoInfo->execHistory[index] )
+ PARSERfree( pIoInfo->execHistory[index] );
+
+ /* Config Level History */
+ if ( pIoInfo->configHistory[index] )
+ PARSERfree( pIoInfo->configHistory[index] );
+ }
+
+
+ /* Remove yourself from IMC */
+ if ( imc_remove( pIoInfo->ioModuleId ) != RC_OK ) {
+ printf("ioWork: Cannot delete Module from IMC\n");
+ }
+ cleanupWorkerTask();
+ PARSERfree( pIoInfo );
+
+ pIoInfo=NULL;
+
+
+
+}
+
+void getPrompt( parseinfo *csb, char* prompt, char *complete )
+{
+ if ( csb != NULL ) {
+ BuildPrompt( csb, NULLTTY );
+
+ strncpy(prompt, csb->prompt, MAXPROMPTLEN);
+ prompt[MAXPROMPTLEN] = EOS;
+
+ strncpy(complete, csb->line, PARSEBUF);
+ complete[PARSEBUF] = EOS ;
+ }
+ else {
+ panic("NULL CSB Obtained in getPrompt\n");
+ }
+}
+/*****************************************************************
+ *
+ * Func: io_work
+ *
+ * Desc: Task Entry point for shell
+ *
+ * Inputs:
+ * inFd : File descriptor to read from
+ outFd : File descriptor to write to
+ * errFd : File descriptor for standard error
+ * interactive :True for console & telnet , False for startup script
+ *
+ * Result: None
+ *
+ * Algorithm:
+ * forever {
+ * Display prompt;
+ * Read a character at a time
+ * Send request to parser either if \n, ?, \t,ctrl-z
+ * Wait for response
+ * }
+ *
+ **********************************************************************/
+
+void io_work( tINT inFd ,
+ tINT outFd,
+ tINT errFd,
+ boolean interactive /*** True for console & telnet , False for script **/
+ )
+{
+
+
+ char line[PARSEBUF + 1];
+ char complete[PARSEBUF + 1];
+ char chr[PARSEBUF + 1];
+ char prompt[MAXPROMPTLEN + 1];
+ char lastchar;
+ char ch ;
+ void *pIndex;
+ parseinfo *csb;
+ parser_mode *prevMode ;
+ extern parser_mode *interface_mode;
+
+ tOCTET2 rc ;
+ tINT execIndex ;
+ tINT configIndex ;
+ tINT index ;
+
+ tpOCTET *currentHistory ;
+
+ tINT *historyIndex;
+ tINT currentIndex ;
+ tINT currentPos ;
+
+ restart:
+ ch = '\0';
+ pIndex = NULL;
+ prevMode = NULL;
+ rc = RC_OK;
+ execIndex = 0;
+ configIndex = 0;
+ index = 0;
+ currentHistory = NULL;
+ historyIndex = &execIndex;
+ currentIndex = 0;
+ currentPos = 0;
+
+ /* Check if we have valid fd's */
+
+ if ( outFd <= 0 || inFd < 0 || errFd < 0) {
+ PSpanic("Invalid fd for I/O Task\n");
+ }
+
+ doneAuth = FALSE;
+
+
+ /*****Allocate memory for pIoInfo *******/
+ if ( (pIoInfo = (tpIOINFO)
+ PARSERcalloc(1, sizeof( tIOINFO))) == NULL ) {
+ PSpanic("ioWork: No memory to allocate IO Info\n");
+ }
+
+ /* Create the history array for Exec & Config Modes */
+ for (index = 0; index < MAX_HISTORY; index++ ) {
+ pIoInfo->execHistory[index] =
+ (tpOCTET) malloc(( sizeof(tOCTET) * (PARSEBUF+1)) );
+ strcpy(pIoInfo->execHistory[index], "");
+
+ pIoInfo->configHistory[index] =
+ (tpOCTET)malloc(( sizeof(tOCTET) * (PARSEBUF+1)));
+ strcpy(pIoInfo->configHistory[index], "");
+ }
+
+ /* This creates the CSB, adds to IMC etc */
+ parser_io_init(pIoInfo);
+
+ /***********/
+
+
+ /* Get CSB to with parser */
+ csb = pIoInfo->csb;
+
+ if (interactive){
+ csb->uid=USER_UID;
+ csb->priv=PRIV_MIN;
+ }else{
+ csb->uid=ROOT_UID;
+ csb->priv=PRIV_ROOT;
+ doneAuth=TRUE;
+ }
+
+ /* CSB may not need inFd & outFd ; But ... */
+ if(interactive){
+ csb->inFd =infd;
+ csb->outFd =outfd;
+ }else{
+ csb->inFd =inFd;
+ csb->outFd =outFd;
+ }
+ /* For More processing cookie.. */
+ csb->pIndex = NULL;
+
+
+ /* For Task level CWD */
+ csb->ioTaskId = taskIdSelf();
+
+ /* Whats my Module Id ? */
+ csb->moduleId = pIoInfo->ioModuleId;
+
+
+ line[0] = lastchar = '\0';
+
+ /* We will be in RAW Mode so that we can read a character
+ * at a time and we will do the ECHO
+ */
+ ioSetTerminalMode( csb->inFd, IO_RAW_MODE );
+
+ ioTaskStdSet( 0, STD_IN, csb->inFd );
+ ioTaskStdSet( 0, STD_OUT, csb->outFd );
+ ioTaskStdSet( 0, STD_ERR, csb->outFd );
+
+
+ ioGlobalStdSet( STD_IN, csb->inFd );
+ ioGlobalStdSet( STD_OUT, csb->outFd );
+ ioGlobalStdSet( STD_ERR, csb->outFd );
+
+ while( 1 ) {
+ pIoInfo->flags = 0;
+
+ ioSetTerminalMode( csb->inFd, IO_RAW_MODE );
+
+ /************ Authenticate User ********************************/
+ if ( doneAuth == FALSE ) {
+ if(!AuthenticateUser(csb)){extern isLoggedOut;
+ csb->uid=ROOT_UID;
+ csb->priv=PRIV_ROOT;
+ if(isLoggedOut==TRUE){
+ isLoggedOut=FALSE;
+ goto cleanup;
+ }
+ strcpy(line,"exit");
+ goto CommandInput;
+
+ }
+
+ doneAuth=TRUE;
+ }
+ /***************************************************/
+
+ prompt[0] = '\0';
+ complete[0] = '\0';
+ getPrompt(csb,prompt, complete );
+
+
+ /* The user did not enter \n last time; and so
+ * we may not have echoed it.. So put \n
+ */
+ if ( lastchar == '\t')
+ write(csb->outFd,"\n",1);
+
+ write( csb->outFd,prompt, strlen(prompt) );
+
+ /* If it is command completion, display the
+ * the completed command or it is help
+ * display previously entered string
+ */
+
+ if ( *complete ) {
+ strcpy( line, complete );
+ write( csb->outFd, complete, strlen(complete));
+ }else {
+ strcpy(line,"\0");
+ }
+
+ /* Reset 'more' cookie */
+ pIndex = csb->pIndex = NULL;
+
+ /* Current Cursor Position */
+ currentPos = strlen(line);
+
+ while (1) {
+
+ ch = '\0';
+ ioSetTerminalMode( csb->inFd, IO_RAW_MODE );
+
+ /* Read one character from fd */
+ if ( read(csb->inFd, &ch, 1 ) <= 0 ) {
+ if(load_running_config){
+ load_running_config=FALSE;
+ csb->mode=exec_mode;
+ csb->inFd=backInFd;
+ }else
+ goto cleanup;
+ }
+
+ /*
+ * Just in case...
+ */
+ if ( ch == '\0' )
+ break;
+
+ rc = process_special_char(csb, &ch, line, historyIndex,
+ currentIndex, &currentPos,pIoInfo );
+ /* Go back and read the input */
+ if ( rc == RC_CONT )
+ continue;
+
+ /* Used for 'strcat' to line */
+ chr[0] = ch;
+ chr[1] = '\0';
+ if( ch == CH_CTRL_Z ){
+ strcpy(line,"disable");
+ goto CommandInput;
+ }
+ if ( ch == '\t' || ch == '?' || ch == '\n'){
+ write(csb->outFd, &ch, sizeof(char));
+ lastchar = ch;
+ break;
+ } else {
+
+ io_reset_cmdline(csb->outFd, currentPos, line,
+ currentPos );
+
+ if ( strlen(line) > 0 ) {
+ /* Get the buffer from current position till end */
+ strncat(chr, &(line[currentPos - 1]), PARSEBUF);
+ chr[PARSEBUF] = EOS;
+ }
+
+ /* Now that we have erased old command after cursor
+ * position, rewrite the updated part of command from
+ * next to cursor till end
+ */
+ write(csb->outFd, chr, strlen(chr));
+
+ /* Build the command to be executed
+ * Make sure we take into account that the 'arrow'
+ * keys may have been used and so replace the right
+ * character in the 'line'
+ */
+ if ((currentPos + strlen(chr)) < PARSEBUF){
+
+ strncpy(&(line[currentPos - 1]), chr, (PARSEBUF-currentPos));
+ line[PARSEBUF] = EOS;
+ } else {
+ /* Make sure that the command does not exceed
+ * the maximum length
+ */
+ write(csb->outFd, longCmdErrMsg, strlen(longCmdErrMsg) );
+ line[PARSEBUF] = EOS;
+ goto process_next_command;
+ }
+
+ chr[0] = CH_BS;
+ chr[1] = '\0';
+
+ /* Move the cursor position to the new place */
+ for ( index = strlen(line); index > currentPos; index-- ){
+ write(csb->outFd, chr, 1);
+ }
+
+ }
+
+ } /* end while */
+
+
+
+ /* Update the 'more' cookie */
+ pIndex = csb->pIndex;
+ /* Store the mode the command was issued */
+
+ prevMode = csb->mode;
+
+ /* Send the request to parser */
+ CommandInput:
+
+ io_send_request(line, lastchar, NULL, 0,pIoInfo);
+ /* Wait for the response from the parser */
+ io_process_response(csb->outFd, 0,pIoInfo);
+ /* store_history: */
+ /* Update the correct History Array. We have config
+ * mode history and exec mode history arrays
+ */
+ if ( prevMode == config_mode )
+ currentHistory = pIoInfo->configHistory;
+ else
+ currentHistory = pIoInfo->execHistory;
+
+
+ if ( !currentHistory )
+ PSpanic("NULL History pointer in I/O Task\n");
+
+ /* This flag is set *ONLY* if the command entered
+ * is *NOT* for command completion
+ */
+ if ( csb->flags & COMMAND_COMPLETE ) {
+ /* Update the current history and make it point to
+ * right index
+ *
+ * currentIndex always is the index where the most
+ * recently entered command will be stored
+ * historyIndex is the index where we are at by using
+ * arrow keys etc. This will be set by process_special_char
+ * routine
+ */
+ if ( *line ) {
+ strncpy(currentHistory[currentIndex], line, PARSEBUF);
+ currentHistory[currentIndex][PARSEBUF]=EOS;
+ *historyIndex = currentIndex;
+ currentIndex = (currentIndex + 1) % (MAX_HISTORY );
+ }
+
+ /* Make sure we update the correct history index
+ * in each mode
+ */
+ historyIndex = ( csb->mode == exec_mode )
+ ? &execIndex
+ : &configIndex;
+
+
+ /* There has been a mode change ? Lets revert back to
+ * what the mode history index was previously
+ */
+ if ( prevMode != csb->mode )
+ currentIndex = ((*historyIndex) + 1) % (MAX_HISTORY);
+
+ csb->flags &= ~COMMAND_COMPLETE;
+
+ }
+ process_next_command:
+
+ } /* end while */
+ cleanup:
+ io_cleanup( taskIdSelf() );
+
+
+
+
+}
+
+
+/*
+ * parser_spawn - create a parser task and wait for it to finish
+ */
+int CliIOInit (int inFd,int outFd,int errFd,boolean interactive)
+{
+ int ret = 0;
+ int tid;
+ char tname[20];
+ static int name=0;
+ int ttymode;
+
+ ttymode = ioctl(inFd, FIOGETOPTIONS, 0);
+
+ /* sprintf(tname, "tCli%d", name++);*/
+ sprintf(tname, "tCli");
+
+ /***** Creates shell task for console and telnet session **********/
+ tid = taskSpawn(tname, PARSER_TASK_PRIORITY, 0, PARSER_TASK_STACK_SIZE,
+ (FUNCPTR)io_work,
+ inFd,
+ outFd,
+ errFd,
+ interactive,
+ 0,
+ 0,0,0,0,0);
+
+ ret=tid;
+ ioctl(inFd, FIOSETOPTIONS, ttymode);
+ return ret;
+}
+
+
+/*****************************************************************
+ *
+ * Func: ioSetTerminalMode
+ *
+ * Desc: Set the terminal mode
+ *
+ * Inputs:
+ * fd : File descriptor of the terminal
+ * termMode : RAW / TERMINAL ( enums )
+ *c
+ * Result: Current Terminal Options
+ * ERROR on Error
+ *
+ * Algorithm:
+ *
+ *****************************************************************/
+tINT ioSetTerminalMode( int fd, tTERMINALMODE termMode )
+{
+
+
+ switch( termMode ) {
+
+ /* RAW Terminal Mode */
+ case IO_RAW_MODE:
+ if (fd == consoleFd)
+ {
+ if ( ioctl (fd, FIOSETOPTIONS, OPT_RAW | OPT_CRMOD |
+ OPT_7_BIT | OPT_MON_TRAP )
+ == ERROR ) {
+ return( ERROR ) ;
+ }
+ }
+ else
+ {
+ if ( ioctl (fd, FIOSETOPTIONS, OPT_RAW | OPT_CRMOD |
+ OPT_7_BIT)
+ == ERROR ) {
+ return( ERROR ) ;
+ }
+ }
+ break;
+
+ case IO_LINE_MODE:
+ if (fd == consoleFd)
+ {
+ if ( ioctl( fd, FIOSETOPTIONS, OPT_TERMINAL ) == ERROR ) {
+ return ( ERROR );
+ }
+ }
+ else
+ {
+ if ( ioctl (fd, FIOSETOPTIONS, OPT_ECHO | OPT_CRMOD | OPT_TANDEM |
+ OPT_7_BIT | OPT_ABORT | OPT_LINE)
+ == ERROR) {
+ return (ERROR);
+ }
+ }
+ break;
+
+ case IO_ECHO_MODE:
+ if (fd == consoleFd)
+ {
+ if ( ioctl( fd, FIOSETOPTIONS,
+ OPT_ECHO | OPT_CRMOD | OPT_7_BIT | OPT_MON_TRAP )
+ == ERROR ) {
+ return ( ERROR );
+ }
+ }
+ else
+ {
+ if ( ioctl( fd, FIOSETOPTIONS,
+ OPT_ECHO | OPT_CRMOD | OPT_7_BIT) == ERROR ) {
+ return ( ERROR );
+ }
+ }
+ break;
+ default:
+ return( ERROR );
+ }
+
+ return(ioctl( fd, FIOGETOPTIONS, 0 ));
+}
+
+/************* Authentication function *************/
+
+bool AuthenticateUser(parseinfo *csb){
+
+char usrPrompt[] ="Username: ";
+char passwdPrompt[] = "Password: ";
+char usrName[MAX_USERNAME_LEN] = "";
+char passwd[256] = "";
+char confirm_password[256]="";
+int retries=6;
+bool rc = FALSE;
+
+
+
+ if(defaultUserInUse == TRUE){
+ printf("\nSystem is being booted for the first time\n\n");
+ printf("PASSWORD FOR THE DEFAULT USER(user) NOT SET\n");
+ printf("Please enter the password for default user,\"user\".\n");
+ printf("Password length should be atleast 8 characters\n");
+
+ if(getInput( STD_OUT,STD_IN,"password :", passwd, 127, TRUE )==FALSE){
+ printf("Could not read password \n");
+ return FALSE;
+ }
+ if(getInput( STD_OUT,STD_IN,"\nconfirm password :", confirm_password, 127, TRUE )==FALSE){
+ printf("Could not read password \n");
+ return FALSE;
+ }
+ if(strcmp(passwd,confirm_password)!=0)
+ {
+ printf("\nPasswords do not match\n");
+ return FALSE;
+ }
+ if(sysUserAdd("user",(char*)passwd,0)==OK){
+ defaultUserInUse=FALSE;
+ printf("\nAdded user successfully\n");
+ strcpy(current_user,"user");
+ strcpy(current_password,passwd);
+ csb->uid=0;
+ csb->priv=PRIV_MIN;
+ return TRUE;
+ }else{
+ printf("\nUser could not be added\n");
+ return FALSE;
+ }
+
+ }
+
+ if( ShellTask == SSHTask)
+ return TRUE;
+
+ while ( retries-- > 0 ) {
+
+ if ( write( csb->outFd, "\n", 1 ) < 0 )
+ return ( FALSE );
+
+ /* Don't prompt for password unless the user enters
+ * something
+ */
+ while( strcmp(usrName, "") == 0 ) {
+ rc = getInput( csb->outFd,csb->inFd,usrPrompt, usrName, MAX_USERNAME_LEN, FALSE );
+ if ( rc == FALSE )
+ return ( FALSE );
+ }
+
+ /* Prompt for password */
+ rc = getInput( csb->outFd,csb->inFd,passwdPrompt, passwd, MAX_PASSWD_LEN, TRUE );
+
+ if ( ( rc == FALSE ) ||
+ ( write( csb->outFd, "\n", 1 ) <= 0 ) )
+ return ( FALSE );
+
+
+ /* set remote IP address to display user's settings */
+
+
+
+ if((csb->uid=sysUserVerify(usrName,passwd))<0){
+ write(csb->outFd,"Login incorrect",strlen("Login incorrect"));
+ rc=FALSE;
+ }else{
+ strcpy(current_user,usrName);
+ strcpy(current_password,passwd);
+ rc=TRUE;
+ break;
+ }
+
+ csb->priv = (csb->uid==ROOT_UID)
+ ? PRIV_MIN
+ : PRIV_MIN;
+
+ strcpy(usrName, "");
+ strcpy(passwd, "");
+
+
+ } /* while retries*/
+
+ return rc;
+
+}
+
+
+/*****************************************************************
+ *
+ * Func: getInput
+ *
+ * Desc: Display specified prompt and get input
+ *
+ * Inputs:
+ * infd : fd to read from
+ outfd :fd to write to
+ * pPrompt : Prompt to be displayed
+ * pInput : Fill the entered input
+ * len : Maximum length of input
+ * hideInput : Echo input back ?
+ *
+ * Result: TRUE : If input was successful
+ * FALSE: otherwise
+ *
+ * Algorithm:
+ *
+ *****************************************************************/
+tOCTET2 getInput( tINT outfd,tINT infd, char *pPrompt, char *pInput,
+ tINT len, boolean hideInput )
+{
+ tOCTET2 rc = TRUE;
+ tINT nbytes =0;
+ int ttymode;
+
+ /* No way .. */
+ if ( !pPrompt || !pInput ) {
+ return ( FALSE );
+ }
+
+ /* Well just in case ? */
+ if (write (outfd, pPrompt, strlen(pPrompt)) != strlen( pPrompt) ){
+ return( FALSE) ;
+ }
+
+ /* Wait till '\n' is entered */
+ ttymode = ioSetTerminalMode( outfd, IO_LINE_MODE );
+
+ /* Do not echo if not required */
+ if ( hideInput ) {
+ /* terminalEcho=FALSE;*/
+ ( void ) ioctl(outfd, FIOSETOPTIONS, (ttymode & ~OPT_ECHO));
+ }
+
+ /* Read maximum specified characters or new-line */
+ if ( (nbytes = read(infd, pInput, len - 1) ) <= 0 ) {
+ rc = FALSE;
+ } else {
+ pInput[nbytes-1] = '\0';
+ }
+ /* Reset terminal characteristics */
+ ioSetTerminalMode( outfd, IO_RAW_MODE );
+ terminalEcho=TRUE;
+ return ( rc );
+
+}
+/*****************************************************************
+ *
+ * Func: cancelIO
+ *
+ * Desc: Cancel the pending I/O operation on a fd
+ *
+ * Inputs:
+ * fd : I/O file descriptor
+ *
+ * Result: None
+ *
+ * Algorithm: Used by the Watchdog timer.
+ *
+ *****************************************************************/
+ void cancelIO( tINT fd )
+{
+ ioctl(fd, FIOCANCEL, 0 );
+}
+
+
diff --git a/data/mnet/Common/cli/src/parser_modes.c b/data/mnet/Common/cli/src/parser_modes.c
new file mode 100644
index 0000000..6b14552
--- /dev/null
+++ b/data/mnet/Common/cli/src/parser_modes.c
@@ -0,0 +1,534 @@
+#include <vxworks.h>
+#include <stdioLib.h>
+#include <tyLib.h>
+#include <taskLib.h>
+#include <errnoLib.h>
+#include <lstLib.h>
+#include <inetLib.h> /* for INET_ADDR_LEN */
+#include <timers.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <msgQLib.h>
+#include <sigLib.h>
+
+
+#include <../include/cli_parser_private.h>
+#include <../include/pstypes.h>
+#include <../include/psvxif.h>
+#include <../include/imsg.h>
+#include <../include/imc.h>
+#include <../include/address.h>
+#include <../include/parsertypes.h>
+#include <../include/config.h>
+#include <../include/parser_sim.h>
+#include <../include/parser.h>
+#include <../include/parser_defs_exec.h>
+#include <../include/parser_input.h>
+#include <../include/parser_sim.h>
+#include <../include/parser_util.h>
+#include <../include/parser_commands.h>
+#include <../include/nv.h>
+#include <../include/parser_errno.h>
+#include <../include/parser_ModNum.h>
+#include <../include/defs.h>
+#include <../include/parser_init.h>
+#include <../include/macros.h>
+#include <../include/parser_actions.h>
+#include <../include/parser_modes.h>
+
+
+
+/*
+ * Local structure definitions
+ */
+struct parser_mode_ {
+ struct parser_mode_ *next;
+ const char *name;
+ const char *prompt;
+ const char *help;
+ const char *alt_mode;
+ mode_save_var_func save_vars;
+ mode_reset_var_func reset_vars;
+ mode_http_init_func http_init;
+ uint flags;
+ transition *top;
+
+#ifdef INCLUDE_PARSER_ALIAS
+ queuetype *aliases;
+ queuetype *def_aliases;
+#endif
+ boolean priv_changed;
+};
+
+static queuetype parser_modes_queue;
+static queuetype *parser_modes = &parser_modes_queue;
+static boolean parser_modes_inited = FALSE;
+
+
+/*
+ * parser_modes_init
+ * Initialize well known parser modes and add default aliases
+ */
+void parser_modes_init (void)
+{
+ if (!parser_modes_inited) {
+ parser_modes_inited = TRUE;
+ parser_modes = &parser_modes_queue;
+ queue_init(parser_modes, 0);
+
+ parser_add_main_modes();
+ }
+}
+
+
+/*
+ * create_new_mode
+ * Allocate and fill in new mode structure
+ */
+static parser_mode *create_new_mode (const char *name, const char *prompt,
+ const char *help,
+ boolean do_aliases, boolean do_privileges,
+ const char *alt_mode,
+ mode_save_var_func save_vars,
+ mode_reset_var_func reset_vars,
+ transition *top,
+ mode_http_init_func http_init)
+{
+ parser_mode *new_mode;
+
+ if (!parser_modes_inited) {
+ parser_modes_init();
+ }
+
+ new_mode = (parser_mode *)PARSERmalloc(sizeof(parser_mode) );
+ if (new_mode == NULL) {
+ return(NULL);
+ }
+
+ new_mode->name = name;
+ new_mode->prompt = prompt;
+ new_mode->help = help;
+ new_mode->alt_mode = alt_mode;
+ new_mode->save_vars = save_vars;
+ new_mode->reset_vars = reset_vars;
+ new_mode->flags = PARSER_MODE_NONE;
+ new_mode->next = NULL;
+
+ if (do_aliases) {
+ new_mode->flags |= PARSER_MODE_ALIASES;
+ }
+ if (do_privileges) {
+ new_mode->flags |= PARSER_MODE_PRIVILEGE;
+ }
+ new_mode->top = top;
+
+#ifdef INCLUDE_PARSER_ALIAS
+ new_mode->aliases = (queuetype *)PARSERmalloc(sizeof(queuetype) );
+
+ if (new_mode->aliases) {
+ queue_init(new_mode->aliases, 0);
+ }
+ new_mode->def_aliases = (queuetype *)PARSERmalloc(sizeof(queuetype));
+ if (new_mode->def_aliases) {
+ queue_init(new_mode->def_aliases, 0);
+ }
+#endif
+
+ new_mode->priv_changed = FALSE;
+ new_mode->http_init = http_init;
+
+ if (parser_mode_debug) {
+ printf("\nAdding parser mode: '%s' 0x%x", name, (uint)new_mode);
+ }
+
+ return(new_mode);
+}
+
+
+/*
+ * parser_add_mode
+ * Create and add new parser mode
+ * name - mode name, used in MODE macro for matching, so
+ * can't contain whitespace
+ * prompt - mode prompt extension, ie. (config-if), except
+ * without the parentheses
+ * help - help strings describing mode, used as MODE macro help
+ * alt_mode - alternate mode to try if parse fails
+ * save_vars - function to save csb vars when trying alt mode
+ * reset_vars - function to reset csb vars when alt mode fails
+ * do_aliases - are aliases allowed in this mode?
+ * do_privileges - can privilege levels be changed in this mode?
+ * top - top of parse chain for parsing
+ */
+parser_mode *parser_add_mode (const char *name, const char *prompt,
+ const char *help,
+ boolean do_aliases, boolean do_privileges,
+ const char *alt_mode,
+ mode_save_var_func save_vars,
+ mode_reset_var_func reset_vars,
+ transition *top,
+ mode_http_init_func http_init)
+{
+ parser_mode *mode;
+
+ mode = create_new_mode(name, prompt, help, do_aliases, do_privileges,
+ alt_mode, save_vars, reset_vars, top, http_init);
+ if (mode) {
+ enqueue(parser_modes, mode);
+ }
+ return(mode);
+}
+
+
+/*
+ * get_mode_tmp
+ * Create temporary mode
+ */
+parser_mode *get_mode_tmp (const char *name, const char *prompt,
+ const char *help,
+ boolean do_aliases, boolean do_privileges,
+ transition *top)
+{
+ return(create_new_mode(name, prompt, help, do_aliases, do_privileges,
+ NULL, NULL, NULL, top, NULL));
+}
+
+
+/*
+ * free_mode
+ *
+ */
+void free_mode (parser_mode *mode)
+{
+#ifdef INCLUDE_PARSER_ALIAS
+ free_aliases(mode->aliases);
+ free_aliases(mode->def_aliases);
+#endif
+ PARSERfree(mode);
+
+}
+
+
+
+/*
+ * get_mode_byname
+ * Find mode with name
+ */
+parser_mode *get_mode_byname (const char *name, uint volume)
+{
+ parser_mode *mode;
+
+ if (!parser_modes_inited) {
+ parser_modes_init();
+ }
+
+ mode = (parser_mode *)parser_modes->qhead;
+ while (mode) {
+ if (strcmp(name, mode->name) == 0) {
+ break;
+ }
+ mode = mode->next;
+ }
+ if (parser_mode_debug) {
+ printf("\nLook up of parser mode '%s' %s",
+ name, mode ? "succeeded" : "failed");
+ }
+ if (!mode && (volume == MODE_VERBOSE)) {
+ printf("\n%% Unable to find %s mode", name);
+ }
+
+ return(mode);
+}
+
+
+/*
+ * test_mode_config_subcommand
+ * Return TRUE if mode is submode of config mode
+ */
+boolean test_mode_config_subcommand (parseinfo *csb)
+{
+ if (csb && csb->mode && csb->mode->alt_mode) {
+ return(TRUE);
+ }
+ return(FALSE);
+}
+
+parser_mode *get_alt_mode (parser_mode *mode)
+{
+ if (mode && mode->alt_mode) {
+ return(get_mode_byname(mode->alt_mode, MODE_SILENT));
+ } else {
+ return(NULL);
+ }
+}
+
+
+/*
+ * get_mode_prompt
+ * Return prompt extension for this mode
+ */
+const char *get_mode_prompt (parseinfo *csb)
+{
+ if (csb && csb->mode) {
+ return(csb->mode->prompt);
+ } else {
+ return("UNKNOWN-MODE");
+ }
+}
+
+
+/*
+ * get_mode_top
+ * Return top of parse chain for this mode
+ */
+transition *get_mode_top (parser_mode *mode)
+{
+ if (mode) {
+ return(mode->top);
+ } else {
+ return(NULL);
+ }
+}
+
+
+/*
+ * get_mode_nv
+ * Return top of parse chain for NV generation for this mode
+ */
+transition *get_mode_nv (parseinfo *csb)
+{
+ if (csb && csb->mode) {
+ return(csb->mode->top);
+ } else {
+ return(NULL);
+ }
+}
+
+void *mode_save_vars (parseinfo *csb)
+{
+ if (csb && csb->mode &&
+ csb->mode->save_vars && csb->mode->reset_vars) {
+ return(csb->mode->save_vars(csb));
+ } else {
+ return(NULL);
+ }
+}
+
+/*
+ * set_mode_byname
+ * Set current mode to name
+ */
+boolean set_mode_byname (parser_mode **mode, const char *name, uint volume)
+{
+ parser_mode *new_mode;
+
+ new_mode = get_mode_byname(name, volume);
+ if (new_mode) {
+ *mode = new_mode;
+ return(TRUE);
+ } else {
+ return(FALSE);
+ }
+}
+
+#ifdef IOS_PARSER
+
+void mode_reset_vars (parseinfo *csb, void *var)
+{
+ if (csb && csb->mode && csb->mode->reset_vars) {
+ csb->mode->reset_vars(csb, var);
+ }
+}
+
+void set_priv_changed_in_mode (parser_mode *mode, boolean val)
+{
+ mode->priv_changed = val;
+}
+
+boolean mode_http_init (parseinfo *csb)
+{
+ if (csb && csb->mode && csb->mode->http_init) {
+ return(csb->mode->http_init(csb));
+ } else {
+ return(TRUE);
+ }
+
+}
+
+boolean priv_changed_in_mode (parser_mode *mode)
+{
+ return(mode->priv_changed);
+}
+
+
+/*
+ * show_parser_modes
+ *
+ */
+void show_parser_modes (parseinfo *csb)
+{
+ parser_mode *mode;
+
+ mode = parser_modes->qhead;
+ if (mode) {
+ printf("\nParser modes:");
+ printf("\nName Prompt Top "
+ "Alias Privilege\n");
+ while (mode) {
+ printf("%20s%20s0x%8x%8s%8s\n",
+ mode->name, mode->prompt, (uint)mode->top,
+ ((mode->flags & PARSER_MODE_ALIASES) ? "TRUE" : "FALSE"),
+ ((mode->flags & PARSER_MODE_PRIVILEGE) ? "TRUE" : "FALSE"));
+ mode = mode->next;
+ }
+ } else {
+ printf("\nNo parser modes");
+ }
+}
+
+
+
+
+
+/*
+ * get_mode_aliases
+ * Return pointer to aliases in this mode
+ */
+queuetype *get_mode_aliases (parser_mode *mode)
+{
+#ifdef INCLUDE_PARSER_ALIAS
+ if (mode) {
+ return(mode->aliases);
+ } else {
+ return(NULL);
+ }
+#else
+ return( NULL ) ;
+#endif
+
+}
+
+
+/*
+ * get_mode_defaliases
+ * Return pointer to default aliases in this mode
+ */
+queuetype *get_mode_defaliases (parser_mode *mode)
+{
+#ifdef INCLUDE_PARSER_ALIAS
+ if (mode) {
+ return(mode->def_aliases);
+ } else {
+ return(NULL);
+ }
+#else
+ return( NULL );
+#endif
+}
+
+
+/*
+ * get_mode_name
+ * Return name of mode
+ */
+const char *get_mode_name (parser_mode *mode)
+{
+ return(mode->name);
+}
+
+
+
+/*
+ * match_mode
+ * Parser function for matching the MODE macro
+ */
+uint match_mode (parseinfo *csb, int *pi,
+ parser_mode **matched_mode, uint flags)
+{
+ parser_mode *mode;
+ uint num_matches = 0;
+ int i;
+ int matched_pi = *pi;
+ char *word;
+
+ mode = parser_modes->qhead;
+ while (mode) {
+ if (mode->flags & flags) {
+ i = *pi;
+ if (match_partial_keyword(csb, mode->name, &i, mode->help,
+ 0, KEYWORD_WS_OK | KEYWORD_HELP_CHECK,
+ csb->priv)) {
+ *matched_mode = mode;
+ matched_pi = i;
+ num_matches++;
+
+ word = csb->line + csb->line_index;
+ if (strncmp(mode->name, word, strlen(mode->name)) == 0) {
+ /* This was strncasecmp
+ * if (strncasecmp(mode->name, word,
+ * strlen(mode->name)) == 0) {
+ */
+ *pi = matched_pi;
+ return(1);
+ }
+ }
+ }
+ mode = mode->next;
+ }
+ if (num_matches > 1) {
+ *matched_mode = NULL;
+ return(0);
+ }
+ *pi = matched_pi;
+ return(num_matches);
+}
+
+
+/*
+ * nv_mode
+ * Do NV generation for MODE macro
+ */
+void nv_mode (parseinfo *csb, transition *mine, mode_struct * const arg)
+{
+ parser_mode *mode;
+
+ mode = parser_modes->qhead;
+ while (mode) {
+ if (mode->flags & arg->flags) {
+ *CSBVAR(csb, arg->offset, parser_mode *) = mode;
+ nvgen_token(csb, mine, mode->name);
+ }
+ mode = mode->next;
+ }
+}
+
+#ifdef INCLUDE_PARSER_ALIAS
+
+
+/*
+ * display_mode_aliases
+ * Show mode aliases
+ * if (mp != NULL)
+ * show mp mode aliases
+ * else
+ * show all mode aliases
+ */
+void display_mode_aliases (parseinfo *csb, parser_mode *mp)
+{
+ parser_mode *mode;
+
+ mode = parser_modes->qhead;
+ while (mode) {
+ if (!mp || (mp == mode)) {
+ show_mode_aliases(csb, mode->aliases, mode->help);
+ }
+ mode = mode->next;
+ }
+}
+
+#endif
+
+
+#endif
+
diff --git a/data/mnet/Common/cli/src/parser_print.c b/data/mnet/Common/cli/src/parser_print.c
new file mode 100644
index 0000000..6e0e9cc
--- /dev/null
+++ b/data/mnet/Common/cli/src/parser_print.c
@@ -0,0 +1,687 @@
+#include <vxworks.h>
+#include <stdioLib.h>
+#include <taskLib.h>
+#include <tyLib.h>
+#include <lstLib.h>
+#include <inetLib.h> /* for INET_ADDR_LEN */
+#include <timers.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+
+#include <../include/cli_parser_private.h>
+#include <../include/pstypes.h>
+#include <../include/psvxif.h>
+#include <../include/imsg.h>
+#include <../include/imc.h>
+#include <../include/cli_parser_api.h>
+#include <../include/address.h>
+#include <../include/parsertypes.h>
+#include <../include/config.h>
+#include <../include/parser_sim.h>
+#include <../include/parser.h>
+
+
+typedef enum {
+ HELP_TEXT, HELP_SHORT, HELP_LONG
+} helpType;
+
+#define FIELDS 4
+
+static int line_index; /* Lines printed since the last more?
+ * prompt */
+
+/*
+ * Forward references
+ */
+static int count_lines(save_buf * pbuffer);
+static void find_field_widths(save_buf *pbuffer, short field_width[]);
+static void sort_short_help(char *buffer, int length);
+static int count_final_newlines(save_buf * pbuffer);
+static int logical_line_length(char *s, helpType * ptype);
+static int print_lines(char **, short [], boolean, boolean, long);
+static void sort_lines(char **line_starts, int num);
+static char **record_line_starts(save_buf * pbuf, int line_cnt);
+static void paged_output(char *, int, short[], boolean, boolean);
+
+/* cisco's strncpy puts a '\0' at the end of every destination.
+ * This is at odds with UNIX's strncpy, which doesn't write '\0'
+ * if it reachs the max length.
+ */
+
+static void unix_strncpy (char *dst, char *src, ulong max)
+{
+ while ((max-- > 0) && (*dst++ = *src++));
+}
+
+/*
+ * This function (print_buf) takes a save_buf and prints it on stdout,
+ * after doing various formating functions:
+ *
+ * - Lines of text are seperated by \n characters, but there's no guarentee
+ * that the last line will be TERMINATED by a \n.
+ *
+ * - Fields within lines are seperated by \t characters. Fields are sized
+ * dynamically; a field assumes the size of its largest component (plus
+ * two chars padding). If a line contains no \t characters, it does not
+ * have fields and does not affect any field widths.
+ *
+ * - Automatic wrap-around onto a new line may occur at any space (' ')
+ * character. If the line is wrapped within a field, the new line is
+ * indented to the start of the field.
+ *
+ * - After a screen-full of lines, a "More?" prompt is presented and accepts
+ * single character input to control further output. Both '\r' and 'q' are
+ * supported as in UNIX more.
+ *
+ * - The size of the screen (both length and width) comes from the stdio
+ * tt_soc structure. Here is what is not done:
+ *
+ * - The more function doesn't support backing up in the input, although this
+ * is certainly doable, since everything is in a buffer.
+ *
+ * - The field function doesn't support wrapping any fields but the last one
+ * on a line. Predictable but bizarre things will occur if interior
+ * fields extend past the end of line.
+ *
+ */
+
+int print_buf (save_buf buffer, boolean do_buginf, boolean do_formatting,
+ int *pIndex, long maxCount)
+{
+ /* Dynamically determined field widths */
+ short field_width[FIELDS] =
+ {0, 0, 0, 0};
+ char **line_starts = NULL;
+ char **orig_line_starts = NULL;
+ int final_newlines;
+ int line_cnt = 2;
+ int index = 0;
+
+ int rc = RC_OK;
+
+ /* Start line_cnt at 2 so we always malloc something below ! */
+
+ /* Don't crash if no help buffer yet. */
+ if (buffer.buf == NULL) {
+ return ( 0 );
+ }
+
+ /*
+ * We really need to ignore \n\n's at the end of the buffer. So we'll
+ * count them and treat them specially. For now, we just won't output
+ * any of the final \n's !
+ */
+ final_newlines = count_final_newlines(&buffer);
+
+ line_cnt=count_lines(&buffer);
+
+ /*
+ * The variable line_cnt is now the number of lines seen. There should
+ * be one newline starting each line, plus maybe a newline at the end.
+ * We now need to allocate an array of pointers and record the
+ * beginning of each useful line in it (i.e. we don't need to
+ * alphabetize repeated newlines).
+ *
+ * If we want to be hyper about memory, we should maybe make sure that
+ * there's no interruption between line_starts allocation and freeing.
+ *
+ * NOTE: record_line_starts sorts TABBED lines, so you have to
+ * find field widths *after* calling it !
+ *
+ */
+
+ line_starts = record_line_starts(&buffer, line_cnt);
+
+ find_field_widths(&buffer, field_width);
+
+ /* Print the paused output to screen. */
+ line_index = 0;
+
+ if (do_formatting) {
+ /* automore_enable(NULL);*/
+ }
+ if ( !pIndex )
+ index = 0;
+ else
+ index = *pIndex;
+
+ if ((index == 0) && (buffer.buf[0] != '\n')) {
+ /* Make sure there is a leading newline */
+ printf("\n");
+ }
+
+ if (line_starts == NULL) {
+ /* Couldn't malloc, just dump it all out as is ! */
+ paged_output(buffer.buf, buffer.used, field_width,
+ do_buginf, do_formatting);
+ } else {
+ orig_line_starts = line_starts;
+ line_starts = line_starts + index;
+ rc = print_lines(line_starts, field_width, do_buginf, do_formatting,
+ maxCount);
+ PARSERfree( orig_line_starts );
+ line_starts = NULL;
+ }
+
+ if (do_formatting) {
+ /* automore_disable();*/
+ }
+
+ return ( rc );
+
+}
+
+static int count_lines (save_buf *pbuffer)
+{
+ int line_cnt = 0;
+ int buffer_index;
+
+ for (buffer_index = 0; buffer_index < pbuffer->used; buffer_index++) {
+ if (pbuffer->buf[buffer_index]=='\n') {
+ line_cnt++;
+ }
+ }
+
+ /* Add one for final line: */
+ return(line_cnt+1);
+}
+
+static void find_field_widths (save_buf *pbuffer, short field_width[])
+{
+ int char_index = 0;
+ int field_index = 0;
+ int buffer_index;
+
+ /*
+ * Run through the buffer once to figure out field widths. Perhaps it
+ * would be best to optionally disable this feature, for printing
+ * large things like configuration files that won't use fields anyway.
+ *
+ * To avoid lots of looping, we start by counting the widths of each
+ * field into field_width. After we've gone through the buffer, we
+ * insert padding (2 chars per field) and sum up the relative field
+ * widths into absolute tab positions.
+ *
+ * To keep things consistent, we use one set of field widths for printing
+ * the entire print buffer.
+ *
+ */
+
+ for (buffer_index = 0; buffer_index < pbuffer->used; buffer_index++) {
+ switch (pbuffer->buf[buffer_index]) {
+ case '\n':
+ if (field_index && field_width[field_index] < char_index) {
+ field_width[field_index] = char_index;
+ }
+ char_index = 0;
+ field_index = 0;
+ /* line_cnt++; */
+ /*
+ * This will overestimate if we later ignore \n\n sequences or
+ * print in chunks, but that's ok, can be dealt with if it
+ * becomes a problem.
+ */
+ break;
+
+ case '\t':
+ if (field_width[field_index] < char_index) {
+ field_width[field_index] = char_index;
+ }
+ char_index = 0;
+ if (field_index < (FIELDS-1)) {
+ field_index++;
+ } else {
+ field_index = 0;
+ /*
+ * Next keyword hangs off end of line and we don't care
+ * what the field width is, so skip it.
+ */
+ buffer_index++;
+ while (pbuffer->buf[buffer_index] &&
+ (pbuffer->buf[buffer_index] != '\n') &&
+ (pbuffer->buf[buffer_index] != '\t')) {
+ buffer_index++;
+ }
+ }
+ break;
+
+ default:
+ char_index++;
+ break;
+ }
+ }
+
+ if (field_index && field_width[field_index] < char_index) {
+ field_width[field_index] = char_index;
+ }
+
+ /*
+ * Adjust field widths to be starting positions vice widths.
+ */
+ field_width[0] += 2;
+ for (field_index = 1; field_index < FIELDS; field_index++) {
+ field_width[field_index] += field_width[field_index - 1] + 2;
+ }
+}
+
+static int count_final_newlines (save_buf * pbuffer)
+{
+ int chars_to_use;
+ int buffer_index;
+ int final_newlines = 0;
+
+ buffer_index = pbuffer->used - 1;
+
+ while ((buffer_index >= 0) && (pbuffer->buf[buffer_index] == '\n')) {
+ buffer_index--;
+ }
+ chars_to_use = buffer_index + 1;
+ pbuffer->buf[chars_to_use] = '\0';
+ final_newlines = pbuffer->used - chars_to_use;
+ pbuffer->used = chars_to_use;
+ return(final_newlines); /* number of final newlines */
+}
+
+
+static void paged_output (char *buf, int used, short field_width[],
+ boolean do_buginf, boolean do_formatting)
+{
+ int char_index = 0;
+ int field_index = 0;
+ int buffer_index;
+ int word_len;
+ int (* output)(const char *, ...);
+
+ output = printf;
+
+ /*
+ * Now we run through the buffer "for real".
+ */
+ for (buffer_index = 0; buffer_index < used; buffer_index++) {
+ switch (buf[buffer_index]) {
+ case '\t':
+ if (do_formatting && (field_index < FIELDS)) {
+ for (; char_index < field_width[field_index]; char_index++) {
+ (*output)(" ");
+ }
+ field_index++;
+ break;
+ }
+ /* Otherwise, fall through to newline */
+ case '\n':
+ (*output)("\n");
+ char_index = 0;
+ field_index = 0;
+ line_index++;
+ break;
+ case ' ':
+ for (word_len = 0; buffer_index + word_len + 1 < used &&
+ !isspace(buf[buffer_index + word_len + 1]);
+ word_len++) {
+ ;
+ }
+ if ((! SCREEN_WIDTH) ||
+ ((char_index + word_len + 1) < SCREEN_WIDTH) ||
+ !do_formatting) {
+ (*output)(" ");
+ char_index++;
+ } else {
+ (*output)("\n");
+ char_index = 0;
+ line_index++;
+ if (field_index) {
+ for (; char_index < field_width[field_index - 1];
+ char_index++) {
+ (*output)(" ");
+ }
+ }
+ }
+ break;
+ default:
+ (*output)("%c", buf[buffer_index]);
+ char_index++;
+ break;
+ }
+ }
+ if (char_index) {
+ (*output)("\n");
+ }
+
+}
+
+/*
+ * Sort groups of lines. A group is a set of lines of the same type,
+ * i.e. ones from short help, long help, or just text which needs
+ * to be displayed. Only help strings should be sorted before ouput.
+ */
+static char **record_line_starts (save_buf * pbuf, int line_cnt)
+{
+ char **line_starts = NULL;
+ int current_line = 0;
+ int buffer_index = 0;
+ helpType type = HELP_TEXT;
+ helpType prevtype = HELP_TEXT;
+ int len;
+ int scan_line = 0;
+
+ line_cnt++;
+ /* reserve room for NULL marker at end, too */
+
+ line_starts = (char **)PARSERmalloc(sizeof(char *) * line_cnt);
+
+ if (line_starts == NULL) {
+ /*
+ * If this is NULL (malloc failed), we'll just have to do without
+ * alphabeticizing the output !
+ */
+ return(NULL);
+ }
+
+ buffer_index = 0;
+ while ((buffer_index < pbuf->used)
+ && (pbuf->buf[buffer_index] != '\0')) {
+
+ line_starts[scan_line] = pbuf->buf + buffer_index;
+ prevtype = type;
+ len = logical_line_length(line_starts[scan_line], &type);
+
+ if ((prevtype == HELP_LONG) && (type != prevtype)) {
+ /* Got long chunk that needs sorting. */
+ sort_lines(line_starts + current_line, scan_line - current_line);
+ /* Start recording the next chunk. */
+ current_line = scan_line;
+ }
+
+ scan_line++;
+ buffer_index += len;
+
+ if (type == HELP_SHORT) {
+ /* Each short help line needs sorting by itself. */
+ sort_short_help(line_starts[current_line], len);
+ /* Don't maintain a "chunk". */
+ current_line = scan_line;
+ }
+ else if (type == HELP_TEXT) {
+ /* Don't maintain a "chunk". */
+ current_line = scan_line;
+ }
+ }
+
+ /* Sort final chunk. */
+ if (type == HELP_LONG) {
+ sort_lines(line_starts + current_line, scan_line - current_line);
+ current_line = scan_line;
+ }
+
+ line_starts[current_line++] = NULL; /* mark end of array */
+ return(line_starts);
+}
+
+/*
+ * Perform bubble sort on <num> logical lines.
+ *
+ * ASSUMES: line_starts is not NULL.
+ *
+ */
+static void sort_lines (char **line_starts, int num)
+{
+ int i;
+ int j;
+ char *s;
+
+ for (i = 0; i < num; i++) {
+ for (j = i + 1; j < num; j++) {
+ /*
+ * Note: we don't care about stuff beyond logical line length,
+ * because if we swap two lines based on what's way out there,
+ * it won't show. So we don't need strncmp() here.
+ */
+ if (strcmp(line_starts[i], line_starts[j]) > 0) {
+ s = line_starts[i];
+ line_starts[i] = line_starts[j];
+ line_starts[j] = s;
+ }
+ }
+ }
+}
+
+static char *find_http_level_end (char * str)
+{
+ char *tmp;
+
+ tmp = strstr(str, "/level/");
+ if (tmp) {
+ tmp += 7;
+ while (isdigit(*tmp)) {
+ tmp++;
+ }
+ return(tmp);
+ } else {
+ return(str);
+ }
+}
+
+static void sort_short_help (char *buffer, int length)
+{
+ char *spare;
+ int i;
+ int ctab = 0;
+ struct tabstruct {
+ char *field;
+ int length;
+ };
+ struct tabstruct *tabfields = NULL;
+ char *str1;
+ char *str2;
+
+ /* allocate room for a temporary copy (and safety margin) */
+ spare = (char *)PARSERmalloc((length + 2));
+ if (spare == NULL) {
+ /*
+ * If we can't allocate this paltry amount of memory, then we'll
+ * just live without sorting.
+ */
+ return;
+ }
+
+ {
+ int tabs = 1;
+
+ /*
+ * Count tabs and allocate room for pointers to fields ending in
+ * tabs.
+ */
+ for (i = 1; i < length; i++) {
+ if (buffer[i - 1] == '\t') {
+ tabs++;
+ }
+ }
+
+ tabfields = (struct tabstruct *)
+ PARSERmalloc((sizeof(struct tabstruct) * tabs));
+
+ if (tabfields == NULL) {
+ /* Oh, well. Gotta do without a sort. */
+ PARSERfree(spare);
+ spare = NULL;
+ return;
+ }
+ }
+
+ /*
+ * Avoid storing a pointer to the '\n' at the end of this line, if
+ * there is one.
+ */
+ if ((length > 0) && (buffer[length - 1] == '\n')) {
+ length--;
+ }
+
+ /* Store pointers to tabbed fields. */
+ {
+ int last = 0;
+
+ tabfields[ctab++].field = buffer;
+
+ for (i = 1; i < length; i++) {
+ if (buffer[i - 1] == '\t') {
+ tabfields[ctab].field = buffer + i;
+ tabfields[ctab - 1].length = i - last;
+ last = i;
+ ctab++;
+ }
+ }
+ tabfields[ctab - 1].length = i - last;
+ }
+
+ {
+ int j;
+ struct tabstruct tmp;
+
+ /* Sort them. */
+ for (i = 0; i < ctab; i++) {
+ for (j = i + 1; j < ctab; j++) {
+ if (strstr(tabfields[i].field, "/level/")) {
+ str1 = find_http_level_end(tabfields[i].field);
+ str2 = find_http_level_end(tabfields[j].field);
+ } else {
+ str1 = tabfields[i].field;
+ str2 = tabfields[j].field;
+ }
+ if (strcmp(str1, str2) > 0) {
+ tmp = tabfields[i];
+ tabfields[i] = tabfields[j];
+ tabfields[j] = tmp;
+ }
+ }
+ }
+ }
+
+ {
+ int len;
+ char *s = spare;
+
+ /* Output to spare buffer. */
+ for (i = 0; i < ctab; i++) {
+ len = tabfields[i].length;
+ unix_strncpy(s, tabfields[i].field, len);
+ s += len;
+ }
+
+ /*
+ * Now copy back to buffer (but don't put \0 at end -- length
+ * should be unaltered.
+ */
+ spare[length] = '\0';
+ s = spare;
+ while (*s != '\0') {
+ *buffer++ = *s++;
+ }
+ }
+
+ PARSERfree(tabfields);
+ PARSERfree(spare);
+ tabfields = NULL;
+ spare = NULL;
+}
+
+/*
+ * ASSUMES: line_starts is not NULL, with end entry marked by NULL.
+ *
+ */
+static int print_lines (char **line_starts, short field_width[],
+ boolean do_buginf, boolean do_formatting, long maxCount)
+{
+ int i = 0;
+ char *s;
+ helpType junk;
+
+ while (line_starts[i] != NULL) {
+ s = line_starts[i];
+ if ( (maxCount != 0) && (i >= maxCount) )
+ return( RC_MORE );
+ i++;
+ paged_output(s, logical_line_length(s, &junk),
+ field_width, do_buginf, do_formatting);
+ }
+
+ return ( RC_OK );
+}
+
+/*
+ * Figure out the length of the logical line in s. Also figure out what
+ * type the line is.
+ *
+ * ASSUMES: buffer end marked with '\0'.
+ *
+ */
+static int logical_line_length (char *s, helpType * ptype)
+{
+ int i;
+ boolean looking = FALSE;
+
+ *ptype = HELP_TEXT;
+
+ for (i = 0; s[i] != '\0'; i++) {
+ switch (s[i]) {
+ case '\n':
+ looking = TRUE;
+ if ((i > 0) && (s[i - 1] == '\t')) {
+ /* \t\n is the sign of a SHORT help line. */
+ *ptype = HELP_SHORT;
+ }
+ break;
+ case '\t':
+ /* \n\t is a continuation line, can only be type LONG */
+ *ptype = HELP_LONG;
+ looking = FALSE;
+ break;
+ default:
+ if (looking) {
+ return(i);
+ }
+ break;
+ }
+ }
+ if ((i > 0) && (s[i - 1] == '\t')) {
+ /* \t\0 at the end is also a short help line. */
+ *ptype = HELP_SHORT;
+ }
+ /* At end of buffer: */
+ return(i);
+}
+
+/* print_caret - prints a caret at the specified location */
+
+char caret[]="^";
+void print_caret (register int offset)
+{
+ printf("%*.1s", (1 + offset), caret);
+}
+#if 0
+/*
+ * RAMS : commented this out as there is a duplicate definition in parser_printf.cpp
+ */
+int doprnt (char *cp, tt_soc *tty, const char *fmt, va_list argp,
+ boolean do_precision)
+{
+
+
+ int nbytes = 0;
+
+ if ( cp != NULL ) {
+ if ( (nbytes = vsprintf( cp, fmt, argp ) ) < 0 ) {
+ nbytes = 0;
+ }
+ } else if (parserNullFp != NULL ) {
+ if ( (nbytes = vfprintf( parserNullFp, fmt, argp ) ) < 0 ) {
+ nbytes = 0;
+ } else {
+ fflush(parserNullFp);
+ ioctl(fileno(parserNullFp), FIOFLUSH, 0 );
+ }
+ }
+
+ return(nbytes);
+}
+#endif
diff --git a/data/mnet/Common/cli/src/parser_printf.c b/data/mnet/Common/cli/src/parser_printf.c
new file mode 100644
index 0000000..8feca95
--- /dev/null
+++ b/data/mnet/Common/cli/src/parser_printf.c
@@ -0,0 +1,981 @@
+#include <vxworks.h>
+#include <stdioLib.h>
+#include <taskLib.h>
+#include <tyLib.h>
+#include <lstLib.h>
+#include <inetLib.h> /* for INET_ADDR_LEN */
+#include <timers.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+
+#include <../include/cli_parser_private.h>
+#include <../include/pstypes.h>
+#include <../include/psvxif.h>
+#include <../include/imsg.h>
+#include <../include/imc.h>
+#include <../include/cli_parser_api.h>
+#include <../include/address.h>
+#include <../include/parsertypes.h>
+#include <../include/config.h>
+
+
+
+enum {
+ AUTOMORE_ABORT,
+ AUTOMORE_LINE,
+ AUTOMORE_PAGE,
+};
+
+#ifdef NOTHING
+
+/*
+ * automore_more
+ * Asks the question " --More-- ", and returns:
+ * 0 if user didn't want more output
+ * 1 if user wants one more line (input was <cr>)
+ * 2 if user wants another page (input was a SPACE, "Y", or "y".
+ * Assumes TRUE always if screen length is zero.
+ */
+
+static inline int
+automore_more (void)
+{
+ char c;
+
+ if (!stdio)
+ return(AUTOMORE_ABORT);
+
+ if (stdio->tty_length == 0)
+ return(AUTOMORE_PAGE);
+ LOG_SYNC_REPRINT_REG(stdio,"\n --More-- ");
+ while (TRUE) {
+ printf("\n --More-- ");
+ flush();
+ c = getcwait(stdio);
+ c &= 0177;
+ /* \-\-\e\r\o\M\-\-\--More-- \ \ \ \ \ \ \ \ \ */
+ printf("\b\b\b\b\b\b\b\b\b \b\b\b\b\b\b\b\b\b");
+ switch (c) {
+ case '?':
+ printf(
+ "Press RETURN for another line, SPACE for another"
+ " page, anything else to quit"
+ );
+ break;
+ case 040: /* SPACE, Y, or y */
+ case 'Y':
+ case 'y':
+ LOG_SYNC_REPRINT_END(stdio);
+ return(AUTOMORE_PAGE);
+ case '\r': /* return */
+ LOG_SYNC_REPRINT_END(stdio);
+ return(AUTOMORE_LINE);
+ default: /* Anything else */
+ LOG_SYNC_REPRINT_END(stdio);
+ return(AUTOMORE_ABORT);
+ }
+}
+}
+
+#endif
+
+/*
+ * doprintc
+ * Handle a single character for _doprnt
+ */
+
+void doprintc (
+ char **cp,
+ tt_soc *tty,
+ char ch)
+{
+ if (*cp) { /* if writing to a string */
+ *(*cp)++ = ch; /* don't do any formatting */
+ return;
+ }
+
+ if (tty == NULLTTY) { /* If not really doing I/O */
+ return; /* just get out */
+ }
+
+ putc(ch, stdout);
+
+#ifdef NOTHING
+
+ /*
+ * Allow console output to be displayed directly to the
+ * console before the system is up.
+ */
+ if ((!(systeminit_flag || system_configured))
+ || tty == CONTTY) {
+ console_putc(ch & 0x7f);
+ return;
+ }
+ ch &= tty->tty_execmask; /* mask inappropriate bits */
+ if (tty->statbits & LASTWASCR) { /* was the last one a CR? */
+ tty->statbits &= ~LASTWASCR; /* yes, clear flag */
+ if (ch == 012) /* flush char if it is a LF */
+ return; /* we already printed it */
+ }
+
+ /*
+ * If the automore flush flag is set, and automore is enabled, and it
+ * isn't being supressed, don't do any output.
+ */
+
+ if (tty->automore_flush && tty->automore_enabled && !tty->automore_supress)
+ return;
+
+ if ((uchar)ch < 040) {
+ switch (ch) {
+ case 07: /* pass bell, tab, backspace */
+ case 011:
+ case 010:
+ break;
+ case 015:
+ tty->statbits |= LASTWASCR; /* if next is LF, flush it */
+ case 012:
+ if (tty->automore_enabled && !tty->automore_supress &&
+ tty->tty_length) {
+ tty->automore_count++;
+ if ((tty->automore_count >= (tty->tty_length-1)) &&
+ (tty->automore_count > 1)) {
+
+ /*
+ * We are at the end of the page. Supress recursive
+ * processing and set the flush flag based on
+ * whether they want more output or not. Reset
+ * the count and then recursively print out the
+ * header.
+ *
+ * We fall through to print out the original
+ * newline from the input string. This works
+ * because all strings, including the header,
+ * follow the convention of a leading newline.
+ */
+
+ tty->automore_supress++;
+ switch (automore_more()) {
+ case AUTOMORE_LINE: /* one more line */
+ /* subtraction values include the offset
+ * needed for the above test against
+ * tty->tty_length-1.
+ */
+ tty->automore_count = tty->tty_length - 2;
+ break;
+ case AUTOMORE_PAGE: /* one more page */
+ if (tty->automore_header) {
+ printf("%s", tty->automore_header);
+ /*
+ * Output the CR we just swallowed
+ */
+ printc('\n');
+ tty->automore_count = 1;
+ } else {
+ tty->automore_count = 0;
+ }
+ break;
+ default:
+ case AUTOMORE_ABORT: /* abort */
+ tty->automore_count = 0;
+ tty->automore_flush = TRUE;
+ break;
+ }
+ tty->automore_supress--;
+ /*
+ * Don't output LF or CR since we've
+ * cleared the current line.
+ */
+ return;
+ }
+ } else {
+ /*
+ * No paging, so allow the process to suspend
+ * if it's generating reams of output.
+ */
+ process_may_suspend();
+ }
+ putc(tty,015); /* Output a CR */
+ ch = 012; /* And finish with a LF */
+ break;
+ case '\033':
+ if (tty->tty_international) {
+ break;
+ }
+ /* FALL THROUGH */
+ default: /* all else to arrow format */
+ putc(tty,'^');
+ ch += '@';
+ break;
+ }
+ }
+ putc(tty,ch);
+
+
+#endif
+
+}
+
+
+#ifdef NOTHING
+
+/*
+ * printf - cisco convention
+ * Print a format string on standard output
+ */
+
+int printf (const char *fmt, ...)
+{
+ va_list ap;
+
+ if (stdio) {
+ va_start(ap, fmt);
+ return(_doprnt(NULL, stdio, fmt, ap, FALSE));
+ va_end(ap);
+ } else {
+ errmsg(&msgsym(BADPRINT,SYS), "printf");
+ return(0);
+ }
+}
+
+/*
+ * vprintf - cisco convention
+ * Print a format string on standard output using va_args
+ */
+int vprintf (const char *fmt, va_list ap)
+{
+ if (stdio) {
+ return(_doprnt(NULL, stdio, fmt, ap, FALSE));
+ } else {
+ errmsg(&msgsym(BADPRINT,SYS), "vprintf");
+ return(0);
+ }
+}
+
+/*
+ * printc
+ * Print a character on the primary output
+ */
+
+void printc (char ch)
+{
+ char *n = NULL;
+
+ if (stdio) {
+ doprintc(&n, stdio, ch);
+ } else {
+ errmsg(&msgsym(BADPRINT,SYS), "printc");
+ }
+}
+
+/*
+ * ttyprintc
+ * Print a character on the specified output
+ */
+
+void ttyprintc (tt_soc *tty, char ch)
+{
+ char *n = NULL;
+
+ doprintc(&n, tty, ch);
+}
+
+/*
+ * ttyprintf - cisco convention
+ * printf to other than the standard terminal
+ */
+
+int ttyprintf (tt_soc *tty, const char *fmt, ...)
+{
+ va_list ap;
+ int i;
+
+ va_start(ap, fmt);
+ if (tty != CONTTY && tty != NULLTTY) {
+ tty->automore_supress++;
+ i = _doprnt(NULL, tty, fmt, ap, FALSE);
+ tty->automore_supress--;
+ return(i);
+ } else
+ return(_doprnt(NULL, tty, fmt, ap, FALSE));
+ va_end(ap);
+}
+
+/*
+ * _ttyprintf - like fprintf, only no automore supression
+ */
+
+int _ttyprintf (tt_soc *tty, char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ return(_doprnt(NULL, tty, fmt, ap, FALSE));
+ va_end(ap);
+}
+
+/*
+ * sprintf - cisco convention
+ * String version of printf.
+ */
+
+int sprintf (char *cp, const char *fmt, ...)
+{
+ va_list ap;
+ int count;
+
+ va_start(ap, fmt);
+ count = _doprnt(cp, NULL, fmt, ap, FALSE);
+ va_end(ap);
+ cp[count] = '\0';
+ return(count);
+}
+
+/*
+ * vsprintf - cisco convention
+ * String version of printf using varargs as argument
+ */
+int vsprintf (char *cp, const char *fmt, va_list ap)
+{
+ int count;
+
+ count = _doprnt(cp, NULL, fmt, ap, FALSE);
+ cp[count] = '\0';
+ return(count);
+}
+
+/*
+ * ansi_sprintf - ANSI convention
+ */
+
+int ansi_sprintf (char *cp, const char *fmt, ...)
+{
+ va_list ap;
+ int count;
+
+ va_start(ap, fmt);
+ count = _doprnt(cp, NULL, fmt, ap, TRUE);
+ va_end(ap);
+ cp[count] = '\0';
+ return (count);
+}
+
+
+/*
+ * console_message
+ * Print a console message using the bootstrap monitor routines
+ */
+
+void console_message (const char *str)
+{
+ /* emt_call() is used here instead of console_putc() so that
+ * it can be called from sched_cputype() when running on the
+ * wrong hardware.
+ */
+ while (*str)
+ emt_call(EMT_PUTCHAR, *str++);
+}
+
+/*
+ * flush
+ * flush pending output to stdio
+ */
+
+void flush (void)
+{
+ if (stdio)
+ (void)startoutput(stdio);
+}
+
+/*
+ * tt_flush
+ * Flush pending output to given tt_soc *
+ * Used to be called fflush, conflicting with UNIX stdio.
+ */
+
+void ttyflush (tt_soc *tty)
+{
+ if (tty)
+ (void)startoutput(tty);
+}
+
+
+#endif
+
+/*
+ * _doprnt - master printf routine.
+ * The conversions %o, %x, %d, %u, %s, %c, and %% are implemented.
+ * The -, 0, *, and # options are supported for numbers only.
+ * The <width> option is supported for numbers, strings, and characters.
+ * The number of characters printed is returned.
+ *
+ * E/e prints a dotted 48 bit Ethernet address. Takes a string pointer.
+ *
+ * T/t prints a terminal line number in octal or decimal. Integer arg.
+ *
+ */
+
+int doprnt (char *cp, tt_soc *tty, const char *fmt, va_list argp,
+ boolean do_precision)
+{
+ uchar c, *q;
+ int radix, d, length;
+ int charcount;
+ int digitcount;
+ ulong n;
+ uchar digits[25];
+ int hash,rjust,width,size,temp,plus,precision;
+ char fill;
+ /* ulong host; */
+ boolean spaces;
+ boolean is_negative;
+ ulonglong nn = 0;
+
+ /*
+ * Protect against being called incorrectly from interrupt level.
+ * Also, if we were passed a null terminal pointer and string
+ * pointer, figure that stdio hasn't been set up yet and do the I/O
+ * to the console
+ */
+
+#ifdef NOTHING
+
+ if (tty == NULL) {
+ if (cp == NULL) {
+ if (get_interrupt_level() != 0) {
+ errmsg(&msgsym(INTPRINT,SYS));
+ return(0);
+ }
+ tty = console;
+ }
+ } else if ((tty != CONTTY) && systeminit_flag) {
+ if (get_interrupt_level() != 0) {
+ errmsg(&msgsym(INTPRINT,SYS));
+ return(0);
+ }
+ }
+
+#endif
+
+ nn = 0;
+ charcount = 0; /* nothing printed yet */
+ while ((c = *fmt++)) { /* work until end of string */
+ if (c != '%') {
+ charcount++;
+ doprintc(&cp,tty,c); /* output normal characters */
+ } else {
+ width = -1; /* default width is unspecified */
+ length = 0; /* no length yet */
+ fill = ' '; /* default fill is space */
+ rjust = 0; /* default is left justified */
+ hash = 0; /* default is no leading 0 or 0x */
+ size = 0; /* default is that args are short */
+ plus = 0; /* default is no plus sign */
+ precision = -1; /* no precision yet */
+ if (*fmt == '-') {
+ rjust++; /* want right justified */
+ fmt++;
+ }
+ if (*fmt == '+') {
+ plus++; /* add a plus if positive integer */
+ fmt++;
+ }
+ if (*fmt == '0') {
+ fill = '0'; /* set fill char to '0' */
+ fmt++;
+ }
+ if (*fmt == '#') {
+ hash++; /* want leading 0 or 0x */
+ fmt++;
+ }
+ if (*fmt == '*') { /* look to args for width */
+ width = va_arg(argp, int);
+ fmt++;
+ } else /* width possibly specified */
+ while ((*fmt >= '0') && (*fmt <= '9')) {
+ if (width == -1)
+ width = 0;
+ width = width*10 + (*fmt++ - '0');
+ }
+
+ if (do_precision) { /* Check for precision */
+ if (*fmt == '.') { /* precision possibly specified */
+ fmt++;
+ precision = 0;
+ if (*fmt == '*') { /* look to args for precision */
+ precision = va_arg(argp, int);
+ if (precision < 0) /* check for nonsense precision */
+ precision = 0;
+ fmt++;
+ } else
+ while ((*fmt >= '0') && (*fmt <= '9'))
+ precision = precision*10 + (*fmt++ - '0');
+ }
+ } else
+ precision = width; /* cisco convention derives */
+ /* precision from width */
+
+ if (*fmt == 'l') { /* use Longs instead of shorts */
+ size++;
+ fmt++;
+ }
+ if (*fmt == 'l') { /* use Long Longs instead of longs */
+ size++;
+ fmt++;
+ }
+
+ if (!*fmt)
+ break; /* Check for trailing nulls - bad format */
+
+ switch (*fmt++) { /* get char after the %, switch */
+
+#ifdef NOTHING
+
+ case 'B': /* hexadecimal or ethernet */
+ case 'b':
+ temp = va_arg(argp, int);
+ if (temp == APOLLO_TYPE) {
+ q = va_arg(argp, uchar *);
+ bcopy(&q[2], (char *)&host, 4);
+ if (cp) {
+ length = sprintf(cp, "%x", host);
+ cp += length;
+ } else
+ length = _ttyprintf(tty,"%x", host);
+ charcount += length;
+ break;
+ }
+ /* Else fall thru to Ethernet style address */
+ case 'e': /* print an Ethernet address */
+ case 'E': /* 64-bit Ethernet style SMDS address */
+ q = va_arg(argp, uchar *);
+ for (d = 0; d <= 2; d++) {
+ doprintc(&cp,tty,tohexchar((*q)>>4));
+ doprintc(&cp,tty,tohexchar(*q++));
+ doprintc(&cp,tty,tohexchar((*q)>>4));
+ doprintc(&cp,tty,tohexchar(*q++));
+ if (d < 2)
+ doprintc(&cp,tty,'.');
+ }
+ charcount += 14;
+ /*
+ * Do E.164 style by adding 16 more bits.
+ */
+ if (*(char *)(fmt-1) != 'E' || *q == 0xff) {
+ break;
+ }
+ doprintc(&cp,tty,'.');
+ doprintc(&cp,tty,tohexchar((*q)>>4));
+ doprintc(&cp,tty,tohexchar(*q++));
+ doprintc(&cp,tty,tohexchar((*q)>>4));
+ doprintc(&cp,tty,tohexchar(*q++));
+ charcount += 5;
+ break;
+
+ case 't': /* terminal line number */
+ if (decimaltty_enable)
+ goto do_decimal;
+ else
+ goto do_octal;
+ break;
+
+#endif
+
+ case 'o': /* octal */
+ case 'O':
+ /*do_octal:*/ radix = 8;
+ if (precision == -1)
+ precision = 1;
+ if (size > 1) {
+ nn = va_arg(argp, ulonglong);
+ n = (nn != 0);
+ } else if (size) {
+ n = va_arg(argp, ulong);
+ } else {
+ n = va_arg(argp, uint);
+ }
+ if (hash && (n > 0)) {
+ doprintc(&cp,tty,'0');
+ length++;
+ charcount++;
+ }
+ goto compute;
+
+#ifdef NOTHING
+
+ case 'q': /* hexadecimal or decimal */
+ case 'Q':
+ temp = va_arg(argp, int);
+ if ((temp == XNS_TYPE) || (temp == UBXNS_TYPE))
+ goto do_unsigned;
+
+ /* else fall thru to hex */
+
+ case 'x': /* hexadecimal */
+ case 'X':
+ radix = 16;
+ if (precision == -1)
+ precision = 1;
+ if (size > 1) {
+ nn = va_arg(argp, ulonglong);
+ n = (nn != 0);
+ } else if (size) {
+ n = va_arg(argp, ulong);
+ } else {
+ n = va_arg(argp, uint);
+ }
+ if (hash) {
+ doprintc(&cp,tty,'0');
+ doprintc(&cp,tty,'x');
+ length += 2;
+ charcount += 2;
+ }
+ goto compute;
+#endif
+
+
+ case 'u': /* unsigned decimal */
+ case 'U':
+ /*do_unsigned:*/ radix = 10;
+ if (precision == -1)
+ precision = 1;
+ if (size > 1) {
+ nn = va_arg(argp, ulonglong);
+ n = (nn != 0);
+ } else if (size) {
+ n = va_arg(argp, ulong);
+ } else {
+ n = va_arg(argp, uint);
+ }
+ goto compute;
+
+ case 'd': /* signed decimal */
+ case 'D':
+ /* do_decimal: */ radix = 10;
+ if (precision == -1)
+ precision = 1;
+ if (size > 1) {
+ nn = va_arg(argp, longlong);
+ n = (nn != 0);
+ is_negative = ((longlong)nn < 0);
+ } else if (size) {
+ n = va_arg(argp, long);
+ is_negative = ((long)n < 0);
+ } else {
+ n = va_arg(argp, int);
+ /*
+ * For backward compatibility reasons, this test for a
+ * negative number is based upon a 'long', not an 'int'.
+ */
+ is_negative = ((long)n < 0);
+ }
+ if (is_negative) {
+ doprintc(&cp, tty, '-');
+ length++; charcount++;
+ n = -n;
+ } else if (plus) {
+ doprintc(&cp, tty, '+');
+ length++; charcount++;
+ }
+ compute:
+ digitcount = 0;
+ if (n == 0) {
+ q = &digits[0];
+ if (!do_precision) {
+ *q++ = '0';
+ length++;
+ }
+ } else if (nn != 0) {
+ /*
+ * Do not attempt to collapse this into the following case for
+ * 32 bit numbers. All you will accomplish is to use 64bit
+ * arithmetic for all numbers, which is slower in general, but
+ * is much slower for division.
+ */
+ printf("Printing Decimal....???parser_printf.c\n");
+#ifdef MOD_ERRORS
+ for (q = &digits[0]; nn != 0; nn = nn / radix) {
+ d = nn % radix; length++; digitcount++;
+ *q++ = d + (d < 10 ? '0' : '7');
+ }
+#endif
+
+ } else
+ for (q = &digits[0]; n != 0; n = n / radix) {
+ d = n % radix; length++; digitcount++;
+ *q++ = d + (d < 10 ? '0' : '7');
+ }
+ if (do_precision && (precision > 0)
+ && (digitcount < precision))
+ for (d = digitcount; d < precision; d++) {
+ *q++ = '0';
+ length++;
+ }
+ q--; /* back up the pointer a bit */
+ if ((rjust || fill == '0') && width != -1 && (length < width))
+ for (d = 0; d < (width - length); d++) {
+ doprintc(&cp,tty,fill); /* leading fill */
+ charcount++;
+ }
+ while (q >= &digits[0]) {
+ doprintc(&cp,tty, *q--);
+ charcount++;
+ }
+ if (!rjust && fill != '0' && width != -1 && (length < width))
+ for (d = 0; d < (width-length); d++) {
+ doprintc(&cp,tty,' '); /* trailing fill - spaces*/
+ charcount++;
+ }
+ break;
+
+ case 'c': /* character */
+ if (rjust && width != -1)
+ for (d = 0; d < width-1; d++) {
+ doprintc(&cp,tty,' '); /* leading fill - spaces */
+ charcount++;
+ }
+ temp = va_arg(argp, int);
+ doprintc(&cp,tty,temp);
+ charcount++;
+ if (!rjust && width != -1)
+ for (d = 0; d < width-1; d++) {
+ doprintc(&cp,tty,' '); /* trailing fill - spaces*/
+ charcount++;
+ }
+ break;
+
+ case 's': /* string */
+ case 'S': /* string parsed by STRING macro */
+ q = va_arg(argp, uchar *);
+ if (q == NULL) /* insure proper formatting */
+ q = "";
+ spaces = FALSE; /* No spaces */
+ temp = (int) q; /* stash copy of pointer */
+ while (*q) {
+ if (*(fmt-1) == 'S') {
+ if (*q == ' ') {
+ spaces = TRUE; /* Contains spaces */
+ } else {
+ if (*q == '"') {
+ length++; /* Escape quotes */
+ } else {
+ if ((*q >= 127) ||
+ (*q == '\r') ||
+ (*q == '\n')) {
+ length += 3;/*Number escape sequence */
+ }
+ }
+ }
+ }
+ ++q;
+ ++length; /* figure its length */
+ }
+ if (spaces) {
+ length += 2;
+ }
+ if (rjust && (width != -1) && (length < width)) {
+ for (d = 0; d < (width - length); d++) {
+ doprintc(&cp,tty,fill); /* leading fill */
+ charcount++;
+ }
+ }
+ if (spaces) {
+ doprintc(&cp, tty, '"');
+ charcount++;
+ }
+ q = (uchar *) temp; /* get pointer again */
+ while (*q != 0) {
+ if ((precision != -1) &&
+ ((int)(q - (uchar *)temp) >= precision)) {
+ break;
+ }
+ if (*(fmt-1) == 'S') {
+ if ((*q < 127) && (*q != '\r') && (*q != '\n')) {
+ if (*q == '"') {
+ doprintc(&cp, tty, '\\');
+ charcount++;
+ }
+ doprintc(&cp,tty, *q);
+ charcount++;
+ } else {
+ doprintc(&cp, tty, '\\');
+ doprintc(&cp, tty, 'x');
+ doprintc(&cp, tty, (((*q/16) < 0x0A) ?
+ ((*q/16) + '0') :
+ ((*q/16) + 'A' - 0x0A)));
+ doprintc(&cp, tty, (((*q%16) < 0x0A) ?
+ ((*q%16) + '0') :
+ ((*q%16) + 'A' - 0x0A)));
+ charcount += 4;
+ }
+ } else {
+ doprintc(&cp,tty, *q);
+ charcount++;
+ }
+ q++;
+ }
+ if (spaces) {
+ doprintc(&cp, tty, '"');
+ charcount++;
+ }
+ if (!rjust && (width != -1) && (length < width)) {
+ for (d = 0; d < (width-length); d++) {
+ doprintc(&cp,tty,' '); /* trailing fill - spaces */
+ charcount++;
+ }
+ }
+ break;
+
+ case 'r': /* 'raw' display string */
+ q = va_arg(argp, uchar *); /* point to string */
+ if (q == NULL) /* check for null pointer */
+ break;
+ while (*q != 0) { /* field widths don't make */
+ if (cp) /* any sense for displays */
+ *cp++ = *q;
+ else {
+ ;
+#ifdef NOTHING
+ if (tty != NULLTTY) {
+ if (system_running && tty != CONTTY) {
+ putc(tty,*q);
+ } else {
+ console_putc(*q);
+ }
+ }
+#endif
+
+ }
+ charcount++;
+ q++;
+ }
+ break;
+
+ case '%': /* percent sign */
+ doprintc(&cp,tty, '%');
+ charcount++;
+ break;
+
+#ifdef NOTHING
+
+ case 'C': /* cisco specials */
+ fmt++;
+ /* fall thru */
+#endif
+
+ default:
+
+ vprintf(fmt, argp );
+ /*
+ perror("Default in doprnt");
+ charcount += reg_invoke_printf(*(fmt-1), &fmt, &cp, tty, &argp,
+ rjust, width, size, hash,
+ precision);
+ */
+ break;
+ }
+ }
+ }
+ return(charcount);
+}
+
+
+#ifdef NOTHING
+
+/*
+ * automore_enable() - Turn on automatic "more" processing
+ *
+ * This routine is used to enable automatic "more" processing. After
+ * calling it, printf() will pause every page asking the user if they
+ * want more. If they say no, all further output will be supressed until
+ * automore processing is disabled.
+ */
+
+void automore_enable (const char *header)
+{
+ if (!stdio)
+ return;
+ stdio->automore_count = 0; /* Set the line number */
+ stdio->automore_flush = FALSE; /* Not flushing output */
+ stdio->automore_enabled = TRUE; /* Enable automore */
+ automore_header(header); /* Set the header pointer */
+}
+
+/*
+ * automore_header() - Change automore's header in midstream
+ *
+ * Once automore is running, it is sometimes useful to be able to change
+ * the header. This can happen if you are printing a table and want to
+ * print some explanatory text before the table header.
+ */
+
+void automore_header (const char *header)
+{
+ if (!stdio)
+ return;
+ if (header) {
+ stdio->automore_header = NULL; /* To avoid printing header twice */
+ printf("\n%s", header);
+ }
+ stdio->automore_header = header; /* Save the header pointer */
+}
+
+/*
+ * automore_disable() - Disable automatic "more" processing
+ *
+ * This routine is used to disable any further more processing.
+ */
+
+
+void automore_disable (void)
+{
+ if (!stdio)
+ return;
+ stdio->automore_enabled = FALSE; /* Disable automore processing */
+ stdio->automore_flush = FALSE; /* No more output flushing */
+}
+
+/*
+ * automore_quit
+ * If the user quits out of automore, allow the user process to find out.
+ * This is normally used by having the user process poll this function. If
+ * it returns TRUE, then the output is being flushed. This is very useful
+ * if the output is frequently very long.
+ */
+
+boolean automore_quit (void)
+{
+ if (!stdio)
+ return(TRUE);
+ return(stdio->automore_flush);
+}
+
+/*
+ * automore_conditional - Conditionally check for stopping output
+ *
+ * This routine is used to conditionally ask for permission to do
+ * more output. Rather than actually doing the I/O here, we simply
+ * adjust the line count so that the regular automore processing
+ * will handle it.
+ */
+
+void automore_conditional (int lines)
+{
+ /*
+ * If output has not been flushed, and this terminal has a length,
+ * and a line count of zero or a line count greater than what would
+ * fit on the page was specified, set the lines printed to the
+ * page length so that the next output will cause the more prompt
+ * to appear.
+ */
+
+ if (!stdio)
+ return;
+ if (!stdio->automore_flush && stdio->tty_length &&
+ (!lines || (lines > (stdio->tty_length - stdio->automore_count))))
+ stdio->automore_count = stdio->tty_length;
+}
+
+#endif
+
diff --git a/data/mnet/Common/cli/src/parser_privilege.c b/data/mnet/Common/cli/src/parser_privilege.c
new file mode 100644
index 0000000..0ffe273
--- /dev/null
+++ b/data/mnet/Common/cli/src/parser_privilege.c
@@ -0,0 +1,322 @@
+#include <vxworks.h>
+#include <stdioLib.h>
+#include <tyLib.h>
+#include <taskLib.h>
+#include <errnoLib.h>
+#include <lstLib.h>
+#include <inetLib.h> /* for INET_ADDR_LEN */
+#include <timers.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <msgQLib.h>
+#include <sigLib.h>
+
+
+#include <../include/cli_parser_private.h>
+#include <../include/pstypes.h>
+#include <../include/psvxif.h>
+#include <../include/imsg.h>
+#include <../include/imc.h>
+#include <../include/address.h>
+#include <../include/parsertypes.h>
+#include <../include/config.h>
+#include <../include/parser_sim.h>
+#include <../include/parser.h>
+#include <../include/parser_defs_exec.h>
+#include <../include/parser_input.h>
+#include <../include/parser_sim.h>
+#include <../include/parser_util.h>
+#include <../include/parser_commands.h>
+#include <../include/nv.h>
+#include <../include/parser_errno.h>
+#include <../include/parser_ModNum.h>
+#include <../include/defs.h>
+#include <../include/parser_init.h>
+#include <../include/macros.h>
+#include <../include/parser_actions.h>
+#include <../include/parser_privilege.h>
+
+
+#ifdef IOS_PARSER
+
+
+boolean parser_priv_debug = FALSE;
+static void set_privilege_level(parser_mode *, uint, uint,
+ char *, boolean, boolean, char *);
+
+
+/*
+ * priv_command
+ *
+ * Handle parsing of privilege global config command. Call
+ * set_privilege_level since we need a new csb, so call with
+ * needed arguments extracted from csb
+ */
+void priv_command (parseinfo *csb)
+{
+ if (csb->nvgen && !priv_changed_in_mode(csb->pmp)) {
+ return;
+ }
+ set_privilege_level(csb->pmp, GETOBJ(int,1), GETOBJ(int,2),
+ GETOBJ(string,1), csb->sense, csb->nvgen,
+ csb->nv_command);
+}
+
+/*
+ * set_privilege_level
+ *
+ * Handle parsing and NV generation of privilege global config command.
+ * If doing NV generation
+ * traverse parse tree of current node
+ * NV generate commands added to priv_nvgenQ
+ * else
+ * parser command with parse tree of current node
+ * change priv level of transitions added to privQ
+ */
+static void set_privilege_level (parser_mode *mode, uint level, uint reset,
+ char *com, boolean sense, boolean nvgen,
+ char *nv_command)
+{
+ parseinfo *csb;
+ privq *pq;
+ priv_nvgenq *pnvq;
+ priv_nvgenq *ptmp;
+ priv_nvgenq *prev;
+
+ csb = get_csb("Privilege CSB");
+ if (!csb) {
+ printf(nomemory);
+ return;
+ }
+
+ csb->mode = mode;
+ csb->nvgen = nvgen;
+ csb->priv = PRIV_ROOT;
+ csb->sense = TRUE;
+ csb->priv_set = TRUE;
+ push_node(csb, get_mode_top(csb->mode));
+
+ if (csb->nvgen) {
+ parse_token(csb); /* traverse parse tree */
+ if (csb->priv_nvgenQ) {
+ /*
+ * Weed out duplicate entries
+ */
+ pnvq = csb->priv_nvgenQ->qhead;
+ prev = NULL;
+ while (pnvq) {
+
+ ptmp = pnvq->next;
+ while (ptmp) {
+ if ((pnvq->level == ptmp->level) &&
+ (strcmp(pnvq->command, ptmp->command) == 0)) {
+ /* Duplicate entry */
+ if (parser_priv_debug) {
+ printf("\nDuplicate priv entry 0x%x %d '%s'",
+ (uint)mode,pnvq->level, pnvq->command);
+ }
+ if (prev) {
+ prev->next = pnvq->next;
+ } else {
+ csb->priv_nvgenQ->qhead = pnvq->next;
+ }
+ PARSERfree(pnvq);
+ pnvq = NULL;
+ break;
+ }
+ ptmp = ptmp->next;
+ }
+ if (pnvq) {
+ prev = pnvq;
+ pnvq = pnvq->next;
+ } else {
+ pnvq = csb->priv_nvgenQ->qhead;
+ }
+ }
+
+ /*
+ * NV generate remaining entries
+ */
+ while (! QUEUEEMPTY(csb->priv_nvgenQ)) {
+ /*
+ * For each priv structure, remove from nvgenQ,
+ * NV generate, and free priv structure
+ */
+ pnvq = dequeue(csb->priv_nvgenQ);
+ /*
+ nv_write(TRUE, "%s level %d %s", nv_command,
+ pnvq->level, pnvq->command);
+ */
+ printf("nv_write in parser_privilege.c\n");
+ PARSERfree(pnvq);
+ }
+ }
+ free_csb(&csb);
+ return;
+ }
+
+ strcpy(csb->line, com);
+ if (parser_priv_debug) {
+ printf("\nSetting privilege level to %d for command '%s'",
+ level, csb->line);
+ }
+
+ /*
+ * Parse the input buffer and find the
+ * transitions that need to be changed.
+ */
+ parse_token(csb);
+ if (!csb->privQ) {
+ /* No transitions found, so report error */
+ printf("\n%% Unknown command '%s'", csb->line);
+ } else {
+ /*
+ * We have some transitions, so change the
+ * privilege levels for them.
+ */
+ set_priv_changed_in_mode(mode, TRUE);
+ while (! QUEUEEMPTY(csb->privQ)) {
+ pq = dequeue(csb->privQ);
+ if (sense && !reset) {
+ if (parser_priv_debug) {
+ printf("\nChanging privilege for 0x%x from %x-%x-%d-0x%x",
+ (uint)pq->priv, pq->priv->cur_priv,
+ pq->priv->def_priv, pq->priv->priv_changed,
+ TRANS_PRIV_FLAGS_GET(pq->priv->flags));
+ }
+ pq->priv->priv_changed = TRUE;
+ pq->priv->cur_priv = level;
+ if (parser_priv_debug) {
+ printf(" to %x-%x-%d-0x%x", pq->priv->cur_priv,
+ pq->priv->def_priv, pq->priv->priv_changed,
+ TRANS_PRIV_FLAGS_GET(pq->priv->flags));
+ }
+ } else {
+ if (parser_priv_debug) {
+ printf("\nChanging privilege for 0x%x from %x-%x-%d-0x%x",
+ (uint)pq->priv, pq->priv->cur_priv,
+ pq->priv->def_priv, pq->priv->priv_changed,
+ (uint)(TRANS_PRIV_FLAGS_GET(pq->priv->flags)));
+ }
+ pq->priv->cur_priv = pq->priv->def_priv;
+ if (reset) {
+ pq->priv->priv_changed = FALSE;
+ }
+ if (parser_priv_debug) {
+ printf(" to default %x-%x-%d-0x%x", pq->priv->cur_priv,
+ pq->priv->def_priv, pq->priv->priv_changed,
+ TRANS_PRIV_FLAGS_GET(pq->priv->flags));
+ }
+ }
+ PARSERfree(pq);
+ }
+ }
+ free_csb(&csb);
+}
+
+/*
+ * show_priv_command
+ *
+ * Display users current privilege level
+ */
+void show_priv_command (parseinfo *csb)
+{
+ printf("\nCurrent privilege level is %d", csb->priv);
+}
+
+
+#endif /* IOS_PARSER */
+
+
+
+
+
+/*
+ * priv_enqueue
+ *
+ * Add a privilege structure onto queue, allocating storage
+ * for queue if necessary
+ */
+static void priv_enqueue (queuetype **qp, void *pv)
+{
+ if (!*qp) {
+ *qp = (queuetype *)PARSERmalloc(sizeof(queuetype));
+ if (!*qp) {
+ /* No memory */
+ return;
+ } else {
+ queue_init(*qp, 0);
+ }
+ }
+ requeue(*qp, pv);
+}
+
+/*
+ * priv_push
+ *
+ * Allocate storage for privilege structure and add to privQ
+ */
+void priv_push (parseinfo *csb, trans_priv *priv)
+{
+ privq *pq;
+
+ /*
+ * Modify the current privilege
+ */
+ if (parser_priv_debug) {
+ printf("\nPushing transition on stack 0x%x", (uint)priv);
+ }
+ pq = (privq *)PARSERmalloc(sizeof(privq));
+ if (!pq) {
+ printf(nomemory);
+ return;
+ }
+ pq->priv = priv;
+ pq->next = NULL;
+ /* Add priv structure to privQ */
+ priv_enqueue(&csb->privQ, pq);
+}
+
+/*
+ * nvgen_privilege
+ *
+ * Allocate storage for privilege structure and add to priv_nvgenQ
+ */
+boolean nvgen_privilege (parseinfo *csb, trans_priv *priv, const char *str)
+{
+ priv_nvgenq *pnvq;
+ return TRUE; /* modified by rrams */
+#if 0
+ if ((! priv->priv_changed) || (csb->flags & CONFIG_ABORT)) {
+ /*
+ * Privilege level hasn't changed, or a previous command
+ * failed and we shouldn't bother
+ */
+ return(FALSE);
+ }
+#endif
+ pnvq = (priv_nvgenq *)PARSERmalloc(sizeof(priv_nvgenq));
+ if (!pnvq) {
+ /*
+ * Out of memory, flag CONFIG_ABORT so furthur commands aren't
+ * NV generated and return
+ */
+ csb->flags |= CONFIG_ABORT;
+ printf(nomemory);
+ return(FALSE);
+ }
+ /* Add text of command */
+ if (csb->nv_command[0] != '\0') {
+ sprintf(pnvq->command, "%s %s", csb->nv_command, str);
+ } else {
+ strcpy(pnvq->command, str);
+ }
+ pnvq->level = priv->cur_priv;
+ pnvq->next = NULL;
+ /* Add priv structure to priv_nvgenQ */
+ priv_enqueue(&csb->priv_nvgenQ, pnvq);
+ return(TRUE);
+}
+
+
diff --git a/data/mnet/Common/cli/src/parser_util.c b/data/mnet/Common/cli/src/parser_util.c
new file mode 100644
index 0000000..25d502c
--- /dev/null
+++ b/data/mnet/Common/cli/src/parser_util.c
@@ -0,0 +1,268 @@
+#include <vxworks.h>
+#include <stdioLib.h>
+#include <tyLib.h>
+#include <taskLib.h>
+#include <errnoLib.h>
+#include <lstLib.h>
+#include <inetLib.h> /* for INET_ADDR_LEN */
+#include <timers.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <msgQLib.h>
+#include <sigLib.h>
+
+#include <../include/pstypes.h>
+#include <../include/psvxif.h>
+#include <../include/platdef.h>
+#include <../include/ttyutil.h>
+
+#include <../include/imsg.h>
+#include <../include/imc.h>
+
+#include <../include/parsertypes.h>
+#include <../include/address.h>
+#include <../include/config.h>
+#include <../include/parser_defs_exec.h>
+#include <../include/parser_input.h>
+#include <../include/parser_sim.h>
+#include <../include/parser_util.h>
+#include <../include/parser_commands.h>
+#include <../include/nv.h>
+#include <../include/parser_ModNum.h>
+#include <../include/parser_errno.h>
+#include <../include/defs.h>
+#include <../include/parser.h>
+
+
+
+static char netascii2cisco (char **buf)
+{
+ char ch;
+
+ if ((**buf == '\r') &&
+ (*(*buf+1) == '\n')) {
+ *buf += 2;
+ return('\n');
+ }
+ if ((**buf == '\r') &&
+ (*(*buf+1) == '\0')) {
+ *buf += 2;
+ return('\r');
+ }
+ ch = **buf;
+ (*buf)++;
+ return(ch);
+}
+
+/*
+ * BATCH_INPUT
+ *
+ * If there is an active batch input buffer which
+ * contains more data, read a line from it and return TRUE.
+ *
+ * This function must operate much the same way as readline so
+ * that the parser does not know the difference.
+ */
+boolean batch_input (parseinfo *csb, char *buf, int buflen,
+ char *breakset, char *lastcharp)
+{
+ char *cp = buf;
+
+ *lastcharp = '\0';
+
+ if (csb->batch_buf && *csb->batch_offset) {
+ /* Copy a line, stopping at any breakset character,
+ * NULL, or a full buffer
+ */
+ while (*csb->batch_offset
+ && ! strchr(breakset, *csb->batch_offset)
+ && ((cp - buf) < (buflen - 1))) {
+ *(cp++) = netascii2cisco(&csb->batch_offset);
+ }
+
+ *lastcharp = netascii2cisco(&csb->batch_offset);
+ *cp = '\0';
+ return(TRUE);
+ }
+ return(FALSE);
+}
+
+/*
+ * SAVE_LINE
+ *
+ * Save lines into a block buffer. Used for comments, which are output at the
+ * begining of the NV generation; generated command lines, which are output
+ * after the comments; and help, which is output after a line is parsed.
+ * For generation, make sure we have enough space to save both comments and
+ * configuration. If there isn't enough space in NV ram, truncate comments.
+ *
+ * Unlike an earlier version of save_line, newline characters aren't added
+ * automatically - call save_line a second time if needed (since lines are
+ * added sequentially into the buffer). Tabs are used to delimit fields;
+ * this feature is used only by the help strings.
+ */
+
+void save_line_init (save_buf *bp)
+{
+ if (bp->buf) {
+ PARSERfree(bp->buf);
+ }
+ bp->buf = NULL;
+ bp->size = 0;
+ bp->used = 0;
+}
+
+void save_line (parseinfo *csb, save_buf *bp, const char *fmt, ...)
+{
+ va_list args;
+ int n;
+ int newsize;
+
+ char *mybuf;
+
+ if (!fmt) {
+ return;
+ }
+
+ va_start(args, fmt);
+
+ n = doprnt(NULL, NULLTTY, fmt, args, FALSE);
+
+ /*
+ * We expect to be able to parse args again later for the real
+ * write. However, some processors have to store state in the
+ * va_list block for va_arg() reads so refresh the state
+ * again by ending and starting again.
+ */
+
+ va_end(args);
+
+ va_start(args, fmt);
+
+
+ /* Add 1, for the null termination */
+ while (( bp->used + n + 1) > bp->size) {
+ newsize = bp->size + SABUFSIZE;
+ mybuf = (char *)PARSERmalloc(newsize);
+ memset((void *)mybuf, 0, newsize );
+ if (mybuf) {
+ bp->size = newsize;
+ if (bp->buf == NULL) {
+ *mybuf = '\0';
+ } else {
+ strcpy(mybuf, bp->buf);
+ PARSERfree(bp->buf);
+ }
+ } else {
+ va_end(args);
+ return;
+ }
+ bp->buf = mybuf;
+ }
+
+ /* We do not need to use doprnt if we are printing
+ * to a non-NULL buffer, instead use vsprintf
+ * doprnt has some issues with command completion in our
+ * case.
+ */
+
+ n = vsprintf(bp->buf + bp->used, fmt, args);
+
+ bp->used += n;
+ va_end(args);
+}
+
+boolean confirm (char *s)
+{
+ char c;
+ int fd;
+ boolean result = FALSE;
+
+ fd = ioTaskStdGet(0, STD_IN);
+
+ ioSetTerminalMode(fd, IO_RAW_MODE);
+
+ while (TRUE) {
+ printf("%s[confirm]", s);
+ fflush(stdout);
+ if ( read( fd, &c, 1 ) < 0 ) {
+ printf("Cannot read input\n");
+ goto DONE;
+ }
+ /* c &= 0177; */
+ write(fd, &c, 1);
+ write(fd, "\r\n", 2);
+ switch (c) {
+ case CH_NL:
+ case CH_CR:
+ case 'Y':
+ case 'y':
+ result = (TRUE);
+ goto DONE;
+
+ case '?':
+ printf("Press RETURN to continue, anything else to abort\n");
+ break;
+ default:
+ result = (FALSE);
+ goto DONE;
+
+ }
+ }
+
+ DONE:
+ ioSetTerminalMode(fd, IO_LINE_MODE);
+
+ return(result);
+}
+
+/*
+ * yes_or_no
+ * Print a prompt and wait for a yes or no answer. The supplied default
+ * answer is used if a single return character is typed. If usedef is
+ * false set then no default is used and the user must type yes or no.
+ */
+
+#define MAXBUF 100
+
+boolean yes_or_no (const char *prompt, boolean def, boolean usedef)
+{
+ char *c, buffer[MAXBUF];
+ int fd = -1;
+
+ fd = ioTaskStdGet(0, STD_IN);
+
+ FOREVER {
+
+ if (prompt)
+ printf("%s?[%s]: ", prompt, usedef ? def ? "yes" : "no" :
+ "yes/no");
+
+ fflush(stdout);
+ if ( read( fd, buffer, MAXBUF-1) < 0 )
+ return(FALSE);
+
+ c = deblank(buffer);
+
+ if (usedef && ( null(c) || *c == '\n') )
+ return(def);
+
+ if (tolower(c[0]) == 'y')
+ return(TRUE);
+
+ if (tolower(c[0]) == 'n')
+ return(FALSE);
+
+ printf("%% Please answer 'yes' or 'no'.\n");
+ }
+
+ return(FALSE);
+}
+
+void
+parser_return(parseinfo *csb, int errno_val)
+{
+ csb->return_val = FALSE;
+ csb->errno_val = errno_val;
+}
diff --git a/data/mnet/Common/cli/src/queue.c b/data/mnet/Common/cli/src/queue.c
new file mode 100644
index 0000000..7da9479
--- /dev/null
+++ b/data/mnet/Common/cli/src/queue.c
@@ -0,0 +1,513 @@
+#include <vxworks.h>
+#include <stdioLib.h>
+#include <tyLib.h>
+#include <taskLib.h>
+#include <errnoLib.h>
+#include <lstLib.h>
+#include <inetLib.h> /* for INET_ADDR_LEN */
+#include <timers.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <msgQLib.h>
+#include <sigLib.h>
+
+
+#include <../include/cli_parser_private.h>
+#include <../include/pstypes.h>
+#include <../include/psvxif.h>
+#include <../include/imsg.h>
+#include <../include/imc.h>
+#include <../include/address.h>
+#include <../include/parsertypes.h>
+#include <../include/config.h>
+#include <../include/parser_sim.h>
+#include <../include/parser.h>
+
+boolean queueempty_inline (queuetype *q)
+{
+ return(q->qhead == NULL);
+}
+
+
+/*
+ * enqueue_inline - add an element to a fifo queue.
+ */
+
+void enqueue_inline (queuetype *qptr, void *eaddr)
+{
+ nexthelper *p, *ptr;
+
+ p = qptr->qtail; /* last element pointer */
+ ptr = eaddr;
+
+ /*
+ * Make sure the element isn't already queued or the last
+ * element in this list
+ */
+ if ((ptr->next != NULL) || (p == ptr)) {
+ perror("enqueue_inline:Error\n");
+ return;
+ }
+ if (!p) /* q empty */
+ qptr->qhead = ptr;
+ else /* not empty */
+ p->next = ptr; /* update link */
+ qptr->qtail = ptr; /* tail points to new element */
+ qptr->count++;
+}
+
+/*
+ * dequeue_inline - remove first element of a fifo queue.
+ */
+
+static void *dequeue_inline (queuetype *qptr)
+{
+ nexthelper *p;
+
+
+ if (qptr == NULL)
+ return(NULL);
+ p = qptr->qhead; /* points to head of queue */
+ if (p) { /* is there a list? */
+ qptr->qhead = p->next; /* next link */
+ if (!p->next)
+ qptr->qtail = NULL; /* this was last guy, so zap tail */
+ p->next = NULL; /* clear link, just in case */
+ }
+ if (p && (--qptr->count < 0) && qptr->maximum) {
+ perror("dequeue_inline:Error\n");
+ /* (*kernel_errmsg)(&msgsym(QCOUNT, SYS), "dequeue", qptr,
+ qptr->count);
+ */
+
+ qptr->count = 0;
+ }
+ return(p);
+}
+
+/*
+ * requeue_inline - add an element to the *head* of a "fifo" queue.
+ */
+
+static void requeue_inline (queuetype *qptr, void *eaddr)
+{
+ nexthelper *ptr;
+
+ ptr = eaddr;
+ if (ptr->next != NULL) {
+ perror("requeue:Error\n");
+ return;
+ }
+ if (qptr->qhead == NULL) /* if list is empty */
+ qptr->qtail = ptr; /* update tail pointer */
+ else
+ ptr->next = qptr->qhead; /* new head points to old head */
+ qptr->qhead = ptr; /* list head points to new head */
+ qptr->count++;
+}
+
+/*
+ * queue_init
+ * Initialize a queuetype
+ */
+
+void queue_init (queuetype *q, int maximum)
+{
+ q->qhead = NULL;
+ q->qtail = NULL;
+ q->count = 0;
+ q->maximum = maximum;
+}
+
+/*
+ * enqueue - add an element to a fifo queue.
+ * Note no interrupt interlocking.
+ */
+
+void enqueue (queuetype *qptr, void *eaddr)
+{
+ enqueue_inline(qptr, eaddr);
+}
+
+/*
+ * dequeue - remove first element of a fifo queue.
+ * Note no interrupt interlocking.
+ */
+
+void *dequeue (queuetype *qptr)
+{
+ return(dequeue_inline(qptr));
+}
+
+/*
+ * requeue - add an element to the *head* of a "fifo" queue.
+ * Performs the inverse operation of dequeue()
+ * Note no interrupt interlocking.
+ */
+
+void requeue (queuetype *qptr, void *eaddr)
+{
+ requeue_inline(qptr, eaddr);
+}
+
+/*
+ * peekqueuehead -- Return address of element at head of queue.
+ * Does not lock out interrupts.
+ */
+
+void *peekqueuehead (queuetype* q)
+{
+ nexthelper* p;
+
+ p = (nexthelper *)q->qhead; /* first member */
+ return(p);
+
+}
+
+/*
+ * queryqueuedepth -- Query the length of the queue.
+ * Does not lock out interrupts.
+ */
+
+int queryqueuedepth (queuetype* q)
+{
+ return(q->count);
+}
+
+/*
+ * insqueue - add an element to the *middle* of a "fifo" queue.
+ * 'eaddr' goes immediately after 'paddr'.
+ *
+ * If 'paddr' is NULL, requeue is called.
+ * Note no interrupt interlocking.
+ */
+
+void insqueue (queuetype *qptr, void *eaddr, void *paddr)
+{
+ nexthelper *eptr, *pptr;
+
+ eptr = (nexthelper *)eaddr;
+ pptr = (nexthelper *)paddr;
+ if (pptr == NULL) {
+ requeue(qptr, eptr);
+ return;
+ }
+ if (eptr->next != NULL) {
+ perror("insqueue:Error!\n");
+ return;
+ }
+ eptr->next = pptr->next;
+ pptr->next = eptr;
+ if (eptr->next == NULL)
+ qptr->qtail = eptr; /* tail points to new element */
+ qptr->count++;
+}
+
+
+
+
+
+
+
+
+
+#ifdef IOS_PARSER
+
+
+/*
+ * checkqueue
+ * Return TRUE if specified element is in queue, FALSE otherwise
+ * Does not lock out interrupts.
+ */
+
+boolean checkqueue (queuetype *q, void *e)
+{
+ nexthelper *p;
+
+ if (q == NULL)
+ return(FALSE);
+ p = q->qhead; /* first member */
+ while (p) {
+ if (p == e) /* match? */
+ return(TRUE); /* yes, return TRUE */
+ else
+ p = p->next; /* no, cdr the list */
+ }
+ return(FALSE); /* not in queue, return FALSE */
+}
+
+
+
+
+
+/*
+ * p_dequeue -- remove first element from a fifo queue
+ * Locks out interrupts.
+ */
+
+void *p_dequeue (queuetype *qptr)
+{
+ void *p;
+
+ p = dequeue_inline(qptr);
+ return (p);
+}
+
+/*
+ * p_enqueue -- put an element into a fifo queue
+ * Locks out interrupts.
+ */
+
+void p_enqueue (queuetype *qptr, void *eaddr)
+{
+ enqueue_inline(qptr, eaddr);
+}
+
+/*
+ * p_requeue - add an element to the *head* of a "fifo" queue.
+ * Locks out interrupts.
+ */
+
+void p_requeue (queuetype *qptr, void *eaddr)
+{
+ requeue_inline(qptr, eaddr);
+}
+
+/*
+ * p_unqueue -- delete a specified element from a fifo queue.
+ * Lock out interrupts.
+ */
+
+void p_unqueue (queuetype *q, void *e)
+{
+ unqueue_inline(q, e);
+}
+
+/*
+ * p_swapqueue - remove an old element from a fifo queue AND add a
+ * new element into the fifo queue at the old elements' position in
+ * the fifo queue.
+ * Locks out interrupts.
+ */
+
+void p_swapqueue (queuetype *qptr, void *enew, void *eold)
+{
+ swapqueue_inline(qptr, enew, eold);
+}
+
+
+/*
+ * p_unqueuenext -- delete the next element from a fifo queue.
+ * Lock out interrupts.
+ */
+
+void p_unqueuenext (queuetype *q, void **prev)
+{
+ nexthelper *nextelement;
+
+
+ nextelement = (nexthelper *)*prev;
+
+ if (nextelement) { /* else we're at the end of the list - do nothing */
+ *prev = nextelement->next;
+ nextelement->next = NULL;
+
+ if (!*prev) { /* prev now at the end of the list; fix the header */
+ if (prev == (void **)&q->qhead)
+ q->qtail = NULL; /* prev is the header, now an empty list */
+ else
+ q->qtail = prev; /* real prev , it's at the end */
+ }
+ if ((--q->count < 0) && (q->maximum)) {
+ /* (*kernel_errmsg)(&msgsym(QCOUNT, SYS), "p_unqueuenext",
+ q, q->count);
+ */
+ printf("p_unqueuenext:Error\n");
+ q->count = 0;
+ }
+
+ }
+ return;
+}
+
+
+/*
+ * unqueue -- delete a specified element from a fifo queue.
+ * Does not lock out interrupts.
+ */
+
+void unqueue (queuetype *q, void *e)
+{
+ unqueue_inline(q, e);
+}
+
+
+/*
+ * remqueue - remove a specified element from a fifo queue.
+ * The previous queue element is supplied (paddr) to allow a direct lift
+ * (eaddr) and repair. If paddr is NULL, the first member in queue is removed.
+ * Note no interrupt interlocking.
+ */
+
+void *remqueue (queuetype *qptr, void *eaddr, void *paddr)
+{
+
+ /*
+ * If previous member is null and member is at the head of queue,
+ * remove from head
+ */
+ if ((eaddr == qptr->qhead) &&
+ (paddr == NULL)) {
+ return(dequeue(qptr));
+ } else {
+ /*
+ * Check to make sure the previous member is really what it
+ * claims to be or that the current member or previous member are
+ * non-null
+ */
+ if ((paddr == NULL) || (eaddr == NULL) ||
+ (((nexthelper *)paddr)->next != eaddr)){
+ /* (*kernel_errmsg)(&msgsym(LINKED, SYS), "remqueue", eaddr,
+ qptr);
+ */
+ printf("remqueue: Error!!\n");
+ return(NULL);
+ }
+
+ /*
+ * Lift the candidate eaddr and repair pointers
+ */
+ ((nexthelper *)paddr)->next = ((nexthelper *)eaddr)->next;
+ ((nexthelper *)eaddr)->next = NULL;
+
+ /*
+ * Repair tail of queue, if necessary
+ */
+ if (((nexthelper *)paddr)->next == NULL)
+ qptr->qtail = paddr;
+
+ /*
+ * Decrement queue count and do sanity check
+ */
+ if ((--qptr->count < 0) && qptr->maximum) {
+ /* (*kernel_errmsg)(&msgsym(QCOUNT, SYS), "remqueue", qptr,
+ qptr->count);
+ */
+ printf("remqueue:Error\n");
+ qptr->count = 0;
+ }
+ return(eaddr);
+ }
+}
+
+/*
+ * queueBLOCK
+ * Schedule test for blocking on queue empty
+ */
+
+boolean queueBLOCK (queuetype *qptr)
+{
+ return(qptr->qhead ? FALSE : TRUE);
+}
+
+static boolean queuefull_reserve_inline (queuetype *q, int reserve)
+{
+ return((q->maximum != 0) && ((q->count + reserve) >= q->maximum));
+}
+
+static boolean queuefull_inline (queuetype *q)
+{
+ return((q->maximum != 0) && (q->count >= q->maximum));
+}
+
+static int queuesize_inline (queuetype *q)
+{
+ return(q->count);
+}
+
+
+static int queuemax_inline(queuetype *q)
+{
+ return(q->maximum);
+}
+
+
+/*
+ * swapqueue_inline -- swap a new element for an old element on a fifo queue.
+ */
+
+static void swapqueue_inline (queuetype *q, void *enew, void *eold)
+{
+ nexthelper *p;
+ nexthelper *prev;
+ nexthelper *eoldptr;
+ nexthelper *enewptr;
+
+ enewptr = enew;
+ eoldptr = eold;
+ p = q->qhead; /* first member */
+ prev = (nexthelper *)q;
+ while (p) {
+ if (p == eoldptr) { /* delete this guy */
+ prev->next = enewptr; /* tie in new element */
+ enewptr->next = eoldptr->next; /* keep chain intact */
+ eoldptr->next = NULL; /* clear element pointer */
+ if (q->qtail == eoldptr) /* last element? */
+ q->qtail = enewptr;
+ return; /* exit now */
+ } else {
+ prev = p;
+ p = p->next;
+ }
+ }
+ /* (*kernel_errmsg)(&msgsym(NOTQ, SYS), "swapqueue", eoldptr, q);
+ */
+ printf("swapqueue:Error\n");
+
+}
+
+/*
+ * unqueue_inline -- delete a specified element from a fifo queue.
+ */
+
+static void unqueue_inline (queuetype *q, void *e)
+{
+ nexthelper *p;
+ nexthelper *prev;
+ nexthelper *eptr;
+
+ eptr = e;
+ p = q->qhead; /* first member */
+ prev = (nexthelper *)q;
+ while (p) {
+ if (p == eptr) { /* delete this guy */
+ prev->next = p->next; /* keep chain intact */
+ if (!p->next) { /* zapped the tail */
+ if (q->qhead == 0)
+ prev = 0; /* tail was head */
+ q->qtail = prev;
+ }
+ eptr->next = NULL; /* clear element pointer */
+ if ((--q->count < 0) && (q->maximum)) {
+ /* (*kernel_errmsg)(&msgsym(QCOUNT, SYS), "unqueue", q,
+ q->count);
+ */
+ perror("unqueue_inline:Error\n");
+
+ q->count = 0;
+ }
+ return; /* exit now */
+ } else {
+ prev = p;
+ p = p->next;
+ }
+ }
+ /* (*kernel_errmsg)(&msgsym(NOTQ, SYS), "unqueue", eptr, q);
+ */
+ perror("unqueue:Error\n");
+
+}
+
+
+#endif /* IOS_PARSER */
diff --git a/data/mnet/Common/cli/src/show_chain.c b/data/mnet/Common/cli/src/show_chain.c
new file mode 100644
index 0000000..9447d75
--- /dev/null
+++ b/data/mnet/Common/cli/src/show_chain.c
@@ -0,0 +1,220 @@
+
+#include <vxworks.h>
+#include <stdioLib.h>
+#include <tyLib.h>
+#include <taskLib.h>
+#include <errnoLib.h>
+#include <lstLib.h>
+#include <inetLib.h> /* for INET_ADDR_LEN */
+#include <timers.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <msgQLib.h>
+#include <sigLib.h>
+#include <usrLib.h>
+#include <time.h>
+#include <symLib.h>
+
+
+#include <../include/cli_parser_private.h>
+#include <../include/pstypes.h>
+#include <../include/psvxif.h>
+#include <../include/imsg.h>
+#include <../include/imc.h>
+#include <../include/address.h>
+#include <../include/parsertypes.h>
+#include <../include/config.h>
+#include <../include/parser_sim.h>
+#include <../include/parser.h>
+#include <../include/parser_defs_exec.h>
+#include <../include/parser_input.h>
+#include <../include/parser_sim.h>
+#include <../include/parser_util.h>
+#include <../include/parser_commands.h>
+#include <../include/nv.h>
+#include <../include/parser_errno.h>
+#include <../include/parser_ModNum.h>
+#include <../include/defs.h>
+#include <../include/parser_init.h>
+#include <../include/macros.h>
+#include <../include/parser_actions.h>
+
+
+#define ALTERNATE NONE
+#include "../include/vxworks_show_chain.h"
+LINK_POINT( basic_show_commands, ALTERNATE );
+#undef ALTERNATE
+
+
+
+
+static parser_extension_request show_chain_init_table[] =
+{
+ { PARSE_ADD_SHOW_CMD, &pname( basic_show_commands)},
+ { PARSE_LIST_END, NULL }
+};
+
+
+void ShowParserInit(void)
+{
+ parser_add_command_list(show_chain_init_table, "show_commands");
+
+}
+
+
+
+/******** Shows version of gp10 software ****************
+
+void Show_Version(parseinfo *csb){
+ static char *date = __DATE__ ;
+ static char *time = __TIME__ ;
+
+ version();
+ printf(" dated %s : %s\n", date, time );
+}
+*/
+/**Shows system memory partition blocks and statistics*/
+void Show_Memory(parseinfo *csb){
+ switch(csb->which){
+ case SUMMARY:
+ memShow(0);
+ break;
+ case DETAIL:
+ memShow(1);
+ break;
+ }
+}
+
+/**** Shows system clock **/
+void Show_Clock(parseinfo *csb){
+ struct timespec tp;
+ clock_gettime(CLOCK_REALTIME,&tp);
+ printf("\n%s\n",asctime(gmtime( &(tp.tv_sec) ) ));
+
+}
+
+/******* display entries in the system ARP table ********/
+void Show_Arp(parseinfo *csb){
+ arpShow();
+}
+
+/******** "Shows list of gp10 users *********/
+void Show_Users(parseinfo *csb){
+ sysUserShow();
+}
+
+/******** Shows the attached network interfaces *****/
+void Show_Interfaces(parseinfo *csb){
+ ifShow(0);
+}
+
+/******* Shows ip traffic ***/
+void Show_ip_Traffic(parseinfo *csb){
+ icmpstatShow();
+ tcpstatShow();
+ udpstatShow();
+}
+
+/********* Shows ip route *****/
+void Show_ip_Route(parseinfo *csb){
+ routeShow();
+}
+
+/******* Shows list of system drivers ****/
+void Show_Drivers(parseinfo *csb){
+ iosDrvShow();
+}
+
+/******* Shows the list of devices in the system ***/
+void Show_Devices(parseinfo *csb){
+ iosDevShow();
+}
+
+/******** Shows list of file descriptor names in the system *******/
+void Show_Fd(parseinfo *csb){
+ iosFdShow();
+}
+
+/********* Shows stack trace of a task ****/
+void Show_Stack_Trace(parseinfo *csb){
+
+ tt(GETOBJ(int,1));
+}
+
+/**********Shows task information from Task control block ****/
+void Show_Task(parseinfo *csb){
+
+ switch(csb->which){
+ case TASK_ALL:
+ taskShow(0,2);
+ break;
+ case TASK_GEN:
+ taskShow(GETOBJ(int,1),1);
+ break;
+ case TASK_DETAIL:
+ taskShow(GETOBJ(int,1),1);
+ break;
+ case TASK_SUMMARY:
+ taskShow(GETOBJ(int,1),0);
+ break;
+ }
+}
+/****** Shows the current status for loaded modules **/
+void Show_Module(parseinfo *csb){
+
+ switch(csb->which){
+ case ALL:
+ moduleShow(NULL,0);
+ break;
+ case NAME:
+ moduleShow(GETOBJ(string,1),0);
+ break;
+ }
+}
+
+extern void *sysSymTbl;
+
+
+/**** look up a symbol by name ***/
+
+void Show_Symbol(parseinfo *csb){
+ SYM_TYPE ptr;
+ char *bufp;
+
+ /* symFindByName(sysSymTbl,GETOBJ(string,1),&bufp,&ptr);
+ printf("\n%s\n",bufp);*/
+ switch(csb->which){
+ case ALL:
+ lkup(NULL);
+ case NAME:
+ if(GETOBJ(string,1)==NULL)break;
+ lkup(GETOBJ(string,1));
+ break;
+
+
+ }
+
+
+}
+
+/******* Shows environment variable *******/
+void ShowEnv(parseinfo *csb){
+
+ if((getenv(GETOBJ(string,1)))==NULL){
+ printf("\nvariable not found\n");
+ return;
+ }else
+ printf("\n Variable is = %s\n",getenv(GETOBJ(string,1)));
+
+
+}
+
+
+/******* Shows the symbolic name of machine ***/
+void ShowHost(parseinfo *csb){
+ char hostname[128];
+ gethostname(hostname,127);
+ printf("\n%s\n",hostname);
+}
+
diff --git a/data/mnet/Common/cli/src/sys_debug.c b/data/mnet/Common/cli/src/sys_debug.c
new file mode 100644
index 0000000..e000b3c
--- /dev/null
+++ b/data/mnet/Common/cli/src/sys_debug.c
@@ -0,0 +1,261 @@
+#include <vxworks.h>
+#include <stdioLib.h>
+#include <lstLib.h>
+#include <stdlib.h>
+#include <inetLib.h>
+#include <timers.h>
+#include <ctype.h>
+#include <msgQLib.h>
+#include <sigLib.h>
+
+
+#include <../include/cli_parser_private.h>
+#include <../include/pstypes.h>
+#include <../include/psvxif.h>
+#include <../include/imsg.h>
+#include <../include/imc.h>
+#include <../include/address.h>
+#include <../include/parsertypes.h>
+#include <../include/config.h>
+#include <../include/parser_sim.h>
+#include <../include/parser.h>
+#include <../include/debug.h>
+#include <../include/sys_debug.h>
+
+#define MAX_HEADING_LEN 32
+
+static SEM_ID debugSemId;
+static LIST debugShowFuncList;
+static LIST debugAllFuncList;
+#if 0
+/*
+ * RAMS : commented this for now
+ */
+extern void show_debug_http_all(void);
+extern void show_debug_https_all(void);
+extern void show_debug_icp_all (void);
+extern void show_debug_log_all (void);
+extern void show_debug_translog_all (void);
+extern void show_debug_radius_all (void);
+extern void show_debug_authentication_all(void);
+extern void show_debug_tacacs_all (void);
+extern void show_debug_snmp_all (void);
+extern void show_debug_stat_all(void);
+extern void show_debug_wccp_all(void);
+extern void show_debug_wi_all(void);
+extern void show_debug_url_all(void);
+extern void show_debug_sreg_all(void);
+extern void show_debug_rule_all();
+#endif
+
+static tDEBUG_FUNC_NODE* findDebugNode( LIST *, void *, const debug_item_type *);
+
+STATUS add_debug_node( LIST *list, void *func,
+ const debug_item_type *debug_items,
+ const char* heading )
+{
+ STATUS status = OK;
+ tDEBUG_FUNC_NODE *funcNode = NULL;
+
+ if ( PSsemTake(debugSemId, WAIT_FOREVER) == ERROR ) {
+ return(ERROR);
+ }
+
+ if ( findDebugNode( list, func, debug_items ) == NULL ) {
+ funcNode =
+ ( tDEBUG_FUNC_NODE *)PARSERcalloc(1, sizeof(tDEBUG_FUNC_NODE));
+ if ( funcNode ) {
+ funcNode->debug_items = (debug_item_type *)debug_items;
+ funcNode->debugFunction = func;
+ if ( heading &&
+ (funcNode->heading =
+ (char *)PARSERmalloc(sizeof(char) * (MAX_HEADING_LEN + 1)))
+ != NULL){
+ strncpy(funcNode->heading, heading, MAX_HEADING_LEN - 1);
+ funcNode->heading[MAX_HEADING_LEN] = '\0';
+ }
+
+ lstAdd( list, (NODE*)funcNode);
+ }
+ }
+
+ if ( PSsemGive(debugSemId) == ERROR ) {
+ status = ERROR;
+ }
+ return ( status );
+}
+
+STATUS add_debug_show(DEBUG_SHOW_FUNCTION_PTR func,
+ const debug_item_type *debug_items,
+ const char *heading )
+{
+ return(add_debug_node(&debugShowFuncList,
+ (void *)func, debug_items,
+ heading));
+}
+
+
+STATUS add_debug_all(DEBUG_ALL_FUNCTION_PTR func,
+ const debug_item_type *debug_items )
+{
+ if ((add_debug_node(&debugAllFuncList,
+ (void *)func, debug_items,
+ NULL)) == OK ) {
+ if ( func == NULL )
+ generic_debug_all(debug_items, debug_all_p());
+ else
+ func(debug_all_p());
+
+ return( OK );
+ } else
+ return(ERROR);
+}
+
+void invoke_debug_all(boolean debug_all)
+{
+ tDEBUG_FUNC_NODE *function;
+
+
+ if ( PSsemTake(debugSemId, WAIT_FOREVER) == ERROR ) {
+ return;
+ }
+
+ function = (tDEBUG_FUNC_NODE *)lstFirst(&debugAllFuncList);
+
+ while ( function ) {
+ if ( function->debugFunction == NULL ) {
+ if ( function->debug_items )
+ generic_debug_all( function->debug_items, debug_all);
+ } else {
+ ((DEBUG_ALL_FUNCTION_PTR)function->debugFunction)(debug_all);
+ }
+ function = (tDEBUG_FUNC_NODE *)lstNext((NODE*)function);
+ }
+
+ if ( PSsemGive(debugSemId) == ERROR ) {
+ return;
+ }
+}
+
+void invoke_debug_show(void)
+{
+ tDEBUG_FUNC_NODE *function;
+
+ if ( PSsemTake(debugSemId, WAIT_FOREVER) == ERROR ) {
+ return;
+ }
+
+ function = (tDEBUG_FUNC_NODE *)lstFirst(&debugShowFuncList);
+
+ while ( function ) {
+ if ( function->debugFunction == NULL ) {
+ if ( function->debug_items )
+ generic_debug_show( function->debug_items, function->heading);
+ } else {
+ ((DEBUG_SHOW_FUNCTION_PTR)function->debugFunction)();
+ }
+ function = (tDEBUG_FUNC_NODE *)lstNext((NODE*)function);
+ }
+#if 0
+ /*
+ * RAMS : commented this for now
+ */
+ show_debug_http_all();
+ show_debug_https_all();
+ show_debug_icp_all();
+ show_debug_log_all();
+ show_debug_translog_all();
+ show_debug_radius_all();
+ show_debug_authentication_all();
+ show_debug_tacacs_all();
+ show_debug_snmp_all();
+ show_debug_stat_all();
+ show_debug_wccp_all();
+ show_debug_wi_all();
+ show_debug_url_all();
+ show_debug_sreg_all();
+ show_debug_rule_all();
+
+#endif
+ if ( PSsemGive(debugSemId) == ERROR ) {
+ return;
+ }
+}
+
+void sys_debug_init(void)
+{
+ debugSemId = PSsemMCreate( PS_DEFAULT_MUTEX_SEM_FLAG ) ;
+
+ if ( debugSemId == NULL ) {
+ PSpanic("Cannot create Debug Semaphore\n");
+ }
+ lstInit(&debugShowFuncList);
+ lstInit(&debugAllFuncList);
+}
+
+static tDEBUG_FUNC_NODE* findDebugNode( LIST *list, void *func,
+ const debug_item_type *debug_items )
+{
+ tDEBUG_FUNC_NODE *pNode = NULL;
+ boolean locateFunc = TRUE;
+
+ if (list == NULL )
+ return(NULL);
+
+ if ( func == NULL ) {
+ if ( debug_items == NULL )
+ return( NULL );
+
+ locateFunc = FALSE;
+ }
+
+ pNode = (tDEBUG_FUNC_NODE *)lstFirst(list);
+
+ while( pNode ) {
+ if ( locateFunc ) {
+ if ( pNode == func )
+ return( pNode );
+ } else if ( pNode->debug_items == debug_items ) {
+ return ( pNode );
+ }
+ pNode = (tDEBUG_FUNC_NODE *)lstNext((NODE*)pNode);
+ }
+
+ return(NULL);
+}
+
+STATUS remove_debug_node(LIST *list, void *func,
+ const debug_item_type *debug_items )
+{
+ tDEBUG_FUNC_NODE *pNode = NULL;
+
+ if ( PSsemTake(debugSemId, WAIT_FOREVER) == ERROR ) {
+ return(ERROR);
+ }
+
+ if ( (pNode = findDebugNode(list, func, debug_items)) == NULL )
+ return(ERROR);
+
+ lstDelete(list, (NODE *)pNode);
+ PARSERfree(pNode);
+
+ if ( PSsemGive(debugSemId) == ERROR ) {
+ return(ERROR);
+ }
+ return(OK);
+
+}
+
+STATUS remove_debug_all( DEBUG_ALL_FUNCTION_PTR func,
+ const debug_item_type *debug_items )
+{
+ return(remove_debug_node(&debugAllFuncList, (void*)func, debug_items));
+}
+
+STATUS remove_debug_show( DEBUG_SHOW_FUNCTION_PTR func,
+ const debug_item_type *debug_items )
+{
+ return(remove_debug_node(&debugShowFuncList, (void*)func, debug_items));
+}
+
+
diff --git a/data/mnet/Common/cli/src/usrScript.c b/data/mnet/Common/cli/src/usrScript.c
new file mode 100644
index 0000000..f3fcd5e
--- /dev/null
+++ b/data/mnet/Common/cli/src/usrScript.c
@@ -0,0 +1,73 @@
+
+#include "vxworks.h"
+#include "stdio.h"
+#include "ioLib.h"
+
+/******************************************************************************
+*
+* usrStartupScript - make shell read initial startup script file
+*
+* This routine reads a startup script before the VxWorks
+* shell comes up interactively.
+*
+* NOMANUAL
+*/
+/*****************************/
+extern int __floatsisf;
+extern int __divsf3 ;
+extern int __mulsf3 ;
+extern int __addsf3 ;
+
+
+
+/****************************/
+
+extern int consoleFd;
+
+int x;
+
+
+void cli_usrStartupScript
+ (
+ char *fileName
+ )
+ {
+ int old;
+ int newStdIn,newStdOut;
+/*******************************/
+x=__floatsisf;
+x= __divsf3 ;
+x= __mulsf3 ;
+x= __addsf3 ;
+/**************************/
+ if (fileName == NULL)
+ return;
+
+ newStdIn = open (fileName, O_RDONLY, 0);
+ if (newStdIn != ERROR)
+ {
+ printf ("Executing startup script debug %s ...\n", fileName);
+ taskDelay (sysClkRateGet () / 2);
+
+
+
+ CliIOInit(newStdIn,consoleFd,consoleFd,FALSE);
+
+ do
+ taskDelay (sysClkRateGet ());
+ while (taskNameToId ("tCli") != ERROR);
+
+
+ close (newStdIn);
+
+
+
+ printf ("\nDone executing startup script debug %s\n", fileName);
+ taskDelay (sysClkRateGet () / 2);
+ }
+ else
+ printf ("Unable to open startup script %s\n", fileName);
+
+}
+
+
diff --git a/data/mnet/Common/cli/src/util.c b/data/mnet/Common/cli/src/util.c
new file mode 100644
index 0000000..6260135
--- /dev/null
+++ b/data/mnet/Common/cli/src/util.c
@@ -0,0 +1,866 @@
+#include <vxworks.h>
+#include <stdioLib.h>
+#include <taskLib.h>
+#include <tyLib.h>
+#include <lstLib.h>
+#include <inetLib.h> /* for INET_ADDR_LEN */
+#include <timers.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+
+#include <../include/cli_parser_private.h>
+#include <../include/pstypes.h>
+#include <../include/psvxif.h>
+#include <../include/imsg.h>
+#include <../include/imc.h>
+#include <../include/cli_parser_api.h>
+#include <../include/address.h>
+#include <../include/parsertypes.h>
+#include <../include/config.h>
+
+
+/*
+ * null
+ * check for null string
+ */
+
+boolean null (const char *s)
+{
+ char c;
+
+ if (s)
+ while ((c = *s++) != '\0')
+ if ((c != ' ') && (c != '\t'))
+ return(FALSE);
+ return(TRUE);
+}
+
+
+/*
+ * deblank
+ * Remove leading white space
+ */
+
+char *
+deblank (const char *s)
+{
+ if (!s)
+ return((char *)s);
+
+ while (*s == ' ' || *s == '\t')
+ ++s;
+
+ return((char *)s);
+}
+
+
+
+/*
+ * partialmatch
+ * Returns TRUE if "unknown" is a proper substring of "known"
+ */
+
+boolean partialmatch (char const *known, char *unknown)
+{ /* see if unknown <= known */
+ char k, u;
+
+ if (null(unknown)) /* null string never matches */
+ return(FALSE);
+ unknown = (char *)deblank(unknown);
+ while ((k = *known++)) {
+ if (!(u = *unknown++)) {
+ return(TRUE); /* u < known OK */
+ } else {
+ if (toupper(k) != toupper(u))
+ return(FALSE);
+ }
+ }
+ if (*unknown) /* known exhausted */
+ return(FALSE); /* unknown > known */
+ return(TRUE); /* unknown == known */
+}
+
+
+char *
+address_string (ulong address,char *buf)
+{
+ sprintf(buf, "%d.%d.%d.%d",
+ (address >> 24) & 0xff, (address >> 16) & 0xff,
+ (address >> 8) & 0xff, address & 0xff);
+
+ return buf;
+}
+
+
+#ifdef IOS_PARSER
+
+
+/*
+ * parse_unsigned
+ * Parse an unsigned number.
+ * If number starts with '0x', interpret as hexadecimal.
+ * If number starts with '0', interpret as octal.
+ * Anything else is assigned to be unsigned decimal.
+ * Returns -1 on error.
+ */
+
+ulong parse_unsigned (char *buff, boolean *okflag)
+{
+ char c;
+ ulong num;
+ char *startptr;
+
+ *okflag = FALSE;
+
+ if (null(buff))
+ return(-1);
+ buff = deblank(buff);
+ num = 0;
+ c = *buff++;
+ if (c == '0') {
+
+ /*
+ * If '0x', we've parsed a hexadecimal number
+ */
+ if ((*buff == 'x') || (*buff == 'X')) {
+ buff++;
+ c = toupper(*buff++);
+ startptr = buff;
+ while (((c >= '0') && (c <= '9')) || ((c >= 'A') && (c <= 'F'))) {
+ if ((c >= '0') && (c <= '9'))
+ num = num*16 + (c - '0');
+ else
+ num = num*16 + (c - '7');
+ c = toupper(*buff++);
+ }
+ if ((buff == startptr) || (term_char(c) == FALSE))
+ return(-1);
+ *okflag = TRUE;
+ return(num);
+ }
+
+ /*
+ * Check for an octal number, or just zero.
+ */
+ startptr = buff-1;
+ while ((c >= '0') && (c <= '7')) {
+ num = num*8 + (c - '0');
+ c = *buff++;
+ }
+ if (buff == startptr || (term_char(c) == FALSE))
+ return(-1);
+ *okflag = TRUE;
+ return(num);
+ }
+
+ /*
+ * No leading zero, looks like a positive decimal number.
+ */
+ startptr = buff;
+ while ((c >= '0') && (c <= '9')) {
+ num = num*10 + (c - '0');
+ c = *buff++;
+ }
+ if ((buff == startptr) || (term_char(c) == FALSE))
+ return(-1);
+ *okflag = TRUE;
+ return(num);
+}
+/*
+ * parse_signed
+ * Parse an unsigned number.
+ * If number starts with '0x', interpret as hexadecimal.
+ * If number starts with '0', interpret as octal.
+ * Anything else is assigned to be unsigned decimal.
+ * Returns OKFLAG=FALSE on error else okflag=TRUE.
+ */
+
+ulong parse_signed (
+ char *buff,
+ boolean *okflag)
+{
+ char c;
+ ulong num;
+ char *startptr;
+ int sign = 1;
+
+ *okflag = FALSE;
+
+ if (null(buff))
+ return(0);
+
+ buff = deblank(buff);
+ num = 0;
+
+ while ((c = *buff++) == '+')
+ ;
+ while ((c = *buff++) == '-')
+ sign = sign * -1;
+
+ if (c == '0') {
+
+ /*
+ * If '0x', we've parsed a hexadecimal number
+ */
+ if ((*buff == 'x') || (*buff == 'X')) {
+ buff++;
+ c = toupper(*buff++);
+ startptr = buff;
+ while (((c >= '0') && (c <= '9')) || ((c >= 'A') && (c <= 'F'))) {
+ if ((c >= '0') && (c <= '9'))
+ num = num*16 + (c - '0');
+ else
+ num = num*16 + (c - '7');
+ c = toupper(*buff++);
+ }
+ if ((buff == startptr) || (term_char(c) == FALSE))
+ return(0);
+ *okflag = TRUE;
+ return(num);
+ }
+
+ /*
+ * Check for an octal number, or just zero.
+ */
+ startptr = buff-1;
+ while ((c >= '0') && (c <= '7')) {
+ num = num*8 + (c - '0');
+ c = *buff++;
+ }
+ if (buff == startptr || (term_char(c) == FALSE))
+ return(0);
+ *okflag = TRUE;
+ return(num*sign);
+ }
+
+ /*
+ * No leading zero, looks like a positive decimal number.
+ */
+ startptr = buff;
+ while ((c >= '0') && (c <= '9')) {
+ num = num*10 + (c - '0');
+ c = *buff++;
+ }
+ if ((buff == startptr) || (term_char(c) == FALSE))
+ return(0);
+ *okflag = TRUE;
+ return(num*sign);
+}
+
+/*
+ * parse_decimal_long
+ * Parse an unsigned decimal number.
+ * Returns -1 on error.
+ */
+
+ulong parse_decimal_long (char *buff, boolean *okflag)
+{
+ char c;
+ ulong num;
+ char *startptr;
+
+ *okflag = FALSE;
+
+ if (null(buff))
+ return(-1);
+ buff = deblank(buff);
+ num = 0;
+ c = *buff++;
+
+ startptr = buff;
+ while ((c >= '0') && (c <= '9')) {
+ num = num*10 + (c - '0');
+ c = *buff++;
+ }
+ if (buff == startptr)
+ return(-1);
+ *okflag = TRUE;
+ return(num);
+}
+
+/*
+ * parse_hex_long
+ * Parse a 32 bit hex number from a string buffer. Return 0 if a bad number
+ */
+
+ulong parse_hex_long (char *buff)
+{
+ char c;
+ ulong num;
+ char *startptr;
+
+ if (null(buff))
+ return(0);
+ buff = deblank(buff);
+ num = 0;
+ c = toupper(*buff++);
+ startptr = buff;
+ while (((c >= '0') && (c <= '9')) || ((c >= 'A') && (c <= 'F'))) {
+ if ((c >= '0') && (c <= '9'))
+ num = num*16 + (c - '0');
+ else
+ num = num*16 + (c - '7');
+ c = toupper(*buff++);
+ }
+ if ((buff == startptr) ||
+ (c != '.' && c != ':' && term_char(c) == FALSE) )
+ return(0L);
+ return(num);
+}
+
+/*
+ * octet
+ * parse one octet of a protocol address (IP, DECnet, etc.).
+ * Returns valid char pointer on success, nil pointer otherwise
+ */
+
+char *octet (char *ptr, ulong *address, char brkchar)
+{
+ ulong i = 0; /* accumulate number here */
+ char c; /* get first character */
+
+ if (null(ptr)) /* make sure pointer is reasonable */
+ return(NULL);
+ c = *ptr++;
+ while ((c >= '0') && (c <= '9')) { /* while it's a number */
+ i = i*10 + ((int) c - '0'); /* add a digit */
+ c = *ptr++; /* get next character */
+ }
+ if ((i <= 255) && (c == brkchar)) { /* sanity and break check */
+ *address = (*address << 8) + i; /* form more of the address */
+ return(ptr); /* give a good return */
+ } else
+ return(NULL); /* bad number or termination */
+}
+
+/*
+ * t_number
+ * Return TRUE if string is a number
+ */
+
+boolean t_number (char *s)
+{
+ char c;
+
+ if (null(s))
+ return(FALSE);
+ s = deblank(s);
+ c = *s++;
+ while ((term_char(c) == FALSE)) {
+ if (c < '0' || c > '9')
+ return(FALSE);
+ c = *s++;
+ }
+ return(TRUE);
+}
+
+/*
+ * notset
+ * Given a non-zero integer argument, print as a decimal number.
+ * If zero, as the string "not set".
+ */
+
+void notset (int arg)
+{
+ if (arg == 0)
+ printf("not set");
+ else
+ printf("%d", arg);
+}
+
+/*
+ * is_printable_string
+ * Is this a printable ascii string?
+ * Return FALSE if any byte in the supposed string is not an ascii
+ * printable character, else, return TRUE.
+ * The NULL string is not considered a string by this routine.
+ */
+
+boolean is_printable_string (const char *s, int size)
+{
+ char ch;
+ int i;
+
+ if (!s || !size)
+ return(FALSE);
+ for (i=0; i<size; i++) {
+ ch = *s++;
+ if (!isprint(ch)) /* check for printable ascii character */
+ return(FALSE);
+ }
+ return(TRUE); /* All characters are ascii printable*/
+}
+
+/*
+ * int_array_op
+ * Perform addition and deletion operations on an arbitrary sized
+ * integer array.
+ *
+ * Return TRUE if operation succeeded; FALSE otherwise.
+ *
+ * add is a boolean to add to the array. If FALSE, remove from array.
+ */
+
+boolean int_array_op (int *array, int *index, int maxx, int value,
+ boolean add)
+{
+ int i;
+
+ for (i = 0; i < *index; i++)
+ if (array[i] == value)
+ break;
+ if (!add) {
+ if (i >= *index)
+ return(FALSE);
+ if (i != maxx - 1)
+ while (i < maxx - 1) {
+ array[i] = array[i+1];
+ i++;
+ }
+ (*index)--;
+ } else if (i >= *index) { /* not found in list */
+ if (i == maxx - 1)
+ return(FALSE);
+ array[*index] = value;
+ (*index)++;
+ }
+ return(TRUE);
+}
+
+/*
+ * strmatch
+ * If nullok is non zero, null string will match
+ */
+
+boolean strmatch (char *str1, char *cmd, boolean nullok)
+{
+ char c, d;
+
+ if (null(str1)) /* if a null pointer */
+ str1 = ""; /* make it instead reference a null string */
+ str1 = deblank(str1);
+ if (!nullok) {
+ c = *str1;
+ d = *cmd;
+ if (c == '\0' || d == '\0') /* one is empty */
+ if (c || d)
+ return(FALSE); /* one is not null */
+ else
+ return(TRUE); /* nulls can only match each other */
+ }
+
+ /*
+ * return equal if equal up to a space
+ */
+ d = '\0'; /* in case first c is \0 */
+ while ((c = *str1++) && (d = *cmd++) && c != ' ' && d != ' ')
+ if (toupper(c) != toupper(d))
+ return(FALSE);
+
+ /*
+ * Return FALSE if string is longer than command and we are not
+ * at a space, eg. "testx" will NOT match "test" but "test xxx" will.
+ */
+ if (d == '\0' && c != '\0' && c != ' ')
+ return(FALSE);
+ return(TRUE);
+}
+
+/*
+ * ExactToSPsmatch
+ * Exact match up to a ' ' in source string
+ */
+
+boolean ExactToSPsmatch (char *s, char *t)
+{
+ char c, d;
+
+ while (TRUE) {
+ c = *s++;
+ d = *t++;
+ if (c == ' ' && d == '\0')
+ return(TRUE); /* matched up to a space */
+ if (!c || !d)
+ break; /* end of at least one string */
+ if (toupper (c) != toupper (d))
+ return(FALSE);
+ }
+ if (c || d)
+ return(FALSE); /* only partial match */
+ return(TRUE);
+}
+
+/*
+ * nmatch
+ * Find the number of matches to str, and return that number.
+ */
+
+int nmatch (register char *str, char *const cmds[], const ushort cmdflags[],
+ int ncmds, int *index)
+{
+ int j;
+ int i, len, minlen;
+
+ if (null(str))
+ str = "";
+ i = 0;
+ minlen = 1000; /* large enough */
+ str = deblank(str);
+ for (j = 0; j < ncmds; ++j) {
+ if (strmatch(str, cmds[j], FALSE)) {
+ len = strlen(cmds[j]);
+ if (len < minlen) { /* keep minimums */
+ minlen = len;
+ *index = j;
+ }
+ i++;
+ }
+ }
+ if ((i > 1) && ExactToSPsmatch(str, cmds[*index]))
+ return(TRUE);
+ return(i);
+}
+
+/*
+ * findarg
+ * Return a string pointer to a spot after a space
+ */
+
+char *findarg (char *str)
+{
+ if (null(str))
+ return(NULL);
+ str = deblank(str);
+ while (*str && *str++ != ' '); /* to end or after first space */
+ if (!*str)
+ return(NULL);
+ str = (char *) deblank(str);
+ return(str);
+}
+
+/*
+ * return_false, return_true
+ * Stub functions that always return TRUE or FALSE
+ */
+
+boolean return_false (void *dummy, ...)
+{
+ return(FALSE);
+}
+
+boolean return_true (void *dummy, ...)
+{
+ return(TRUE);
+}
+
+fuzzy return_fuz_false (void *dummy, ...)
+{
+ return(FUZ_FALSE);
+}
+fuzzy return_fuz_true (void *dummy, ...)
+{
+ return(FUZ_TRUE);
+}
+
+uchar *return_null (void *dummy, ...)
+{
+ return(NULL);
+}
+
+long return_zero (void)
+{
+ return(0L);
+}
+
+long return_one (void)
+{
+ return(1L);
+}
+
+void return_nothing (void *dummy, ...)
+{
+ return;
+}
+
+/*
+ * instring
+ */
+boolean instring (char *query, char *string)
+{
+ char *p, *q;
+ int i, limit;
+
+ /* Quick tests */
+ if (query == NULL || *query == '\0')
+ return(TRUE);
+ if (string == NULL || *string == '\0')
+ return(FALSE);
+
+ limit = strlen(string) - strlen(query) + 1;
+ for (i = 0; i < limit; i++) {
+ p = query;
+ q = string+i;
+ while (tolower(*p++) == tolower(*q++))
+ if (*p == '\0')
+ return(TRUE);
+ }
+ return(FALSE);
+}
+
+/*
+ * str_cat_with_realloc
+ *
+ * Concatenate source string on dest string. If dest string is not
+ * large enough to hold result (determined by comparing needed size
+ * with destsize), a new buffer is allocated. The buffer is resized
+ * by STRING_BUF_CHARS bytes.
+ */
+void
+strcat_with_realloc(char **dest, uint *destsize, char *src)
+{
+ char *newbuf;
+
+ while (strlen(src) >= *destsize - strlen(*dest)) {
+ newbuf = realloc(*dest, *destsize + STRING_BUF_CHARS);
+ if (newbuf) {
+ *destsize += STRING_BUF_CHARS;
+ *dest = newbuf;
+ } else
+ return;
+ }
+ strcat(*dest, src);
+}
+
+/* safe_sprintf
+ *
+ * Works like sprintf, only it takes a pointer to a buffer, dest, and
+ * a pointer to the size of the buffer. Routine will pass back results
+ * in the buffer. Buffer may be reallocated if additional space is
+ * needed. Routine returns number of characters processed.
+ */
+int
+safe_sprintf (char **dest, uint *destsize, const char *fmt, ...)
+{
+ char *workbuf = string_getnext();
+ va_list argp;
+ int count;
+ boolean allocated = FALSE;
+
+ /* Calculate how many bytes we need */
+ va_start(argp, fmt);
+ count = _doprnt(NULL, NULLTTY, fmt, argp, FALSE);
+ va_end(argp);
+
+ /* If standard buffer not big enough then allocate one */
+ if (count >= STRING_BUF_CHARS - 1) {
+ workbuf = PARSERmalloc(count + 1);
+ if (workbuf == NULL)
+ return 0;
+ allocated = TRUE;
+ }
+
+ va_start(argp, fmt);
+ count = _doprnt(workbuf, NULL, fmt, argp, FALSE);
+ va_end(argp);
+ workbuf[count] = '\0';
+
+ strcat_with_realloc(dest, destsize, workbuf);
+
+ if (allocated)
+ PARSERfree(workbuf);
+ return count;
+}
+
+/*
+ * queuepick - Pick an element in a queue, by index
+ *
+ * This routine is used to return the pointer to an arbitrary element in
+ * a linked list, passing the address of the queue head and an index
+ * number.
+ *
+ * This allows walking through a queue "by index" which can be used to
+ * avoid poison-free crashes. The index is zero-based (zero gives you
+ * the "first" element in the queue).
+ */
+
+
+void *queuepick (void *queue, int index)
+{
+ void *ptr;
+
+ for (ptr = *(void **)queue; ptr; ptr = *(void **)ptr)
+ if (index-- == 0)
+ break;
+ return(ptr);
+}
+
+/*
+ * xnethash
+ * Hash addresses
+ */
+
+uint xnethash (register uchar *addr, register ushort len)
+{
+ register uint i, sum;
+
+ sum = 0;
+ for (i = 0; i < len; i++)
+ sum += addr[i];
+ return sum;
+}
+
+/*
+ * lw_insert -- insert an element into a doubly-linked list.
+ *
+ *
+ * Insert new entry "entry" in list after element "pred"
+ * NOTE: an empty list is formed by having the initial element
+ * have both the flink and blink point to itself. Think of this
+ * as a queue (ie, a circular list) rather than a simple
+ * double-linked list where the terminal elements point to NULL.
+ */
+void lw_insert (dqueue_t *entry, dqueue_t *pred)
+{
+ pred->flink->blink = entry;
+ entry->flink = pred->flink;
+ entry->blink = pred;
+ pred->flink = entry;
+}
+
+/*
+ * lw_remove -- remove an element from a doubly-linked list.
+ *
+ * removes entry "entry"
+ * Note that the removed element has its flink & blink set to point
+ * to itself.
+ */
+void lw_remove (dqueue_t *entry)
+{
+ entry->blink->flink = entry->flink;
+ entry->flink->blink = entry->blink;
+ entry->flink = entry->blink = entry;
+}
+
+void o_init (dqueue_t *entry, void *parent)
+{
+ entry->flink = entry;
+ entry->blink = entry;
+ entry->parent = parent;
+ TIMER_STOP(entry->value);
+}
+
+void o_enqueue (dqueue_t *header, dqueue_t *entry)
+{
+ dqueue_t *p;
+
+ for (p = header->flink; p != header; p = p->flink) {
+ if (TIMER_LATER(p->value, entry->value))
+ break;
+ }
+
+ entry->flink = p->blink->flink;
+ p->blink->flink = entry;
+ entry->blink = p->blink;
+ p->blink = entry;
+}
+
+dqueue_t *o_dequeue (dqueue_t *header)
+{
+ dqueue_t *p;
+
+ if (header->flink == header)
+ return(NULL);
+ if (SLEEPING(header->flink->value))
+ return(NULL);
+ p = header->flink;
+ p->flink->blink = p->blink;
+ p->blink->flink = p->flink;
+ p->flink = p->blink = p;
+ TIMER_STOP(p->value);
+ return(p);
+}
+
+void o_unqueue (dqueue_t *entry)
+{
+ entry->flink->blink = entry->blink;
+ entry->blink->flink = entry->flink;
+ entry->flink = entry->blink = entry;
+ TIMER_STOP(entry->value);
+}
+
+/*
+ * nethash
+ * Given a 32 bit quantity, return an 8 bit hash table offset.
+ * We use XOR'ing as our hash function to avoid division overhead.
+ */
+
+int nethash (ulong addr)
+{
+ register ushort bucket;
+ register charlong address;
+
+ address.d.lword = addr;
+
+ bucket = address.d.sword[0];
+ bucket ^= address.d.sword[1];
+ bucket ^= (bucket >> 8);
+ bucket &= 0xFF;
+ return(bucket);
+}
+
+/*
+ * strdup()
+ * malloc() a new string, and copy old string to new memory
+ */
+char *strdup (const char *oldstr)
+{
+ char *newstr;
+ SAVE_CALLER();
+
+ if (oldstr == NULL)
+ return(NULL);
+
+ newstr = PARSERmalloc(strlen(oldstr) + 1);
+ if (newstr == NULL) {
+ return(NULL);
+ }
+ strcpy(newstr, oldstr);
+ memory_specify_allocator(newstr, caller());
+ return(newstr);
+}
+
+/*
+ * malloc_named() a new string, and copy old string to new memory
+ */
+char *strdup_named (const char *oldstr, const char *name)
+{
+ char *newstr;
+ SAVE_CALLER();
+
+ if (oldstr == NULL)
+ return(NULL);
+
+ newstr = malloc_named(strlen(oldstr) + 1, name);
+ if (newstr == NULL) {
+ return(NULL);
+ }
+ strcpy(newstr, oldstr);
+ memory_specify_allocator(newstr, caller());
+ return(newstr);
+}
+
+char *
+address_string (addrtype *address)
+{
+ char *buffer;
+
+ buffer = string_getnext();
+ reg_invoke_sprintf_address_addr(address->type, buffer, address);
+ return(buffer);
+}
+
+
+
+#endif /* IOS_PARSER */
+
diff --git a/data/mnet/Common/cli/vxsh/Makefile b/data/mnet/Common/cli/vxsh/Makefile
new file mode 100644
index 0000000..0aea1d6
--- /dev/null
+++ b/data/mnet/Common/cli/vxsh/Makefile
@@ -0,0 +1,103 @@
+##########################################################
+#
+# (c) Copyright Cisco 2000
+# All Rights Reserved
+#
+##########################################################
+# TOP_OF_VOB must be defined before including l3defs.mk
+TOP_OF_VOB = ..\..
+
+#EXT = arppc
+
+# These Must be Properly Defined
+THIS_APP_DIR = vxsh
+THIS_DIRECTORY = Src
+
+ifeq ($(APPDIR),)
+ MY_OUTPUT = $(VOB2DIR)\bin\vxsh.out
+else
+ MY_OUTPUT = $(OBJDIR)\vxsh.out
+endif
+
+
+VOB2DIR = $(TOP_OF_VOB)\..\$(VOB)
+BINDIR = ..\bin
+
+#LIBNAME = libppc860gnuvx.a
+LIBNAME = lib$(CPU)$(TOOL)vx.a
+
+# Name(s) of Common VOB directories to include
+COMMON_BLD_DIR =
+
+include $(VOB2DIR)\l3defs.mk
+CC_INCLUDE += -I$(VOB2DIR)\Host
+
+all: makeCommonObjs $(MY_OUTPUT)
+
+# Adds the .o file(s) list needed from the Common VOB
+makeCommonObjs:
+ifneq ($(COMMON_BLD_DIR),)
+ @for %f in ($(COMMON_BLD_DIR)) do \
+ make -C $(COMMON_VOB_APP_DIR)\%f \
+ all VOB=$(VOBNAME) APPDIR=Host\$(THIS_APP_DIR)\$(THIS_DIRECTORY)
+endif
+
+# If Common VOB directories to include get the .o files from bin
+$(MY_OUTPUT): $(MODULE_OBJS)
+
+ @ echo Copying $(LIBNAME).copy to $(LIBNAME)
+ $(CP) $(WIND_BASE)\target\lib\$(LIBNAME).copy $(OBJDIR)\$(LIBNAME)
+ attrib -R $(OBJDIR)\$(LIBNAME)
+
+ $(AR) -x $(OBJDIR)\$(LIBNAME) shell.o
+ $(AR) -x $(OBJDIR)\$(LIBNAME) shellLib.o
+ $(AR) -x $(OBJDIR)\$(LIBNAME) ledLib.o
+
+ $(AR) -dv $(WIND_BASE)\$(LIBNAME) shellLib.o
+ $(AR) -dv $(WIND_BASE)\$(LIBNAME) shell.o
+ $(AR) -dv $(WIND_BASE)\$(LIBNAME) ledLib.o
+
+ifneq ($(COMMON_BLD_DIR),)
+ $(LD) -r -o $@.tmp $() $(MODULE_OBJS) $(wildcard ./bin/*.o) shell.o shellLib.o ledLib.o
+else
+ $(LD) -r -o $@.tmp $() $(MODULE_OBJS) shell.o shellLib.o ledLib.o
+endif
+ $(NM) $@.tmp | munch > _ctdt.c
+ $(CC) -traditional $(CC_ARCH_SPEC) -c _ctdt.c
+ $(LD) -r -o $@ _ctdt.o $@.tmp
+ $(RM)$(subst /,$(DIRCHAR), _ctdt.c _ctdt.o $@.tmp)
+
+cleanall:
+ @for %f in ($(notdir $(MODULE_OBJS))) do \
+ $(RM) ..\bin\%f
+
+ $(RM) $(MY_OUTPUT)
+
+
+ifneq ($(COMMON_BLD_DIR),)
+ $(RM) src\*.o
+ $(RM) bin\*.o
+ $(RM) bin\*.out
+endif
+
+# Create libPENTIUM
+library: $(MODULE_OBJS)
+ @ echo Copying $(LIBNAME).copy to $(LIBNAME)
+ $(CP) $(WIND_BASE)\target\lib\$(LIBNAME).copy $(WIND_BASE)\target\lib\$(LIBNAME)
+ $(CP) $(WIND_BASE)\target\lib\$(LIBNAME) $(OBJDIR)\$(LIBNAME)
+ $(AR) -dv $(WIND_BASE)\target\lib\$(LIBNAME) shellLib.o
+ $(AR) -dv $(WIND_BASE)\target\lib\$(LIBNAME) shell.o
+ $(AR) -dv $(WIND_BASE)\target\lib\$(LIBNAME) ledLib.o
+ attrib -R $(OBJDIR)\$(LIBNAME)
+
+
+
+extract : $(MODULE_OBJS)
+ $(AR) -x $(OBJDIR)\$(LIBNAME) shell.o
+ $(AR) -x $(OBJDIR)\$(LIBNAME) shellLib.o
+ $(AR) -x $(OBJDIR)\$(LIBNAME) ledLib.o
+
+
+
+
+
diff --git a/data/mnet/Common/cli/vxsh/vxsh.c b/data/mnet/Common/cli/vxsh/vxsh.c
new file mode 100644
index 0000000..0831a96
--- /dev/null
+++ b/data/mnet/Common/cli/vxsh/vxsh.c
@@ -0,0 +1,9 @@
+
+#include <vxworks.h>
+#include <stdioLib.h>
+
+void Cli_VxshellInformation(void){
+
+ printf("\nVxShell is the shell provide by vxworks original library ");
+ printf("\nIt provides user a command prompt ,which executes all the standard vxworks functions\n");
+}
diff --git a/data/mnet/Common/gglink/Makefile b/data/mnet/Common/gglink/Makefile
new file mode 100644
index 0000000..bd4611d
--- /dev/null
+++ b/data/mnet/Common/gglink/Makefile
@@ -0,0 +1,47 @@
+##########################################################
+#
+# (c) Copyright Cisco 2000
+# All Rights Reserved
+#
+# Use Examples:
+#
+# Case 1:
+# make all VOB=GP10 -
+# Places .out in VOB/bin directory
+#
+# Case 2:
+# make all VOB=GP10 APPDIR=Host\<Application Name>\<Source Directory> -
+# Places .o file(s) in VOB\$(APPDIR)\bin directory.
+#
+# <Application Name> = Name of Application directory
+# <Source Directory> = application sub directory where the calling
+# Makefile resides.
+#
+# Example: make all VOB=GP10 APPDIR=Host\vxTemplate\src
+#
+# (OPTIONAL) Append REPLACE - Replaces the List of directories
+# to be used in the SUBDIRS variable
+#
+# Example: make all VOB=GP10 APPDIR=Host\vxTemplate\src REPLACE=src
+#
+# Note: This make file must reference a VOB that
+# has a defs.mk in the top level directory.
+#
+##########################################################
+
+SUBDIRS = src
+
+# TOP_OF_VOB must be defined before including l3defs.mk
+TOP_OF_VOB = ..\..
+
+VOBDIR = $(TOP_OF_VOB)\$(VOB)
+
+# Allows a sub-set of the source code directories to be used
+
+ifneq ($(REPLACE),)
+ SUBDIRS = $(REPLACE)
+endif
+
+include $(VOBDIR)\l3defs.mk
+
+
diff --git a/data/mnet/Common/gglink/src/Makefile b/data/mnet/Common/gglink/src/Makefile
new file mode 100644
index 0000000..54ea964
--- /dev/null
+++ b/data/mnet/Common/gglink/src/Makefile
@@ -0,0 +1,61 @@
+##########################################################
+#
+# (c) Copyright Cisco 2000
+# All Rights Reserved
+#
+# Use Examples:
+#
+# Case 1:
+# make all VOB=GP10 -
+# Places .out in VOB/bin directory
+#
+# Case 2:
+# make all VOB=GP10 APPDIR=Host\<Application Name>\<Source Directory> -
+# Places .o file(s) in VOB\$(APPDIR)\bin directory.
+#
+# <Application Name> = Name of Application directory
+# <Source Directory> = application sub directory where the calling
+# Makefile resides.
+#
+# Example: make all VOB=GP10 APPDIR=Host\vxTemplate\src
+#
+#
+# Note: This make file must reference a VOB that
+# has a defs.mk in the top level directory.
+#
+##########################################################
+
+# TOP_OF_VOB must be defined before including l3defs.mk
+TOP_OF_VOB = ..\..\..
+
+# Name of this App's Directory
+THIS_APP_DIR = gglink
+
+VOB2DIR = $(TOP_OF_VOB)\$(VOB)
+BINDIR = ..\bin
+
+ifeq ($(APPDIR),)
+ MY_OUTPUT = $(VOB2DIR)\bin\$(THIS_APP_DIR).out
+else
+ MY_OUTPUT = $(OBJDIR)\$(THIS_APP_DIR).out
+endif
+
+include $(VOB2DIR)\l3defs.mk
+
+
+all: $(MY_OUTPUT)
+
+$(MY_OUTPUT): $(MODULE_OBJS)
+ $(LD) -r -o $@.tmp $(MODULE_OBJS)
+ $(NM) $@.tmp | munch > _ctdt.c
+ $(CC) -traditional $(CC_ARCH_SPEC) -c _ctdt.c
+ $(LD) -r -o $@ _ctdt.o $@.tmp
+ $(RM)$(subst /,$(DIRCHAR), _ctdt.c _ctdt.o $@.tmp)
+
+cleanall:
+ @for %f in ($(notdir $(MODULE_OBJS))) do \
+ $(RM) ..\bin\%f
+
+ $(RM) $(MY_OUTPUT)
+
+
diff --git a/data/mnet/Common/gglink/src/gglink.cpp b/data/mnet/Common/gglink/src/gglink.cpp
new file mode 100644
index 0000000..146864b
--- /dev/null
+++ b/data/mnet/Common/gglink/src/gglink.cpp
@@ -0,0 +1,1178 @@
+
+#include <string.h>
+#include "gglink/gglink_api.h"
+
+BOOL
+GGLINK_UNPACK_SHORT(
+ int &maxlength, // max length of input buffer
+ unsigned char * &ptr, // starting address of input buffer
+ short &dest
+ )
+{
+ if(maxlength < 2)
+ return FALSE;
+ dest = (ptr[0] << 8) + ptr[1];
+ ptr+=2;
+ maxlength-=2;
+ return TRUE;
+}
+
+inline BOOL
+GGLINK_UNPACK_BYTE(
+ int &maxlength, // max length of input buffer
+ unsigned char * &ptr, // starting address of input buffer
+ unsigned char &dest
+ )
+{
+ if (maxlength < 1)
+ return FALSE;
+
+ dest = *ptr++;
+ maxlength--;
+
+ return TRUE;
+}
+
+inline BOOL
+GGLINK_UNPACK_STRING(
+ int &maxlength, // max length of input buffer
+ int stringlength, // size of the string to be unpacked
+ unsigned char * &ptr, // starting address of input buffer
+ unsigned char * dest
+ )
+{
+ if(maxlength < stringlength)
+ return FALSE;
+
+ memcpy(dest, ptr, stringlength);
+ ptr += stringlength;
+ maxlength -= stringlength;
+ return TRUE;
+}
+
+
+BOOL GGLINK_DECODE_IE_MAP_CAUSE(
+ int &maxlength, // max length of input buffer
+ unsigned char * &ptr, // starting address of input
+ GGLINK_IE_MAP_CAUSE &map_cause // output IE data structure
+ )
+{
+ map_cause.ie_present = true;
+ return GGLINK_UNPACK_BYTE(maxlength, ptr, map_cause.map_error_code);
+}
+
+BOOL GGLINK_DECODE_IE_CAUSE(
+ int &maxlength, // max length of input buffer
+ unsigned char * &ptr, // starting address of input buffer
+ GGLINK_IE_CAUSE &cause // output IE data structure
+ )
+{
+ cause.ie_present = true;
+ return GGLINK_UNPACK_BYTE(maxlength, ptr, cause.cause_code);
+}
+
+
+
+BOOL GGLINK_DECODE_IE_GSN_ADDRESS(
+ int &maxlength, // max length of input buffer
+ unsigned char * &ptr, // starting address of input buffer
+ GGLINK_IE_GSN_ADDRESS &gsn_address // output IE data structure
+ )
+{
+ gsn_address.ie_present = true;
+ if (!GGLINK_UNPACK_SHORT(maxlength, ptr, gsn_address.gsn_addr_length))
+ return FALSE;
+
+ if(gsn_address.gsn_addr_length > 16)
+ return FALSE;
+
+ return GGLINK_UNPACK_STRING(maxlength, gsn_address.gsn_addr_length, ptr, gsn_address.addr_octets);
+}
+
+
+BOOL GGLINK_DECODE_IE_MOBILE_ID(
+ int &maxlength, // max length of input buffer
+ unsigned char * &ptr, // starting address of input buffer
+ T_CNI_RIL3_IE_MOBILE_ID &mobileId // output IE data structure
+ )
+{
+
+ int totalLength = ptr[0] + 1;
+
+ if (maxlength < totalLength)
+ {
+ return FALSE;
+ }
+
+ mobileId.ie_present = true;
+
+ // get type
+ mobileId.mobileIdType = (T_CNI_RIL3_MOBILE_ID_TYPE) (ptr[1] & 0x07);
+
+ if(mobileId.mobileIdType == CNI_RIL3_TMSI)
+ {
+ // assuming tmsi is 4 bytes
+ if(totalLength != 6) return FALSE;
+ mobileId.tmsi = (ptr[2] << 24) +
+ (ptr[3] << 16) +
+ (ptr[4] << 8) +
+ ptr[5]
+ ;
+ }
+ else
+ {
+ bool oddInd = (ptr[1] & 0x08)? true: false;
+
+ mobileId.numDigits = (totalLength - 2) * 2;
+ if(oddInd) mobileId.numDigits +=1;
+
+ mobileId.digits[0] = ptr[1] >> 4;
+
+ int bufferIndex, digitIndex;
+ for(bufferIndex=2, digitIndex = 1;
+ bufferIndex < totalLength;
+ bufferIndex++)
+ {
+ mobileId.digits[digitIndex++] =
+ ptr[bufferIndex] & 0x0f;
+ mobileId.digits[digitIndex++] =
+ ptr[bufferIndex] >> 4;
+ }
+ }
+
+ maxlength -= totalLength;
+ ptr += totalLength;
+
+ return TRUE;
+}
+
+
+// T_AUTH_TRIPLET is defined in the C only header file and used in embedded C only struct,
+// so can't pass by reference
+BOOL GGLINK_DECODE_AUTH_TRIPLET(
+ int &maxlength, // max length of input buffer
+ unsigned char * &ptr, // starting address of input buffer
+ T_AUTH_TRIPLET *triplet // output IE data structure
+ )
+{
+ int i;
+ int tripletlength = SEC_RAND_LEN + SEC_SRES_LEN + SEC_KC_LEN;
+
+ if(maxlength < tripletlength) return FALSE;
+ for(i=0;i<SEC_RAND_LEN;i++) triplet->RAND[i] = *ptr++;
+ for(i=0;i<SEC_SRES_LEN;i++) triplet->SRES[i] = *ptr++;
+ for(i=0;i<SEC_KC_LEN;i++) triplet->Kc[i] = *ptr++;
+ maxlength -= tripletlength;
+
+ return TRUE;
+}
+
+BOOL GGLINK_DECODE_IE_AUTH_LIST(
+ int &maxlength, // max length of input buffer
+ unsigned char * &ptr, // starting address of input buffer
+ T_SEC_IE_AUTH_LIST &auth_set // output IE data structure
+ )
+{
+ int i, num;
+
+ auth_set.num_set = num = *ptr++;
+ maxlength--;
+
+ if(num > SEC_MAX_TRIPLET){
+ printf("Err. auth triplet list number too large : %d\n", num);
+ return FALSE;
+ }
+
+ for(i=0; i<num; i++){
+ if (!GGLINK_DECODE_AUTH_TRIPLET(maxlength, ptr, &auth_set.triplet[i]))
+ return FALSE;
+ }
+
+ // sanity check
+ if (maxlength < 0) {
+ printf("GGLINK_DECODE_IE_AUTH_LIST buffer length too short \n");
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+BOOL
+GGLINK_DECODE_IE_ROUTING_AREA_ID(
+ int &maxlength, // max length of input buffer
+ unsigned char * &ptr, // starting address of input buffer
+ T_CNI_RIL3_IE_ROUTING_AREA_ID &ie // output IE data structure
+ )
+{
+ if(maxlength<6) return FALSE;
+
+ // IE-specific processing
+ ie.ie_present = true;
+
+ ie.mcc[0] = (*ptr) & 0x0F; // MCC 1
+ ie.mcc[1] = ((*ptr) & 0xF0) >> 4; // MCC 2
+ ptr++;
+ ie.mcc[2] = (*ptr) & 0x0F; // MCC 3
+ ie.mnc[2] = ((*ptr) & 0xF0) >> 4; // MNC 3
+ ptr++;
+ ie.mnc[0] = (*ptr) & 0x0F; // MNC 1
+ ie.mnc[1] = ((*ptr) & 0xF0) >> 4; // MNC 2
+ ptr++;
+ ie.lac = *ptr++;
+ ie.lac = (ie.lac << 8) + *ptr++;
+ ie.rac = *ptr++;
+
+ maxlength-=6;
+
+ return TRUE;
+}
+
+BOOL
+GGLINK_DECODE_API_MSG_GS_SRQ(
+ int &maxlength, // max length of input buffer
+ unsigned char * &ptr, // starting address of input buffer
+ GGLINK_API_MSG &msg // output msg data structure
+ )
+{
+ msg.msg_type = GGLINK_API_MSG_GS_SRQ;
+
+ return GGLINK_DECODE_IE_MOBILE_ID(maxlength, ptr, msg.msg.security_req.imsi);
+}
+
+
+BOOL
+GGLINK_DECODE_API_MSG_GS_SRS(
+ int &maxlength, // max length of input buffer
+ unsigned char * &ptr, // starting address of input buffer
+ GGLINK_API_MSG &msg // output msg data structure
+ )
+{
+ msg.msg_type = GGLINK_API_MSG_GS_SRS;
+
+ if (!GGLINK_DECODE_IE_MOBILE_ID(maxlength, ptr, msg.msg.security_rsp.imsi))
+ return FALSE;
+
+ return GGLINK_DECODE_IE_AUTH_LIST(maxlength, ptr, msg.msg.security_rsp.triplet_list);
+}
+
+BOOL
+GGLINK_DECODE_API_MSG_GS_RRQ(
+ int &maxlength, // max length of input buffer
+ unsigned char * &ptr, // starting address of input buffer
+ GGLINK_API_MSG &msg // output msg data structure
+ )
+{
+ msg.msg_type = GGLINK_API_MSG_GS_RRQ;
+
+ if (!GGLINK_DECODE_IE_MOBILE_ID(maxlength, ptr, msg.msg.ra_update_req.imsi))
+ return FALSE;
+
+ return GGLINK_DECODE_IE_ROUTING_AREA_ID(maxlength, ptr, msg.msg.ra_update_req.rai);
+}
+
+BOOL
+GGLINK_DECODE_API_MSG_GS_RCF(
+ int &maxlength, // max length of input buffer
+ unsigned char * &ptr, // starting address of input buffer
+ GGLINK_API_MSG &msg // output msg data structure
+ )
+{
+ msg.msg_type = GGLINK_API_MSG_GS_RCF;
+
+ return GGLINK_DECODE_IE_MOBILE_ID(maxlength, ptr, msg.msg.ra_update_cnf.imsi);
+
+}
+
+BOOL
+GGLINK_DECODE_API_MSG_GS_RRJ(
+ int &maxlength, // max length of input buffer
+ unsigned char * &ptr, // starting address of input buffer
+ GGLINK_API_MSG &msg // output msg data structure
+ )
+{
+ msg.msg_type = GGLINK_API_MSG_GS_RRJ;
+
+ if (!GGLINK_DECODE_IE_MOBILE_ID(maxlength, ptr, msg.msg.ra_update_rej.imsi))
+ return FALSE;
+
+ short rejectCause;
+ if (!GGLINK_UNPACK_SHORT(maxlength, ptr, rejectCause))
+ return FALSE;
+
+ msg.msg.ra_update_rej.cause = (T_CNI_RIL3_REJECT_CAUSE_VALUE)rejectCause;
+ return TRUE;
+}
+
+BOOL
+GGLINK_DECODE_API_MSG_GS_PRQ(
+ int &maxlength, // max length of input buffer
+ unsigned char * &ptr, // starting address of input buffer
+ GGLINK_API_MSG &msg // output msg data structure
+ )
+{
+ msg.msg_type = GGLINK_API_MSG_GS_PRQ;
+
+ return GGLINK_DECODE_IE_MOBILE_ID(maxlength, ptr, msg.msg.profile_req.imsi);
+
+}
+
+BOOL
+GGLINK_DECODE_API_MSG_GS_PRS(
+ int &maxlength, // max length of input buffer
+ unsigned char * &ptr, // starting address of input buffer
+ GGLINK_API_MSG &msg // output msg data structure
+ )
+{
+ msg.msg_type = GGLINK_API_MSG_GS_PRS;
+
+ if (!GGLINK_DECODE_IE_MOBILE_ID(maxlength, ptr, msg.msg.profile_rsp.imsi))
+ return FALSE;
+
+ if (!GGLINK_UNPACK_SHORT(maxlength, ptr, msg.msg.profile_rsp.data_size))
+ return FALSE;
+
+ if(msg.msg.profile_rsp.data_size > 1024) {
+ printf("GGLINK_DECODE_API_MSG_GS_PRS data length too long", msg.msg.profile_rsp.data_size);
+ return FALSE;
+ }
+
+ return GGLINK_UNPACK_STRING(maxlength, msg.msg.profile_rsp.data_size, ptr, (unsigned char *)msg.msg.profile_rsp.data);
+
+}
+
+BOOL
+GGLINK_DECODE_API_MSG_GS_URQ(
+ int &maxlength, // max length of input buffer
+ unsigned char * &ptr, // starting address of input buffer
+ GGLINK_API_MSG &msg // output msg data structure
+ )
+{
+ msg.msg_type = GGLINK_API_MSG_GS_URQ;
+
+ return GGLINK_DECODE_IE_MOBILE_ID(maxlength, ptr, msg.msg.unregister_req.imsi);
+
+}
+
+BOOL
+GGLINK_DECODE_API_MSG_SRI_REQ(
+ int &maxlength, // max length of input buffer
+ unsigned char * &ptr, // starting address of input buffer
+ GGLINK_API_MSG &msg // output msg data structure
+ )
+{
+ msg.msg_type = GGLINK_API_MSG_SRI_REQ;
+
+ if(!GGLINK_UNPACK_SHORT(maxlength, ptr, msg.msg.send_routing_info_req.gsn_seqno))
+ return FALSE;
+
+ if(!GGLINK_DECODE_IE_MOBILE_ID(maxlength, ptr, msg.msg.send_routing_info_req.imsi))
+ return FALSE;
+
+ return GGLINK_DECODE_IE_GSN_ADDRESS(maxlength, ptr, msg.msg.send_routing_info_ack.ggsn_addr);
+}
+
+BOOL
+GGLINK_DECODE_API_MSG_SRI_ACK(
+ int &maxlength, // max length of input buffer
+ unsigned char * &ptr, // starting address of input buffer
+ GGLINK_API_MSG &msg // output msg data structure
+ )
+{
+ msg.msg_type = GGLINK_API_MSG_SRI_ACK;
+
+ if (!GGLINK_UNPACK_SHORT(maxlength, ptr, msg.msg.send_routing_info_req.gsn_seqno))
+ return FALSE;
+
+ if (!GGLINK_DECODE_IE_CAUSE(maxlength, ptr, msg.msg.send_routing_info_ack.cause))
+ return FALSE;
+
+ if (!GGLINK_DECODE_IE_MOBILE_ID(maxlength, ptr, msg.msg.send_routing_info_ack.imsi))
+ return FALSE;
+
+ if (msg.msg.send_routing_info_ack.cause.cause_code == GGLINK_CAUSE_REQ_ACCEPTED) {
+ if(!GGLINK_DECODE_IE_GSN_ADDRESS(maxlength, ptr, msg.msg.send_routing_info_ack.sgsn_addr))
+ return FALSE;
+
+ return GGLINK_DECODE_IE_GSN_ADDRESS(maxlength, ptr, msg.msg.send_routing_info_ack.ggsn_addr);
+ } else {
+ return GGLINK_DECODE_IE_MAP_CAUSE(maxlength, ptr, msg.msg.send_routing_info_ack.map_cause);
+ }
+}
+
+BOOL
+GGLINK_DECODE_API_MSG_FR(
+ int &maxlength, // max length of input buffer
+ unsigned char * &ptr, // starting address of input buffer
+ GGLINK_API_MSG &msg // output msg data structure
+ )
+{
+ msg.msg_type = GGLINK_API_MSG_FR;
+
+
+ if (!GGLINK_UNPACK_SHORT(maxlength, ptr, msg.msg.fr_req.gsn_seqno))
+ return FALSE;
+
+ return GGLINK_DECODE_IE_MOBILE_ID(maxlength, ptr, msg.msg.fr_req.imsi);
+
+}
+
+BOOL
+GGLINK_DECODE_API_MSG_FR_ACK(
+ int &maxlength, // max length of input buffer
+ unsigned char * &ptr, // starting address of input buffer
+ GGLINK_API_MSG &msg // output msg data structure
+ )
+{
+ msg.msg_type = GGLINK_API_MSG_FR_ACK;
+
+
+ if (!GGLINK_UNPACK_SHORT(maxlength, ptr, msg.msg.fr_ack.gsn_seqno))
+ return FALSE;
+
+ if(! GGLINK_DECODE_IE_MOBILE_ID(maxlength, ptr, msg.msg.fr_ack.imsi))
+ return FALSE;
+
+
+ if(! GGLINK_DECODE_IE_CAUSE(maxlength, ptr, msg.msg.fr_ack.cause))
+ return FALSE;
+
+ msg.msg.fr_ack.map_cause.ie_present = false;
+ if(msg.msg.fr_ack.cause.cause_code != GGLINK_CAUSE_REQ_ACCEPTED)
+ return GGLINK_DECODE_IE_MAP_CAUSE(maxlength, ptr, msg.msg.fr_ack.map_cause);
+
+ return TRUE;
+}
+
+BOOL
+GGLINK_DECODE_API_MSG_GPRS_PRE(
+ int &maxlength, // max length of input buffer
+ unsigned char * &ptr, // starting address of input buffer
+ GGLINK_API_MSG &msg // output msg data structure
+ )
+{
+ msg.msg_type = GGLINK_API_MSG_GPRS_PRE;
+
+ if (!GGLINK_DECODE_IE_MOBILE_ID(maxlength, ptr, msg.msg.ms_gprs_pre_req.imsi))
+ return FALSE;
+
+ return GGLINK_DECODE_IE_GSN_ADDRESS(maxlength, ptr, msg.msg.ms_gprs_pre_req.gsn_addr);
+
+}
+
+BOOL
+GGLINK_DECODE_API_MSG_GPRS_PRE_ACK(
+ int &maxlength, // max length of input buffer
+ unsigned char * &ptr, // starting address of input buffer
+ GGLINK_API_MSG &msg // output msg data structure
+ )
+{
+ msg.msg_type = GGLINK_API_MSG_GPRS_PRE_ACK;
+
+
+ if (!GGLINK_DECODE_IE_MOBILE_ID(maxlength, ptr, msg.msg.ms_gprs_pre_ack.imsi))
+ return FALSE;
+
+ return GGLINK_DECODE_IE_GSN_ADDRESS(maxlength, ptr, msg.msg.ms_gprs_pre_ack.gsn_addr);
+
+}
+
+BOOL
+GGLINK_DECODE_API_MSG_SSRI_REQ(
+ int &maxlength, // max length of input buffer
+ unsigned char * &ptr, // starting address of input buffer
+ GGLINK_API_MSG &msg // output msg data structure
+ )
+{
+ msg.msg_type = GGLINK_API_MSG_SSRI_REQ;
+
+
+ if (!GGLINK_UNPACK_SHORT(maxlength, ptr, msg.msg.ssri_req.gsn_seqno))
+ return FALSE;
+
+ return GGLINK_DECODE_IE_ROUTING_AREA_ID(maxlength, ptr, msg.msg.ssri_req.rai);
+
+}
+
+BOOL
+GGLINK_DECODE_API_MSG_SSRI_RSP(
+ int &maxlength, // max length of input buffer
+ unsigned char * &ptr, // starting address of input buffer
+ GGLINK_API_MSG &msg // output msg data structure
+ )
+{
+ msg.msg_type = GGLINK_API_MSG_SSRI_RSP;
+
+
+ if (!GGLINK_UNPACK_SHORT(maxlength, ptr, msg.msg.ssri_rsp.gsn_seqno))
+ return FALSE;
+
+ if (!GGLINK_DECODE_IE_CAUSE(maxlength, ptr, msg.msg.ssri_rsp.cause))
+ return FALSE;
+
+ if (!GGLINK_DECODE_IE_ROUTING_AREA_ID(maxlength, ptr, msg.msg.ssri_rsp.rai))
+ return FALSE;
+
+ return GGLINK_DECODE_IE_GSN_ADDRESS(maxlength, ptr, msg.msg.ssri_rsp.sgsn_addr);
+
+}
+
+/*
+ * DecodeGGLinkMessage
+ */
+BOOL
+DecodeGGLinkMessage(
+ int &maxlength, // max length of input buffer
+ unsigned char * &ptr, // starting address of input buffer
+ GGLINK_API_MSG &msg // output msg data structure
+ )
+{
+ short msgType, magic;
+ if (!GGLINK_UNPACK_SHORT(maxlength, ptr, msgType))
+ return FALSE;
+
+ // decode magic field
+ if(!GGLINK_UNPACK_SHORT(maxlength, ptr, magic))
+ return FALSE;
+ msg.magic = magic;
+
+ switch(msgType) /* message type */
+ {
+ case GGLINK_API_MSG_GS_SRQ:
+ return GGLINK_DECODE_API_MSG_GS_SRQ(maxlength, ptr, msg);
+ case GGLINK_API_MSG_GS_SRS:
+ return GGLINK_DECODE_API_MSG_GS_SRS(maxlength, ptr, msg);
+ case GGLINK_API_MSG_GS_RRQ:
+ return GGLINK_DECODE_API_MSG_GS_RRQ(maxlength, ptr, msg);
+ case GGLINK_API_MSG_GS_RCF:
+ return GGLINK_DECODE_API_MSG_GS_RCF(maxlength, ptr, msg);
+ case GGLINK_API_MSG_GS_RRJ:
+ return GGLINK_DECODE_API_MSG_GS_RRJ(maxlength, ptr, msg);
+ case GGLINK_API_MSG_GS_PRQ:
+ return GGLINK_DECODE_API_MSG_GS_PRQ(maxlength, ptr, msg);
+ case GGLINK_API_MSG_GS_PRS:
+ return GGLINK_DECODE_API_MSG_GS_PRS(maxlength, ptr, msg);
+ case GGLINK_API_MSG_GS_URQ:
+ return GGLINK_DECODE_API_MSG_GS_URQ(maxlength, ptr, msg);
+ case GGLINK_API_MSG_SRI_REQ:
+ return GGLINK_DECODE_API_MSG_SRI_REQ(maxlength, ptr, msg);
+ case GGLINK_API_MSG_SRI_ACK:
+ return GGLINK_DECODE_API_MSG_SRI_ACK(maxlength, ptr, msg);
+ case GGLINK_API_MSG_FR:
+ return GGLINK_DECODE_API_MSG_FR(maxlength, ptr, msg);
+ case GGLINK_API_MSG_FR_ACK:
+ return GGLINK_DECODE_API_MSG_FR_ACK(maxlength, ptr, msg);
+ case GGLINK_API_MSG_GPRS_PRE:
+ return GGLINK_DECODE_API_MSG_GPRS_PRE(maxlength, ptr, msg);
+ case GGLINK_API_MSG_GPRS_PRE_ACK:
+ return GGLINK_DECODE_API_MSG_GPRS_PRE_ACK(maxlength, ptr, msg);
+ case GGLINK_API_MSG_SSRI_REQ:
+ return GGLINK_DECODE_API_MSG_SSRI_REQ(maxlength, ptr, msg);
+ case GGLINK_API_MSG_SSRI_RSP:
+ return GGLINK_DECODE_API_MSG_SSRI_RSP(maxlength, ptr, msg);
+ case GGLINK_API_MSG_ECHO_REQ:
+ msg.msg_type = GGLINK_API_MSG_ECHO_REQ;
+ return TRUE;
+ case GGLINK_API_MSG_ECHO_RSP:
+ msg.msg_type = GGLINK_API_MSG_ECHO_RSP;
+ return TRUE;
+
+ default:
+ printf( "Decode error: Non supported message for gglink %d\n",msgType);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/*************************************************************************************************************/
+inline BOOL
+GGLINK_PACK_SHORT(
+ int &maxlength, // max length of output buffer
+ unsigned char * &ptr, // starting address of output buffer
+ short value
+ )
+{
+ if(maxlength < 2)
+ return FALSE;
+ *ptr++ = value>>8;
+ *ptr++ = (unsigned char) value;
+
+ maxlength-=2;
+
+ return TRUE;
+}
+
+inline BOOL
+GGLINK_PACK_BYTE(
+ int &maxlength, // max length of output buffer
+ unsigned char * &ptr, // starting address of output buffer
+ unsigned char value
+ )
+{
+ if (maxlength < 1)
+ return FALSE;
+
+ *ptr++ = value;
+ maxlength--;
+
+ return TRUE;
+}
+
+inline BOOL
+GGLINK_PACK_STRING(
+ int &maxlength, // max length of output buffer
+ int stringlength, // size of the string to be packed
+ unsigned char * &ptr, // starting address of output buffer
+ unsigned char * src
+ )
+{
+ if(maxlength < stringlength)
+ return FALSE;
+
+ memcpy(ptr, src, stringlength);
+ ptr += stringlength;
+ maxlength -= stringlength;
+
+ return TRUE;
+}
+
+BOOL GGLINK_ENCODE_IE_CAUSE(
+ int &maxlength, // max length of output buffer
+ unsigned char * &ptr, // starting address of output buffer
+ GGLINK_IE_CAUSE &cause // input IE data structure
+ )
+{
+ if(!cause.ie_present) return FALSE;
+ return GGLINK_PACK_BYTE(maxlength, ptr, cause.cause_code);
+}
+
+BOOL GGLINK_ENCODE_IE_MAP_CAUSE(
+ int &maxlength, // max length of output buffer
+ unsigned char * &ptr, // starting address of output buffer
+ GGLINK_IE_MAP_CAUSE &map_cause // input IE data structure
+ )
+{
+ if(!map_cause.ie_present) return FALSE;
+ return GGLINK_PACK_BYTE(maxlength, ptr, map_cause.map_error_code);
+
+}
+
+
+
+BOOL GGLINK_ENCODE_IE_GSN_ADDRESS(
+ int &maxlength, // max length of output buffer
+ unsigned char * &ptr, // starting address of output buffer
+ GGLINK_IE_GSN_ADDRESS &gsn_address // input IE data structure
+ )
+{
+
+ if (!GGLINK_PACK_SHORT(maxlength, ptr, gsn_address.gsn_addr_length))
+ return FALSE;
+
+ if(gsn_address.gsn_addr_length > 16 ||
+ gsn_address.gsn_addr_length < 0)
+ return FALSE;
+
+ return GGLINK_PACK_STRING(maxlength, gsn_address.gsn_addr_length, ptr, gsn_address.addr_octets);
+}
+
+
+BOOL
+GGLINK_ENCODE_IE_MOBILE_ID(
+ int &maxlength, // max length of output buffer
+ unsigned char * &ptr, // starting address of output buffer
+ T_CNI_RIL3_IE_MOBILE_ID &mobileId // input IE data structure
+ )
+{
+
+ if(mobileId.ie_present == FALSE)
+ return FALSE;
+
+ ptr[1] = mobileId.mobileIdType;
+
+ if(mobileId.mobileIdType == CNI_RIL3_TMSI)
+ {
+ ptr[0] = 5;
+ ptr[1] |= 0xf0;
+ ptr[2] = (unsigned char) (mobileId.tmsi >> 24);
+ ptr[3] = (unsigned char) (mobileId.tmsi >> 16);
+ ptr[4] = (unsigned char) (mobileId.tmsi >> 8);
+ ptr[5] = (unsigned char) (mobileId.tmsi);
+ maxlength -= 6;
+ ptr += 6;
+ } else
+ {
+
+ unsigned char odd = (mobileId.numDigits % 2)? 0x08: 0x00;
+
+ if (mobileId.numDigits <0 || mobileId.numDigits>CNI_RIL3_MAX_ID_DIGITS)
+ return FALSE;
+
+ int ieLength = 2 + (mobileId.numDigits/2);
+ ptr[0] = ieLength - 1;
+ ptr[1] |= ((mobileId.digits[0] << 4) | odd);
+
+ maxlength -=ieLength;
+
+ if(mobileId.numDigits < 2)
+ {
+ ptr +=ieLength;
+ return TRUE;
+ }
+
+ int bufferIndex = 2;
+ int loopCount = (mobileId.numDigits/2) - 1 ;
+ int digit;
+ int i;
+ for(i=0, digit=1; i < loopCount; i++)
+ {
+ ptr[bufferIndex] = mobileId.digits[digit++];
+ ptr[bufferIndex++] |= mobileId.digits[digit++] << 4;
+ }
+
+ if(odd)
+ {
+ ptr[bufferIndex] = mobileId.digits[digit++];
+ ptr[bufferIndex] |= mobileId.digits[digit++] << 4;
+ }
+ else // even digits
+ {
+ // encode last digit
+ ptr[bufferIndex] = mobileId.digits[digit] | 0xf0;
+ }
+
+ ptr += ieLength;
+ }
+
+ return TRUE;
+}
+
+
+bool GGLINK_ENCODE_AUTH_TRIPLET(
+ int &maxlength, // max length of output buffer
+ unsigned char * &ptr, // starting address of output buffer
+ T_AUTH_TRIPLET *triplet // input IE data structure
+ )
+{
+
+ int tripletlength = SEC_RAND_LEN + SEC_SRES_LEN + SEC_KC_LEN;
+ if (maxlength < tripletlength)
+ return FALSE;
+
+ if (!GGLINK_PACK_STRING(maxlength, SEC_RAND_LEN, ptr, triplet->RAND))
+ return FALSE;
+
+
+ if (!GGLINK_PACK_STRING(maxlength, SEC_SRES_LEN, ptr, triplet->SRES))
+ return FALSE;
+
+
+ if (!GGLINK_PACK_STRING(maxlength, SEC_KC_LEN, ptr, triplet->Kc))
+ return FALSE;
+
+ return TRUE;
+}
+
+BOOL GGLINK_ENCODE_IE_AUTH_LIST(
+ int &maxlength, // max length of output buffer
+ unsigned char * &ptr, // starting address of output buffer
+ T_SEC_IE_AUTH_LIST &auth_set // input IE data structure
+ )
+{
+
+ if(auth_set.num_set > SEC_MAX_TRIPLET){
+ printf("GGLINK_ENCODE_IE_AUTH_LIST Err. auth triplet list number too large : %d\n", auth_set.num_set);
+ return FALSE;
+ }
+
+ if (!GGLINK_PACK_BYTE(maxlength, ptr, (unsigned char) auth_set.num_set))
+ return FALSE;
+
+ int i;
+ for(i=0; i < auth_set.num_set; i++){
+ if (!GGLINK_ENCODE_AUTH_TRIPLET(maxlength, ptr, &auth_set.triplet[i]))
+ return FALSE;
+ }
+ return TRUE;
+}
+
+BOOL GGLINK_ENCODE_IE_ROUTING_AREA_ID(
+ int &maxlength, // max length of output buffer
+ unsigned char * &ptr, // starting address of output buffer
+ T_CNI_RIL3_IE_ROUTING_AREA_ID &ie // input IE data structure
+ )
+{
+ if( maxlength < 6 ) return FALSE; // make sure we have enough bufferd for LV field
+
+ *ptr++ = (ie.mcc[1] << 4) | (ie.mcc[0] & 0x0f);
+ *ptr++ = (ie.mnc[2] << 4) | (ie.mcc[2] & 0x0f);
+ *ptr++ = (ie.mnc[1] << 4) | (ie.mnc[0] & 0x0f);
+ *ptr++ = ie.lac >> 8;
+ *ptr++ = (unsigned char) ie.lac;
+ *ptr++ = ie.rac;
+
+ maxlength -= 6;
+
+ return TRUE;
+}
+
+BOOL
+GGLINK_ENCODE_API_MSG_GS_SRQ(
+ int &maxlength, // max length of output buffer
+ unsigned char * &ptr, // starting address of output buffer
+ GGLINK_API_MSG &msg // input msg data structure
+ )
+{
+
+ return GGLINK_ENCODE_IE_MOBILE_ID(maxlength, ptr, msg.msg.security_req.imsi) ;
+
+}
+
+
+BOOL
+GGLINK_ENCODE_API_MSG_GS_SRS(
+ int &maxlength, // max length of output buffer
+ unsigned char * &ptr, // starting address of output buffer
+ GGLINK_API_MSG &msg // input msg data structure
+ )
+{
+
+ if (! GGLINK_ENCODE_IE_MOBILE_ID(maxlength, ptr, msg.msg.security_rsp.imsi))
+ return FALSE;
+
+ return GGLINK_ENCODE_IE_AUTH_LIST(maxlength, ptr, msg.msg.security_rsp.triplet_list);
+}
+
+BOOL
+GGLINK_ENCODE_API_MSG_GS_RRQ(
+ int &maxlength, // max length of output buffer
+ unsigned char * &ptr, // starting address of output buffer
+ GGLINK_API_MSG &msg // input msg data structure
+ )
+{
+ if (!GGLINK_ENCODE_IE_MOBILE_ID(maxlength, ptr, msg.msg.ra_update_req.imsi))
+ return FALSE;
+
+ return GGLINK_ENCODE_IE_ROUTING_AREA_ID(maxlength, ptr, msg.msg.ra_update_req.rai);
+}
+
+BOOL
+GGLINK_ENCODE_API_MSG_GS_RCF(
+ int &maxlength, // max length of output buffer
+ unsigned char * &ptr, // starting address of output buffer
+ GGLINK_API_MSG &msg // input msg data structure
+ )
+{
+ return GGLINK_ENCODE_IE_MOBILE_ID(maxlength, ptr, msg.msg.ra_update_cnf.imsi);
+
+}
+
+BOOL
+GGLINK_ENCODE_API_MSG_GS_RRJ(
+ int &maxlength, // max length of output buffer
+ unsigned char * &ptr, // starting address of output buffer
+ GGLINK_API_MSG &msg // input msg data structure
+ )
+{
+ if (!GGLINK_ENCODE_IE_MOBILE_ID(maxlength, ptr, msg.msg.ra_update_rej.imsi))
+ return FALSE;
+
+ return GGLINK_PACK_SHORT(maxlength, ptr, msg.msg.ra_update_rej.cause);
+
+}
+
+BOOL
+GGLINK_ENCODE_API_MSG_GS_PRQ(
+ int &maxlength, // max length of output buffer
+ unsigned char * &ptr, // starting address of output buffer
+ GGLINK_API_MSG &msg // input msg data structure
+ )
+{
+
+ return GGLINK_ENCODE_IE_MOBILE_ID(maxlength, ptr, msg.msg.profile_req.imsi);
+
+}
+
+BOOL
+GGLINK_ENCODE_API_MSG_GS_PRS(
+ int &maxlength, // max length of output buffer
+ unsigned char * &ptr, // starting address of output buffer
+ GGLINK_API_MSG &msg // input msg data structure
+ )
+{
+ if(msg.msg.profile_rsp.data_size > 1024) {
+ printf("GGLINK_ENCODE_API_MSG_GS_PRS data length too long", msg.msg.profile_rsp.data_size);
+ return FALSE;
+ }
+
+ if (!GGLINK_ENCODE_IE_MOBILE_ID(maxlength, ptr, msg.msg.profile_rsp.imsi))
+ return FALSE;
+
+ if (!GGLINK_PACK_SHORT(maxlength, ptr, msg.msg.profile_rsp.data_size))
+ return FALSE;
+
+ return GGLINK_PACK_STRING(maxlength, msg.msg.profile_rsp.data_size, ptr,
+ (unsigned char *)msg.msg.profile_rsp.data);
+
+}
+
+BOOL
+GGLINK_ENCODE_API_MSG_GS_URQ(
+ int &maxlength, // max length of output buffer
+ unsigned char * &ptr, // starting address of output buffer
+ GGLINK_API_MSG &msg // input msg data structure
+ )
+{
+
+ return GGLINK_ENCODE_IE_MOBILE_ID(maxlength, ptr, msg.msg.unregister_req.imsi);
+
+}
+
+BOOL
+GGLINK_ENCODE_API_MSG_SRI_REQ(
+ int &maxlength, // max length of output buffer
+ unsigned char * &ptr, // starting address of output buffer
+ GGLINK_API_MSG &msg // input msg data structure
+ )
+{
+
+ if(!GGLINK_PACK_SHORT(maxlength, ptr, msg.msg.send_routing_info_req.gsn_seqno))
+ return FALSE;
+
+ if(!GGLINK_ENCODE_IE_MOBILE_ID(maxlength, ptr, msg.msg.send_routing_info_req.imsi))
+ return FALSE;
+
+ return GGLINK_ENCODE_IE_GSN_ADDRESS(maxlength, ptr, msg.msg.send_routing_info_req.ggsn_addr);
+}
+
+BOOL
+GGLINK_ENCODE_API_MSG_SRI_ACK(
+ int &maxlength, // max length of output buffer
+ unsigned char * &ptr, // starting address of output buffer
+ GGLINK_API_MSG &msg // input msg data structure
+ )
+{
+
+ if (!GGLINK_PACK_SHORT(maxlength, ptr, msg.msg.send_routing_info_req.gsn_seqno))
+ return FALSE;
+
+ if (!GGLINK_ENCODE_IE_CAUSE(maxlength, ptr, msg.msg.send_routing_info_ack.cause))
+ return FALSE;
+
+ if (!GGLINK_ENCODE_IE_MOBILE_ID(maxlength, ptr, msg.msg.send_routing_info_ack.imsi))
+ return FALSE;
+
+ if (msg.msg.send_routing_info_ack.cause.cause_code == GGLINK_CAUSE_REQ_ACCEPTED) {
+ if(!GGLINK_ENCODE_IE_GSN_ADDRESS(maxlength, ptr, msg.msg.send_routing_info_ack.sgsn_addr))
+ return FALSE;
+ return GGLINK_ENCODE_IE_GSN_ADDRESS(maxlength, ptr, msg.msg.send_routing_info_ack.ggsn_addr);
+ } else {
+ return GGLINK_ENCODE_IE_MAP_CAUSE(maxlength, ptr, msg.msg.send_routing_info_ack.map_cause);
+ }
+
+}
+
+BOOL
+GGLINK_ENCODE_API_MSG_FR(
+ int &maxlength, // max length of output buffer
+ unsigned char * &ptr, // starting address of output buffer
+ GGLINK_API_MSG &msg // input msg data structure
+ )
+{
+
+ if (!GGLINK_PACK_SHORT(maxlength, ptr, msg.msg.fr_req.gsn_seqno))
+ return FALSE;
+
+ return GGLINK_ENCODE_IE_MOBILE_ID(maxlength, ptr, msg.msg.fr_req.imsi);
+
+}
+
+BOOL
+GGLINK_ENCODE_API_MSG_FR_ACK(
+ int &maxlength, // max length of output buffer
+ unsigned char * &ptr, // starting address of output buffer
+ GGLINK_API_MSG &msg // input msg data structure
+ )
+{
+
+
+ if (!GGLINK_PACK_SHORT(maxlength, ptr, msg.msg.fr_ack.gsn_seqno))
+ return FALSE;
+
+ if(! GGLINK_ENCODE_IE_MOBILE_ID(maxlength, ptr, msg.msg.fr_ack.imsi))
+ return FALSE;
+
+ if(! GGLINK_ENCODE_IE_CAUSE(maxlength, ptr, msg.msg.fr_ack.cause))
+ return FALSE;
+
+ if(msg.msg.fr_ack.cause.cause_code != GGLINK_CAUSE_REQ_ACCEPTED)
+ return GGLINK_ENCODE_IE_MAP_CAUSE(maxlength, ptr, msg.msg.fr_ack.map_cause);
+
+ if(msg.msg.fr_ack.map_cause.ie_present)
+ {
+ printf("GGLINK_ENCODE_API_MSG_FR_ACK:Map cause should not be included if cause code is REQ ACCPETED\n");
+ }
+
+ return TRUE;
+
+}
+
+BOOL
+GGLINK_ENCODE_API_MSG_GPRS_PRE(
+ int &maxlength, // max length of output buffer
+ unsigned char * &ptr, // starting address of output buffer
+ GGLINK_API_MSG &msg // input msg data structure
+ )
+{
+
+ if (!GGLINK_ENCODE_IE_MOBILE_ID(maxlength, ptr, msg.msg.ms_gprs_pre_req.imsi))
+ return FALSE;
+
+ return GGLINK_ENCODE_IE_GSN_ADDRESS(maxlength, ptr, msg.msg.ms_gprs_pre_req.gsn_addr);
+
+}
+
+BOOL
+GGLINK_ENCODE_API_MSG_GPRS_PRE_ACK(
+ int &maxlength, // max length of output buffer
+ unsigned char * &ptr, // starting address of output buffer
+ GGLINK_API_MSG &msg // input msg data structure
+ )
+{
+
+ if (!GGLINK_ENCODE_IE_MOBILE_ID(maxlength, ptr, msg.msg.ms_gprs_pre_ack.imsi))
+ return FALSE;
+
+ if (!GGLINK_ENCODE_IE_GSN_ADDRESS(maxlength, ptr, msg.msg.ms_gprs_pre_ack.gsn_addr))
+ return FALSE;
+
+ return GGLINK_ENCODE_IE_CAUSE(maxlength, ptr, msg.msg.ms_gprs_pre_ack.cause);
+}
+
+BOOL
+GGLINK_ENCODE_API_MSG_SSRI_REQ(
+ int &maxlength, // max length of input buffer
+ unsigned char * &ptr, // starting address of input buffer
+ GGLINK_API_MSG &msg // output msg data structure
+ )
+{
+
+ if (!GGLINK_PACK_SHORT(maxlength, ptr, msg.msg.ssri_req.gsn_seqno))
+ return FALSE;
+
+ return GGLINK_ENCODE_IE_ROUTING_AREA_ID(maxlength, ptr, msg.msg.ssri_req.rai);
+
+}
+
+BOOL
+GGLINK_ENCODE_API_MSG_SSRI_RSP(
+ int &maxlength, // max length of input buffer
+ unsigned char * &ptr, // starting address of input buffer
+ GGLINK_API_MSG &msg // output msg data structure
+ )
+{
+
+ if (!GGLINK_PACK_SHORT(maxlength, ptr, msg.msg.ssri_rsp.gsn_seqno))
+ return FALSE;
+
+ if (!GGLINK_ENCODE_IE_CAUSE(maxlength, ptr, msg.msg.ssri_rsp.cause))
+ return FALSE;
+
+ if (!GGLINK_ENCODE_IE_ROUTING_AREA_ID(maxlength, ptr, msg.msg.ssri_rsp.rai))
+ return FALSE;
+
+ return GGLINK_ENCODE_IE_GSN_ADDRESS(maxlength, ptr, msg.msg.ssri_rsp.sgsn_addr);
+
+}
+/*
+ * EncodeGGLinkMessage
+ */
+BOOL
+EncodeGGLinkMessage(int &nDataSize, unsigned char * &ptr, GGLINK_API_MSG &msg)
+{
+ BOOL retVal;
+ int initialLength;
+ unsigned char *pLength = ptr;
+ ptr +=2;
+ nDataSize-=2; // 2 bytes for length
+
+ initialLength = nDataSize;
+
+ // encode the message type
+ if(!GGLINK_PACK_SHORT(nDataSize, ptr, msg.msg_type))
+ return FALSE;
+ // encode magic field
+ if(!GGLINK_PACK_SHORT(nDataSize, ptr, msg.magic))
+ return FALSE;
+
+ switch(msg.msg_type) /* message type */
+ {
+ case GGLINK_API_MSG_GS_SRQ:
+ retVal = GGLINK_ENCODE_API_MSG_GS_SRQ(nDataSize, ptr, msg);
+ break;
+ case GGLINK_API_MSG_GS_SRS:
+ retVal = GGLINK_ENCODE_API_MSG_GS_SRS(nDataSize, ptr, msg);
+ break;
+ case GGLINK_API_MSG_GS_RRQ:
+ retVal = GGLINK_ENCODE_API_MSG_GS_RRQ(nDataSize, ptr, msg);
+ break;
+ case GGLINK_API_MSG_GS_RCF:
+ retVal = GGLINK_ENCODE_API_MSG_GS_RCF(nDataSize, ptr, msg);
+ break;
+ case GGLINK_API_MSG_GS_RRJ:
+ retVal = GGLINK_ENCODE_API_MSG_GS_RRJ(nDataSize, ptr, msg);
+ break;
+ case GGLINK_API_MSG_GS_PRQ:
+ retVal = GGLINK_ENCODE_API_MSG_GS_PRQ(nDataSize, ptr, msg);
+ break;
+ case GGLINK_API_MSG_GS_PRS:
+ retVal = GGLINK_ENCODE_API_MSG_GS_PRS(nDataSize, ptr, msg);
+ break;
+ case GGLINK_API_MSG_GS_URQ:
+ retVal = GGLINK_ENCODE_API_MSG_GS_URQ(nDataSize, ptr, msg);
+ break;
+ case GGLINK_API_MSG_SRI_REQ:
+ retVal = GGLINK_ENCODE_API_MSG_SRI_REQ(nDataSize, ptr, msg);
+ break;
+ case GGLINK_API_MSG_SRI_ACK:
+ retVal = GGLINK_ENCODE_API_MSG_SRI_ACK(nDataSize, ptr, msg);
+ break;
+ case GGLINK_API_MSG_FR:
+ retVal = GGLINK_ENCODE_API_MSG_FR(nDataSize, ptr, msg);
+ break;
+ case GGLINK_API_MSG_FR_ACK:
+ retVal = GGLINK_ENCODE_API_MSG_FR_ACK(nDataSize, ptr, msg);
+ break;
+ case GGLINK_API_MSG_GPRS_PRE:
+ retVal = GGLINK_ENCODE_API_MSG_GPRS_PRE(nDataSize, ptr, msg);
+ break;
+ case GGLINK_API_MSG_GPRS_PRE_ACK:
+ retVal = GGLINK_ENCODE_API_MSG_GPRS_PRE_ACK(nDataSize, ptr, msg);
+ break;
+ case GGLINK_API_MSG_SSRI_REQ:
+ retVal = GGLINK_ENCODE_API_MSG_SSRI_REQ(nDataSize, ptr, msg);
+ break;
+ case GGLINK_API_MSG_SSRI_RSP:
+ retVal = GGLINK_ENCODE_API_MSG_SSRI_RSP(nDataSize, ptr, msg);
+ break;
+ case GGLINK_API_MSG_ECHO_REQ:
+ case GGLINK_API_MSG_ECHO_RSP:
+ retVal = TRUE;
+ break;
+
+ default:
+ printf( "Encode error: Non supported message for gglink %d\n",msg.msg_type);
+ return FALSE;
+ }
+
+ if(retVal)
+ {
+ int lengthLength = 2;
+ short encodedLength = initialLength- nDataSize;
+ retVal = GGLINK_PACK_SHORT(lengthLength, pLength, encodedLength);
+ nDataSize = encodedLength + 2;
+ }
+
+ return retVal;
+}
+
diff --git a/data/mnet/Common/include/CdrDbg.h b/data/mnet/Common/include/CdrDbg.h
new file mode 100644
index 0000000..5d9a3f0
--- /dev/null
+++ b/data/mnet/Common/include/CdrDbg.h
@@ -0,0 +1,130 @@
+#ifndef __CDRDBG_H__
+#define __CDRDBG_H__
+
+// *******************************************************************
+//
+// (c) Copyright CISCO Systems Inc. 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// File : CdrDbg.h
+// Author(s) : Igal Gutkin
+// Create Date : 8/22/00
+// Description :
+//
+// *******************************************************************
+
+
+#include "dbgfunc.h"
+
+
+/* Printing and\or sending to the logging module */
+
+#define AM_RETURN(x) {AM_LEAVE();return(x);}
+
+
+// Disable all the logging output
+#if (defined (__DISABLE_OUTPUT))
+
+ #define LAYER_ID 0
+ #define AM_ERROR(XX)
+ #define AM_WARNING(XX)
+ #define AM_HEXDUMP(x,y)
+ #define AM_TRACE(XX)
+ #define AM_DEBUG(XX)
+ #define AM_FUNC(x,y)
+ #define AM_ENTER()
+ #define AM_LEAVE()
+
+// GP10, GMC and GS application on VxWorks standard logging
+#elif (!defined(__STDIOUT) && defined(__VXWORKS__) && (defined(MNET_GP10) || defined(MNET_GMC) || defined(MNET_GS) ))
+
+ #ifdef _MNET_COMMON_LOGGING_MODULE_
+ #define AM_HEXDUMP(x,y) DBG_HEXDUMP_FMT(x,y)
+ #else
+ #define AM_HEXDUMP(x,y) DBG_HEXDUMP(x,y)
+ #endif // _MNET_COMMON_LOGGING_MODULE_
+
+ #define AM_ERROR(XX) DBG_ERROR XX
+ #define AM_WARNING(XX) DBG_WARNING XX
+ #define AM_TRACE(XX) DBG_TRACE XX
+ #define AM_DEBUG(XX) DBG_TRACE XX
+
+ #define AM_ENTER DBG_ENTER
+ #define AM_LEAVE DBG_LEAVE
+ #define AM_FUNC(x,y) DBG_FUNC (x,y)
+
+// Windows application using event logging
+#elif !(defined (_WIN_STDIO) || defined (__STDIOUT))
+
+// Support for the GMC Windows application debug output
+#if (defined(_WINDOWS_) || defined(WIN32)) && !(defined(_WIN_STDIO) || defined(__STDIOUT))
+#include "support.h" // fetch GMC on Windows debug interface definitions
+#endif // _WIN_STDIO
+
+ #define AM_HEXDUMP(x,y)
+ #define AM_ERROR(XX) DebugLogCritical XX
+
+ #ifdef _AM_WARNING_
+ #define AM_WARNING(XX) DebugLogWarning XX
+ #else
+ #define AM_WARNING(XX)
+ #endif
+
+ #ifdef _AM_TRACE_
+ #define AM_TRACE(XX) DebugLogInfo XX
+ #else
+ #define AM_TRACE(XX)
+ #endif
+
+ #ifdef _AM_DEBUG_
+ #define AM_DEBUG(XX) DebugLog XX
+ #define AM_FUNC(x,y) DebugLog("Entering function: %s\n",x)
+ #else
+ #define AM_DEBUG(XX)
+ #define AM_FUNC(x,y)
+ #endif
+
+ #define LAYER_ID 0
+ #define AM_ENTER()
+ #define AM_LEAVE()
+
+//Unspecified system. Use own debug system
+#else
+
+ #define AM_ERROR(XX) {printf("ERROR: ");dbg_print XX;putchar('\n');}
+
+ #ifdef _AM_WARNING_
+ #define AM_WARNING(XX) {printf("WARNING: ");dbg_print XX;putchar('\n');}
+ #else
+ #define AM_WARNING(XX)
+ #endif
+
+ #ifdef _AM_TRACE_
+ #define AM_TRACE(XX) {printf("TRACE: ");dbg_print XX;putchar('\n');}
+ #define AM_HEXDUMP(x,y) HexDump (x,y)
+ #else
+ #define AM_TRACE(XX)
+ #define AM_HEXDUMP(x,y)
+ #endif
+
+ #ifdef _AM_DEBUG_
+ #define AM_DEBUG(XX) {printf("DEBUG: ");dbg_print XX;putchar('\n');}
+ #define AM_FUNC(x,y) printf("Entering function: %s\n",x)
+ #else
+ #define AM_DEBUG(XX)
+ #define AM_FUNC(x,y)
+ #endif
+
+ #define LAYER_ID 0
+ #define AM_ENTER()
+ #define AM_LEAVE()
+
+#endif
+
+
+#endif //__CDRDBG_H__ \ No newline at end of file
diff --git a/data/mnet/Common/include/JCErr.h b/data/mnet/Common/include/JCErr.h
new file mode 100644
index 0000000..fd2cfb3
--- /dev/null
+++ b/data/mnet/Common/include/JCErr.h
@@ -0,0 +1,60 @@
+/*********************************************************************/
+/* */
+/* (c) Copyright Cisco 2000 */
+/* All Rights Reserved */
+/* */
+/*********************************************************************/
+
+/*********************************************************************/
+/* */
+/* Version : 1.0 */
+/* Status : Under development */
+/* File : JCErr.h */
+/* Author(s) : Tim Olson */
+/* Create Date : 9/18/2000 */
+/* Description : JCErr contains error code defintions for common */
+/* platform code. Error codes for specific modules */
+/* modules for a given target should be in the */
+/* <target name>Err.h file. */
+/* */
+/*********************************************************************/
+#ifndef _JCERR_H_
+#define _JCERR_H_ /* include once only */
+
+typedef int JC_STATUS; /* standard return type for common projects */
+
+
+#define JC_TARGET_ERR_CODE_START 512
+
+#define JC_OK 0 /* no error */
+
+/* VxWorks reserves module id's 1-500 */
+/* Common code uses - module number 0x1ff (511 decimal) */
+
+/* All platform specific error codes should be entered below here. */
+/* Format for error codes is as follows: */
+/* +-------------------------------------------+ */
+/* | Module Id + 512 | Error Code | */
+/* +-------------------------------------------+ */
+/* */
+/* 0x01ff0000 - Common code error codes */
+/* 0x02000000 - First target module error codes */
+/* 0x02010000 - Second target module error codes */
+/* . */
+/* . */
+/* 0xffff0000 - Last target module error codes */
+
+/* generic error code definitions -- module number 0x1ff (511 decimal) */
+typedef enum
+{
+ JC_COMMON_ERR_CODE_START = ((JC_TARGET_ERR_CODE_START-1) << 16),
+ JC_ERROR, /* general error */
+ JC_PARAM_INVALID, /* parameter is out of range */
+ JC_PARAM_MISSING, /* parameter missing */
+ JC_MSG_LENGTH_ERROR, /* invalid message length */
+ JC_INVALID_MSG /* message not expected or
+ invalid message type received */
+} JC_ERROR_CODES;
+
+
+#endif \ No newline at end of file
diff --git a/data/mnet/Common/include/JCStdDef.h b/data/mnet/Common/include/JCStdDef.h
new file mode 100644
index 0000000..ed65853
--- /dev/null
+++ b/data/mnet/Common/include/JCStdDef.h
@@ -0,0 +1,103 @@
+/*********************************************************************/
+/* */
+/* (c) Copyright Cisco 2000 */
+/* All Rights Reserved */
+/* */
+/*********************************************************************/
+
+/*********************************************************************/
+/* */
+/* Version : 1.0 */
+/* Status : Under development */
+/* File : JCStdDef.h */
+/* Author(s) : Tim Olson */
+/* Create Date : 9/18/2000 */
+/* Description : */
+/* */
+/*********************************************************************/
+#ifndef _JCSTDDEF_H_
+#define _JCSTDDEF_H_ /* include once only */
+
+/* If not building for vxWorks then we need to define the processors */
+/* used below. If vxWorks is used then these processors are */
+/* already defined. */
+#if !defined(__VXWORKS__)
+#define PENTIUM 1
+#define PPC860 2
+#define TI_C6201 3
+#endif
+
+/* If vxWorks is defined then the standard defs are specified in */
+/* the vxWorks tree. */
+
+#if defined(__VXWORKS__)
+
+#include <vxworks.h>
+
+#endif
+
+/* Standard definitions for PENTIUM */
+
+
+#if (CPU==PENTIUM && !defined(__VXWORKS__))
+
+typedef char INT8;
+typedef short INT16;
+typedef long INT32;
+typedef unsigned char UINT8;
+typedef unsigned short UINT16;
+typedef unsigned long UINT32;
+typedef unsigned char bool;
+
+#endif /* CPU=PENTIUM and __VXWORKS__*/
+
+
+
+/* Standard definitions for PPC860 */
+
+#if (CPU==PPC860 && !defined(__VXWORKS__))
+
+typedef char INT8;
+typedef short INT16;
+typedef long INT32;
+typedef unsigned char UINT8;
+typedef unsigned short UINT16;
+typedef unsigned long UINT32;
+typedef unsigned char bool;
+
+#endif /* CPU=PPC860 and __VXWORKS__ */
+
+
+
+/* Standard definitions for TI_C6201 */
+
+#if (CPU==TI_C6201 && !defined(__VXWORKS__))
+
+typedef char INT8;
+typedef short INT16;
+typedef int INT32;
+typedef unsigned char UINT8;
+typedef unsigned short UINT16;
+typedef unsigned int UINT32;
+typedef unsigned char bool;
+
+#endif /* CPU=TI_C6201 */
+
+
+/*
+ * Added for Win32 test enviroment : DSN
+ */
+#ifdef WIN32
+
+typedef short INT16;
+typedef int INT32;
+typedef unsigned char UINT8;
+typedef unsigned short UINT16;
+typedef unsigned int UINT32;
+#include <windows.h>
+#include <stddef.h>
+
+#endif
+
+
+#endif \ No newline at end of file
diff --git a/data/mnet/Common/include/MnetProductId.h b/data/mnet/Common/include/MnetProductId.h
new file mode 100644
index 0000000..3ee33af
--- /dev/null
+++ b/data/mnet/Common/include/MnetProductId.h
@@ -0,0 +1,102 @@
+/*********************************************************************/
+/* */
+/* (c) Copyright Cisco 2000 */
+/* All Rights Reserved */
+/* */
+/*********************************************************************/
+
+/*********************************************************************/
+/* */
+/* Version : 1.0 */
+/* Status : Under development */
+/* File : ProductId.h */
+/* Author(s) : Bhawani Sapkota */
+/* Create Date : 9/18/2000 */
+/* Description : This file contains MNET product IDs */
+/* */
+/*********************************************************************/
+/* REVISION HISTORY
+/*___________________________________________________________________*/
+/*----------+--------+-----------------------------------------------*/
+/* Name | Date | Reason */
+/*----------+--------+-----------------------------------------------*/
+/* Bhawani |10/16/00| Initial Draft */
+/*----------+--------+-----------------------------------------------*/
+/*********************************************************************/
+
+
+#if !defined(_MNETRODUCTID_H_)
+#define _MNETRODUCTID_H_
+
+typedef enum {
+ MNET_PRODUCT_GP10,
+ MNET_PRODUCT_GMC,
+ MNET_PRODUCT_GS,
+ MNET_PRODUCT_ITP,
+ MNET_PRODUCT_MAXID // always needs to be the last in this
+}MNETProductId_t;
+
+
+#ifdef __cplusplus
+inline
+#else
+static
+#endif
+char *GetMnetProductName(MNETProductId_t id)
+{
+
+ switch (id)
+ {
+ case MNET_PRODUCT_GP10:
+ return "Gsm Port 10 Series (GP10)";
+ break;
+
+ case MNET_PRODUCT_GMC:
+ return "GSM Mobility Controller (GMC)";
+ break;
+
+ case MNET_PRODUCT_GS:
+ return "Serving GPRS Support Node (SGSN)";
+ break;
+
+ case MNET_PRODUCT_ITP:
+ return "IP Transfer Point (ITP)";
+ break;
+ }
+
+ return("Unknown Product ID");
+}
+
+
+#ifdef __cplusplus
+inline
+#else
+static
+#endif
+
+char *GetMnetProductRelativeDirName(MNETProductId_t id)
+{
+
+ switch (id)
+ {
+ case MNET_PRODUCT_GP10:
+ return "Gp10";
+ break;
+
+ case MNET_PRODUCT_GMC:
+ return "Gmc";
+ break;
+
+ case MNET_PRODUCT_GS:
+ return "Gs";
+ break;
+
+ case MNET_PRODUCT_ITP:
+ return "Itp";
+ break;
+ }
+
+ return("Unknown");
+}
+
+#endif /* _MNETRODUCTID_H_ */
diff --git a/data/mnet/Common/include/NetBuffer.h b/data/mnet/Common/include/NetBuffer.h
new file mode 100644
index 0000000..7903651
--- /dev/null
+++ b/data/mnet/Common/include/NetBuffer.h
@@ -0,0 +1,118 @@
+#ifndef __NETBUFFER_H__
+#define __NETBUFFER_H__
+// *******************************************************************
+//
+// (c) Copyright CISCO Systems, 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// Status : Under development
+// File : NetBuffer.h
+// Author(s) : Igal Gutkin
+// Create Date : 12/29/00
+// Description : NetBuffer class definiton.
+//
+// *******************************************************************
+
+#include <vxworks.h>
+#include <netBufLib.h>
+
+#include "Os\JCMutex.h"
+
+#define CALC_VALUE 0
+#define BUFFER_ID M_BLK_ID
+
+// shell accessible info method
+extern "C" void netBufPrintInfo (void);
+
+class NetBuffer
+{
+public:
+
+
+ static
+ NetBuffer *getInstance();
+
+ static
+ bool isInit () { return (pNetBuff_ != NULL); }
+
+ static
+ void release ();
+
+ static
+ void printInfo ();
+
+ // Check the Buffer
+ bool isValidBuffer (BUFFER_ID pMblk) { return (pNetBuff_ && pMblk &&
+ pMblk->pClBlk->clRefCnt &&
+ pMblk->pClBlk->pNetPool == pNetPool_); }
+ // Allocate new buffer
+ // Returns the size of the allocated buffer.
+ // On error returns zero and pMBlk == NULL
+ // Allocated buffer size could be not the same size as requested!
+ unsigned getBuffer (unsigned bufSize, BUFFER_ID& pMBlk);
+
+ // Returns total size of the associated memory buffer or zero on invalid buffer
+ unsigned getBufferSize (BUFFER_ID pMBlk);
+
+ // Release buffer
+ bool freeBuffer (BUFFER_ID pMblk );
+
+ // Create new Buffer ID without replicating the data itself
+ bool duplicateBuffer (BUFFER_ID pSrc, BUFFER_ID& pDest);
+
+ // Return a pointer to the data and the actual data size
+ char *getDataPtr (BUFFER_ID pMblk, unsigned& dataLen);
+
+ // Provide the size of the data stored in the buffer
+ // Return false on invalid buffer ID
+ bool getDataSize(BUFFER_ID pMblk, unsigned& dataLen);
+
+ // Set the size of the data stored in the buffer
+ // Return false on invalid buffer ID or data size exceeding buffer length
+ bool setDataSize(BUFFER_ID pMblk, unsigned dataLen);
+
+ // Copy data from the memory cluster to the user buffer
+ bool getData (BUFFER_ID pMblk, unsigned& dataLen, char *pBuff, unsigned maxLen);
+
+ // Copy data from the user buffer to the memory cluster
+ bool setData (BUFFER_ID pMblk, unsigned dataLen, char *pBuff);
+
+
+protected:
+
+ // Class Constractors & Destractor
+ NetBuffer ();
+
+ virtual
+ ~NetBuffer ();
+
+private :
+ static
+ NetBuffer *init ();
+
+
+
+// Data members
+private:
+
+ static NetBuffer *pNetBuff_ ;
+
+ static M_CL_CONFIG mClBlkConfig_;
+ static CL_DESC clDescTbl_ [];
+
+ static unsigned poolNum_ ;
+
+ NET_POOL netPool_ ;
+ NET_POOL_ID pNetPool_ ;
+
+ JCMutex mutex ;
+};
+
+
+
+#endif //__NETBUFFER_H__ \ No newline at end of file
diff --git a/data/mnet/Common/include/Os/JCCTimer.h b/data/mnet/Common/include/Os/JCCTimer.h
new file mode 100644
index 0000000..2d5154a
--- /dev/null
+++ b/data/mnet/Common/include/Os/JCCTimer.h
@@ -0,0 +1,117 @@
+#ifndef JCCTimer_H
+#define JCCTimer_H
+
+// *******************************************************************
+//
+// (c) Copyright Cisco 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// Status : Under development
+// File : JCCTimer.h
+// Author(s) : Bhava Nelakanti
+// Create Date : 10-19-98
+// Description : interface specification for - JCCTimer
+//
+// REVISION HISTORY:
+// __________________________________________________________________
+//| Name | Date | Reason
+//+__________+________+_______________________________________________
+//| Igal |11/29/00| Added support to set timer in 100 mSec resolution
+//| Shiv |01/14/00| Added support to enable windows applications to
+//| | | use the same APIs provided by JCCTimer
+//+__________+________+______________________________________________
+//
+// *******************************************************************
+// Include Files.
+// *******************************************************************
+
+#if defined(__VXWORKS__)
+ #include "vxWorks.h"
+ #include "wdLib.h"
+#elif (defined(WIN32) || defined(_WINDOWS_))
+ //#include "stdAfx.h"
+ #include <mmsystem.h>
+ #define FUNCPTR LPTIMECALLBACK
+ #define WDOG_ID MMRESULT
+ #define TARGET_RESOLUTION 1 // 1-millisecond target resolution
+#endif
+
+// *******************************************************************
+// forward declarations.
+// *******************************************************************
+
+class JCCTimer
+{
+
+public:
+
+ // Destructor
+ ~JCCTimer() ;
+
+ // Constructors
+ JCCTimer (FUNCPTR fPtr,
+ int timerData);
+
+ JCCTimer (FUNCPTR fPtr);
+
+ // Operators
+
+ // primary behaviour methods
+ void cancelTimer ();
+ void setTimer (int howLong);
+ void setTimer (int howLong, int timerData)
+ { timerData_ = timerData;
+ setTimer (howLong); }
+
+ // set timer in resolution of 100 mSec
+ void setTimerMSec(unsigned mSec)
+ { setTimer (tickPerSec*mSec/10);}
+
+ // set timer in resolution of 100 mSec
+ void setTimerMSec(unsigned mSec, int timerData)
+ { setTimer ((tickPerSec*mSec/10), timerData);}
+
+ static int getTickRate () { return (tickPerSec); }
+
+ // maintenance methods
+
+ // get and set for private data members
+
+ // boolean to indicate if timer is active
+ bool timerSet_;
+
+protected:
+
+private:
+
+ // hide the assignment, and copy ctor and other defaults as needed.
+ JCCTimer();
+
+ JCCTimer (const JCCTimer& rhs) ;
+
+ JCCTimer& operator= (const JCCTimer& rhs) ;
+
+ int operator==(const JCCTimer& rhs) const ;
+
+ void init ();
+
+private:
+
+ static int tickPerSec;
+
+ // data members
+ FUNCPTR funcPtr_ ;
+ int timerData_; // data for timer call-back
+ WDOG_ID timerId_ ; // VxWorks Watchdog Timer Id
+#if (defined(WIN32) || defined(_WINDOWS_))
+ unsigned int wTimerRes;
+#endif
+};
+
+
+#endif // JCCTimer_H
diff --git a/data/mnet/Common/include/Os/JCModule.h b/data/mnet/Common/include/Os/JCModule.h
new file mode 100644
index 0000000..57f5b84
--- /dev/null
+++ b/data/mnet/Common/include/Os/JCModule.h
@@ -0,0 +1,88 @@
+// *******************************************************************
+//
+// (c) Copyright Cisco 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// Status : Under development
+// File : JCModule.h
+// Author(s) : Tim Olson
+// Create Date : 9/18/2000
+// Description :
+//
+// *******************************************************************
+#ifndef _JCMODULE_H_
+#define _JCMODULE_H_ /* include once only */
+
+#include <sysSymTbl.h>
+#include "MnetModuleId.h"
+#include "Os/JCTask.h"
+
+#define MAX_NUM_SUB_TASKS 50
+
+
+typedef enum {
+ SYS_SHUTDOWN = 0,
+ SYS_START = 1,
+ SYS_REBOOT = 2,
+} T_SYS_CMD;
+
+
+typedef int (*JC_SYSCMD_FUNC)(T_SYS_CMD);
+
+typedef enum
+{
+ TASK_SUSPENDED,
+ TASK_MISSING,
+ MODULE_OK
+} SYSTEM_MODULE_STATUS;
+
+class JCModule {
+public:
+ JCModule
+ (
+ MNET_MODULE_ID id,
+ JC_SYSCMD_FUNC cmdFunc,
+ char *cmdFuncStr
+ );
+
+ ~JCModule();
+
+ bool StartModule();
+ void ShutdownModule();
+ void RebootModule();
+ SYSTEM_MODULE_STATUS CheckModule(JCTask **pTask);
+ MNET_MODULE_ID GetModuleId() { return (modId); }
+
+ static JCModule *systemModules[];
+ static void InsertTaskInfo(MNET_MODULE_ID id, JCTask *pTask);
+ static bool AllTasksInMainLoop();
+ static void ShowModuleStat();
+
+private:
+ JC_SYSCMD_FUNC syscmd;
+ char *modName;
+ MNET_MODULE_ID modId;
+ int numRun;
+ int numSub;
+ JCTask *tasks[MAX_NUM_SUB_TASKS];
+ bool isModuleLoaded;
+
+ // Private functions
+ static int CheckSym(char *name, int val, SYM_TYPE type, int arg, UINT16 group);
+ int TestSym(char *str);
+
+
+ // Disallow the following functions
+ JCModule();
+ JCModule(const JCModule&);
+ JCModule& operator=(const JCModule&);
+ int operator== (const JCModule&) const;
+};
+
+
+#endif
diff --git a/data/mnet/Common/include/Os/JCMsgQueue.h b/data/mnet/Common/include/Os/JCMsgQueue.h
new file mode 100644
index 0000000..3c6630d
--- /dev/null
+++ b/data/mnet/Common/include/Os/JCMsgQueue.h
@@ -0,0 +1,91 @@
+// *******************************************************************
+//
+// (c) Copyright Cisco 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// Status : Under development
+// File : JCMsgQueue.h
+// Author(s) : Tim Olson
+// Create Date : 9/18/2000
+// Description :
+//
+// *******************************************************************
+#ifndef _JCMSGQUEUE_H_
+#define _JCMSGQUEUE_H_ /* include once only */
+
+#include "JCErr.h"
+#include "msgQLib.h"
+#include "MnetModuleId.h"
+
+/* OS independent message queue id */
+#define JC_MSG_Q_ID MSG_Q_ID
+
+/* Message queue sending options */
+#define JC_MSG_PRI_NORMAL MSG_PRI_NORMAL
+#define JC_MSG_PRI_URGENT MSG_PRI_URGENT
+
+/* Message queue creation options */
+#define JC_MSG_Q_FIFO MSG_Q_FIFO
+#define JC_MSG_Q_PRIORITY MSG_Q_PRIORITY
+
+/* Message queue reception timeout options */
+#define JC_NO_WAIT NO_WAIT
+#define JC_WAIT_FOREVER WAIT_FOREVER
+
+class JCMsgQueue {
+public:
+ JCMsgQueue
+ (
+ int maxMsgs, /* max msgs that can be queued */
+ int maxMsgLength, /* max bytes in a msg */
+ int options /* message queue options */
+ );
+
+ ~JCMsgQueue();
+
+ JC_STATUS JCMsgQSend
+ (
+ JCMsgQueue *replyMsgQ,
+ unsigned int msgType,
+ MNET_MODULE_ID modId,
+ char * buffer,
+ unsigned int nBytes,
+ int timeout,
+ int priority
+ );
+
+ int JCMsgQReceive
+ (
+ JCMsgQueue **replyMsgQ,
+ unsigned int *msgType,
+ MNET_MODULE_ID *modId,
+ char * buffer,
+ unsigned int *nBytes,
+ int timeout
+ );
+
+ JC_MSG_Q_ID JCGetMsgQId()
+ {
+ return(msgQId);
+ }
+
+private:
+ JC_MSG_Q_ID msgQId;
+ int msgQMaxLen;
+ char *msgQSndBuf;
+ char *msgQRcvBuf;
+
+ // Disallow the following functions
+ JCMsgQueue();
+ JCMsgQueue(const JCMsgQueue&);
+ JCMsgQueue& operator=(const JCMsgQueue&);
+ int operator== (const JCMsgQueue&) const;
+};
+
+
+#endif
diff --git a/data/mnet/Common/include/Os/JCMutex.h b/data/mnet/Common/include/Os/JCMutex.h
new file mode 100644
index 0000000..8adc962
--- /dev/null
+++ b/data/mnet/Common/include/Os/JCMutex.h
@@ -0,0 +1,44 @@
+#ifndef __JCMUTEX_H__
+#define __JCMUTEX_H__
+// *******************************************************************
+//
+// (c) Copyright CISCO Systems, 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// Status : Under development
+// File : JCMutex.h
+// Author(s) : Igal Gutkin
+// Create Date : 11/06/00
+// Description : JCMutex class (Mutual-Exclusion Semapore) definition
+//
+// *******************************************************************
+
+
+#include <vxworks.h>
+#include <semlib.h>
+
+class JCMutex
+{
+public:
+ // Constructors & destructor
+ JCMutex ();
+ virtual ~JCMutex ();
+
+ // pramary methods
+ bool take ();
+ bool give ();
+
+private:
+
+// data members
+private:
+
+ SEM_ID semId_;
+};
+
+#endif //__JCMUTEX_H__ \ No newline at end of file
diff --git a/data/mnet/Common/include/Os/JCTask.h b/data/mnet/Common/include/Os/JCTask.h
new file mode 100644
index 0000000..30e5888
--- /dev/null
+++ b/data/mnet/Common/include/Os/JCTask.h
@@ -0,0 +1,131 @@
+// *******************************************************************
+//
+// (c) Copyright Cisco 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// Status : Under development
+// File : JCTask.h
+// Author(s) : Tim Olson
+// Create Date : 9/18/2000
+// Description :
+//
+// *******************************************************************
+#ifndef _JCTASK_H_
+#define _JCTASK_H_ /* include once only */
+
+#include <taskLib.h>
+#include <semLib.h>
+#include "JCErr.h"
+#include "MnetModuleId.h"
+
+/* OS independent task id */
+#define JC_TASK_ID int
+
+/* Task creation options */
+#define JC_VX_FP_TASK VX_FP_TASK /* execute with floating-point coprocessor support */
+#define JC_VX_PRIVATE_ENV VX_PRIVATE_ENV /* include private environment support */
+#define JC_VX_NO_STACK_FILL VX_NO_STACK_FILL /* do not fill the stack for use by checkStack */
+#define JC_VX_UNBREAKABLE VX_UNBREAKABLE /* do not allow breakpoint debugging */
+
+extern SEM_ID *pMnetSyncSem;
+
+/* System importance for task */
+typedef enum {
+ JC_CRITICAL_TASK,
+ JC_NON_CRITICAL_TASK
+} JC_TASK_IMPORTANCE;
+
+/* Task status */
+typedef enum {
+ JC_TASK_IDLE,
+ JC_TASK_INIT,
+ JC_TASK_LOOP,
+ JC_TASK_EXIT,
+} JC_TASK_STATUS;
+
+
+class JCTask {
+public:
+ JCTask
+ (
+ char *name
+ );
+
+ ~JCTask();
+
+ int JCTaskSpawn
+ (
+ int priority, /* priority of new task */
+ int options, /* task option word */
+ int stackSize, /* size (bytes) of stack needed plus name */
+ FUNCPTR entryPt, /* entry point of new task */
+ int arg1, /* 1st of 10 req'd task args to pass to func */
+ int arg2,
+ int arg3,
+ int arg4,
+ int arg5,
+ int arg6,
+ int arg7,
+ int arg8,
+ int arg9,
+ int arg10,
+ MNET_MODULE_ID modId,
+ JC_TASK_IMPORTANCE importance
+ );
+
+ void JCTaskEnterLoop();
+ void JCTaskNormExit();
+
+ const char *GetTaskName() { return (taskName); }
+ int GetTaskId() { return (taskId); }
+ JC_TASK_IMPORTANCE GetTaskImportance() { return (taskImportance); }
+ JC_TASK_STATUS GetTaskStatus() { return (taskStatus); }
+
+ JC_TASK_ID JCTaskId()
+ {
+ return(taskId);
+ }
+
+ void SetTaskAlarmStatus(bool stat) { taskAlarmed = stat; }
+ bool GetTaskAlarmStatus() { return(taskAlarmed); }
+
+ void ExecuteCoreDumpFunc() { if (coreDumpFunc) coreDumpFunc(); }
+
+private:
+ int taskId;
+ char *taskName;
+ int taskPri; /* priority of new task */
+ int taskOpt; /* task option word */
+ int taskStackSize; /* size (bytes) of stack needed plus name */
+ FUNCPTR taskEntryPt; /* entry point of new task */
+ int taskArg1; /* 1st of 10 req'd task args to pass to func */
+ int taskArg2;
+ int taskArg3;
+ int taskArg4;
+ int taskArg5;
+ int taskArg6;
+ int taskArg7;
+ int taskArg8;
+ int taskArg9;
+ int taskArg10;
+ MNET_MODULE_ID moduleId;
+ JC_TASK_IMPORTANCE taskImportance;
+ FUNCPTR coreDumpFunc;
+ JC_TASK_STATUS taskStatus;
+ bool taskAlarmed;
+
+
+ // Disallow the following functions
+ JCTask();
+ JCTask(const JCTask&);
+ JCTask& operator=(const JCTask&);
+ int operator== (const JCTask&) const;
+};
+
+
+#endif
diff --git a/data/mnet/Common/include/Pm/pm_common.h b/data/mnet/Common/include/Pm/pm_common.h
new file mode 100644
index 0000000..ec2cbff
--- /dev/null
+++ b/data/mnet/Common/include/Pm/pm_common.h
@@ -0,0 +1,209 @@
+#ifndef _PM_COMMON_H_
+#define _PM_COMMON_H_
+
+#include "pm\pmdefs.h"
+
+const int PM_MAX_INTERVAL = 2;
+const int PM_MAX_RECORDS = 1500;
+
+#define PM_ONE_SECOND 1
+#define PM_ONE_MINUTE (PM_ONE_SECOND*60)
+#define PM_SECONDS_IN_15_MIN 900
+#define PM_SECONDS_IN_30_MIN 1800
+#define PM_SECONDS_IN_45_MIN 2700
+#define PM_SECONDS_IN_HOUR 3600
+
+
+#ifdef UNIT_TEST_PMCLASS
+typedef int CauseCode;
+#endif
+
+/* Bind options */
+#define DEFAULT_PORT_ADDR 1
+#define FIXED_PORT_LOCAL_ADDR 2
+#define GET_PORT_AND_LOCAL_ADDR 3
+
+/* Defaults */
+#define kANY_PORT 0
+#define FIXED_PORT 1045
+
+#define kMaxRecvUdpMsgSize 2048
+
+typedef struct socket OS_SPECIFIC_SOCKET_SOCKET;
+typedef struct socket OS_SPECIFIC_DGRAM_SOCKET;
+
+extern unsigned long GetLocalHostAddress();
+extern OS_SPECIFIC_SOCKET_HANDLE SOCKET_UdpCreate();
+extern bool SOCKET_UdpBind(OS_SPECIFIC_SOCKET_HANDLE sock, ubyte2 port);
+
+extern bool SOCKET_UdpReceive(OS_SPECIFIC_DGRAM_HANDLE sock, char *msg, ubyte4 *msgSize, ubyte4 *peerAddr);
+extern bool SOCKET_UdpSendTo(OS_SPECIFIC_DGRAM_HANDLE sock, struct sockaddr_in *pAddrTo, char *message, ubyte4 msglen);
+extern bool SOCKET_Close( OS_SPECIFIC_SOCKET_HANDLE sock );
+
+/*
+ * The PM_BaseObject class declaration
+ */
+class PM_BaseObject {
+ private:
+ /*
+ * base Performance-Management class
+ * - provide critical section
+ */
+ SEM_ID m_semaphore;
+ public:
+ bool takeSemaphore(void);
+ bool giveSemaphore(void);
+ /*
+ * Constructor for the object
+ */
+ PM_BaseObject()
+ {
+ m_semaphore = semBCreate(SEM_Q_PRIORITY,SEM_FULL);
+ };
+
+ /*
+ * Destructor for the object
+ */
+ ~PM_BaseObject()
+ {
+ if (m_semaphore != NULL)
+ semDelete(m_semaphore);
+ }
+
+};
+
+int pm_map_cause_to_index(CauseCode cause);
+CauseCode pm_map_index_to_cause(int index);
+char * pm_map_cause_code_to_str(CauseCode cause);
+
+/*
+ * The PM_SimpleCounter class declaration
+ * 1-minute interval period
+ * total of 15 completed intervals (last 15 minutes) plus
+ * 1 current interval (accumulating)
+ */
+class PM_SimpleCounter: public PM_BaseObject
+{
+ public:
+ void reset(void); /* reset counter to 0 (both value and maxValue) */
+ bool increment(void); /* increment the counter value by 1 */
+ bool increment(int x); /* increment the counter value by x */
+ bool decrement(void); /* decrement the counter value by 1 */
+ int getValue(void); /* obtain the current value of the counter for
+ * the past PM_MAX_INTERVAL-1 (15) completed intervals (sum)
+ */
+ bool setValue(int new_value);
+
+ int getMaxValue(void); /* obtain the maximum value of the counter for
+ * the past PM_MAX_INTERVAL-1 (15) completed intervals (accumulated max)
+ */
+
+ void advanceInterval(void);/* move to the next measurement interval (called by PM task) */
+
+ /* Constructor for the class */
+ PM_SimpleCounter()
+ {
+ currentInterval = 0;
+ };
+
+private:
+ int value[PM_MAX_INTERVAL]; /* maintain the current value for each interval */
+ int maxValue[PM_MAX_INTERVAL]; /* maintain the max value for each interval */
+ int currentInterval; /* index of the current interval (cyclical) */
+};
+
+
+
+
+/*
+ * The PM_PerCauseCounter class declaration
+ */
+class PM_PerCauseCounter: public PM_BaseObject
+{
+ public:
+ void reset(void); /* reset counters to 0 (both value and maxValue) */
+ bool increment(CauseCode cause); /* increment the counter value by 1 */
+ bool decrement(CauseCode cause); /* decrement the counter value by 1 */
+ int getValue(CauseCode cause); /* obtain the current value of the counter for
+ * the past PM_MAX_INTERVAL-1 (15) completed intervals (sum)
+ */
+
+ void advanceInterval(void); /* move to the next measurement interval (called by PM task) */
+
+ private:
+ PM_SimpleCounter perCauseCounter[PM_MAX_CAUSES];
+ /* each per-cause counter is a simpleCounter */
+};
+
+
+
+/*
+ * The PM_StatisticCounter class declaration
+ */
+class PM_StatisticCounter: public PM_BaseObject
+{
+ public:
+ void reset(void); /* reset the entire records[] array by
+ * removing all records, and set the numberRecords to 0
+ */
+
+ bool addRecord(int value); /* insert a record into the record array
+ * return true if successful
+ * return false if out of record entry (newest records will be discarded)
+ */
+
+ int getMeanValue(void); /* obtain the arithmatic-mean of all the records for
+ * the past PM_MAX_INTERVAL-1 (15) completed intervals
+ */
+ int getMaxValue();
+
+ void advanceInterval(void); /* move to the next measurement interval (called by PM task) */
+
+ PM_StatisticCounter()
+ {
+ reset();
+ }
+
+ private:
+ int numRecords[PM_MAX_INTERVAL];
+ int records[PM_MAX_INTERVAL][PM_MAX_RECORDS];
+ int currentInterval; /* index of the current interval (cyclical) */
+ /*
+ * Constructor for the class
+ */
+
+};
+
+
+
+/*
+ * The PM_AccumTimeCounter class declaration
+ * 1-minute interval period
+ * total of 15 completed intervals (last 15 minutes) plus
+ * 1 current interval (accumulating)
+ */
+class PM_AccumTimeCounter: public PM_BaseObject
+{
+ public:
+ void reset(void); /* reset counter to 0 (both value and maxValue) */
+ void start(); /* stat accumulating time */
+ void stop(); /* stop accumulating time */
+ int getValue(void); /* obtain the current value of the counter for
+ * the current interval
+ */
+ void advanceInterval(void);/* move to the next measurement interval (called by PM task) */
+
+ /* Constructor for the class */
+ PM_AccumTimeCounter()
+ {
+ currentInterval = 0;
+ };
+
+private:
+ int accumValue[PM_MAX_INTERVAL]; /* maintain the current accumulated value for each interval */
+ int lastStart[PM_MAX_INTERVAL]; /* maintain the tick value when the timer was last started */
+ bool state[PM_MAX_INTERVAL]; /* maintain the on-off state of the timer */
+ int currentInterval; /* index of the current interval (cyclical) */
+};
+
+#endif
diff --git a/data/mnet/Common/include/SmsPP/smspp_inf.h b/data/mnet/Common/include/SmsPP/smspp_inf.h
new file mode 100644
index 0000000..2895d45
--- /dev/null
+++ b/data/mnet/Common/include/SmsPP/smspp_inf.h
@@ -0,0 +1,84 @@
+
+/*********************************************************************/
+/* */
+/* (c) Copyright Cisco 2000 */
+/* All Rights Reserved */
+/* */
+/*********************************************************************/
+
+/*********************************************************************/
+/* */
+/* Version : 1.01 */
+/* Status : Unde development */
+/* File : jccsmspp.h */
+/* Author(s) : Bhawani Sapkota */
+/* Create Date : 12/25/2000 */
+/* Description : his file contains data types and const defined */
+/* for SMS-PP and are shared between SMC and SMR. */
+/* */
+/*********************************************************************/
+/* REVISION HISTORY
+/*___________________________________________________________________*/
+/*----------+--------+-----------------------------------------------*/
+/* Name | Date | Reason */
+/*----------+--------+-----------------------------------------------*/
+/* Bhawani |03/09/00| Initial Draft */
+/* Bhawani |11/20/00| restructured and ported form NT to vxWorks */
+/*----------+--------+-----------------------------------------------*/
+/*********************************************************************/
+
+#ifndef __JCCSMSPP_H_
+#define __JCCSMSPP_H_
+
+#define SMS_MAX_RP_MSG_LEN 248
+#define SMS_MAGIC_NUMBER 0x12345678
+
+/* Ranges for SMS reference numbers used on VBLink interface
+ for the ViperCell (VC) and ViperBase (VB) */
+#define INVALID_VC_SMS_REF_NUM 0
+#define MIN_VC_SMS_REF_NUM 1
+#define MAX_VC_SMS_REF_NUM 32767
+#define MIN_VB_SMS_REF_NUM 32768
+#define MAX_VB_SMS_REF_NUM 65535
+
+/* This value is used in the SMS VBLink communication
+ in order to specify normal disconnection */
+#define SMS_VBLINK_NORMAL_DISCONNECT 255
+
+typedef enum {
+ MNSMS_MSG_BASE = 0,
+
+ MNSMS_ABORT_Req, // = 1 ViperBase->ViperCell
+
+ MNSMS_EST_Req , // = 2 RP-DATA ViperBase->ViperCell
+ MNSMS_DATA_Req , // = 3 RP-ACK (RP-ERROR) ViperBase->ViperCell
+
+ MNSMS_EST_Ind , // = 4 RP-DATA ViperCell->ViperBase
+ MNSMS_DATA_Ind , // = 5 RP-ACK (RP-ERROR) ViperCell->ViperBase
+
+ MNSMS_ERROR_Ind, // = 6 ViperCell->ViperBase
+ MNSMS_REL_Req , // = 7 ViperBase->ViperCell
+
+ MNSMS_MSG_MAX
+
+} SMS_VBLINK_MSGTYPE;
+
+
+typedef struct
+{
+ UINT32 magic ; // = SMS_MAGIC_NUMBER
+ UINT32 refNum ; // associated subscriber profile index
+ UINT32 msgType; // value of type SMS_VBLINK_MSGTYPE
+ UINT32 status ; // holds disconnect cause, or 0
+ UINT32 msgLen ;
+} SmsHdrVblinkMsg_t;
+
+#define SMS_VBLINK_HDRSIZE (sizeof(SmsHdrVblinkMsg_t))
+
+typedef struct
+{
+ SmsHdrVblinkMsg_t hdr;
+ UINT8 msg[SMS_MAX_RP_MSG_LEN];
+} SmsVblinkMsg_t;
+
+#endif /* __JCCSMSPP_H_ */
diff --git a/data/mnet/Common/include/VCLOGGING.H b/data/mnet/Common/include/VCLOGGING.H
new file mode 100644
index 0000000..95ab458
--- /dev/null
+++ b/data/mnet/Common/include/VCLOGGING.H
@@ -0,0 +1,283 @@
+#ifndef VCLOGGING_HDR_INC
+#define VCLOGGING_HDR_INC
+/*
+ ****************************************************************************************
+ * Copyright Cisco Systems, Inc 2000 All Rights reserved *
+ * *
+ * File : vclogging.h *
+ * *
+ * Description : Header file containing data structures, definitions, and *
+ * macros defined for logging use on the MNET solution *
+ * *
+ * Author : Dinesh Nambisan *
+ * *
+ *----------------------- Revision history ---------------------------------------------*
+ * Time | Date | Name | Description *
+ *--------------------------------------------------------------------------------------*
+ * 00:00 |03/18/99 | DSN | Initial version created *
+ * | | | *
+ ****************************************************************************************
+ */
+
+/*
+ * VxWorks & ANSI C headers
+ */
+#include <vxworks.h>
+#include <msgqlib.h>
+#include <sockLib.h>
+#include <hostlib.h>
+#include <inetLib.h>
+#include <stdioLib.h>
+#include <strLib.h>
+#include <ioLib.h>
+#include <assert.h>
+/*
+ * Module enumeration header file
+ */
+#include "logmodules.h"
+
+#define _MNET_COMMON_LOGGING_MODULE_
+
+#ifdef MNET_GP10
+#define VIPERLOG_HOST_ETHERNET_INTERFACE "motfec0"
+#elif MNET_GS
+#define VIPERLOG_HOST_ETHERNET_INTERFACE "fei0"
+#elif MNET_GMC
+#define VIPERLOG_HOST_ETHERNET_INTERFACE "fei0"
+#endif
+
+#define ASCII_PRINTABLE_BEGIN 32
+#define ASCII_PRINTABLE_END 126
+#define ASCII_SPACE_CHAR 32
+
+#define VIPERLOG_PORT_NUM 2105
+#define VIPERLOG_MAX_NET_PKT_SIZE 1200
+#define MAX_DEBUG_MSGS_IN_Q 3000
+#define VIPERLOG_MSG_MAGIC_NO 0x1234
+
+#define VIPERLOG_ALL_MODULES 1000
+#define MAX_VIPERLOG_BUFFERED_PKTS 3
+
+#define VIPERLOG_MAX_FUNC_NAME_LEN 64
+#define VIPERLOG_MAX_DEBUG_MSG_LEN 256
+
+#define MAX_SHORT_STRING_LENGTH 7
+#define MAX_LONG_STRING_LENGTH 20
+#define VIPERLOG_NULL_CALL_ID 0
+
+
+#define VIPERLOG_MAX_RECORDS_IN_FILE 10000
+#define VIPERLOG_MAX_MSGS_IN_Q 1000
+#define VIPERLOG_MAX_OUT_BUFF_LENGTH 256
+
+
+/*
+ Bit mask for log options values
+
+ |----|----|----|----|----|----|---|---|---|---|---|---|---|---|---|---|
+ | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
+ |----|----|----|----|----|----|---|---|---|---|---|---|---|---|---|---|
+
+ ------------------------------
+ Bit no | Meaning
+ -----------------------------
+ 0 : If set, indicates log to console enabled
+ 1 : If set, indicates log to network enabled
+ 2 : If set, indicates log to file enabled
+ 3 : If set, indicates function tracing required
+ 4 : If set, indicates call tracing required
+ 5 : If set, indicates logging of informational messages required
+ 6 : If set, indicates logging of warnings required
+ 7 : if set, indicates logging of errors required
+ 8 : if set, indicates use of timestamps
+ 9-15 : reserved; unused for now
+*/
+
+typedef enum {
+
+ LOG_TO_CONSOLE_MASK = 0x0001,
+ LOG_TO_NETWORK_MASK = 0x0002,
+ LOG_TO_FILE_MASK = 0x0004,
+ LOG_CONTROL_TRACE_MASK = 0x0008,
+ LOG_CALL_TRACE_MASK = 0x0010,
+ LOG_INFORMATIONAL_MASK = 0x0020,
+ LOG_WARNINGS_MASK = 0x0040,
+ LOG_ERRORS_MASK = 0x0080,
+ LOG_TIMESTAMPS = 0x0100
+
+} VIPERLOG_FILTER_MASK;
+
+
+/*
+ * Inverse masks
+ */
+typedef enum {
+
+ LOG_CONTROL_TRACE_INVERSE_MASK = 0xfff7,
+ LOG_CALL_TRACE_INVERSE_MASK = 0xffef,
+ LOG_INFORMATIONAL_INVERSE_MASK = 0xffdf,
+ LOG_WARNINGS_INVERSE_MASK = 0xffbf,
+ LOG_ERRORS_INVERSE_MASK = 0xff7f,
+
+} VIPERLOG_FILTER_INVERSE_MASK;
+
+
+typedef enum {
+
+ LOG_SEVERITY_FUNCTION_TRACE = LOG_CONTROL_TRACE_MASK,
+ LOG_SEVERITY_TRACE = LOG_INFORMATIONAL_MASK,
+ LOG_SEVERITY_CALL_TRACE = LOG_CALL_TRACE_MASK,
+ LOG_SEVERITY_WARNING = LOG_WARNINGS_MASK,
+ LOG_SEVERITY_ERROR = LOG_ERRORS_MASK
+
+} VIPERLOG_SEVERITY;
+
+
+#define LOG_ASCII 0
+#define LOG_PLAIN_BINARY 1
+#define LOG_FORMAT_BINARY 2
+
+
+/*
+ * the packet format for log messages
+ */
+typedef struct {
+
+ unsigned short magic ;
+ unsigned short severity_level;
+ unsigned short module_id ;
+ unsigned long call_id ;
+ unsigned long timestamp ;
+ unsigned long tick_count ;
+ unsigned data_type ;
+ unsigned binary_length ;
+ char function_name[VIPERLOG_MAX_FUNC_NAME_LEN];
+ char message [VIPERLOG_MAX_DEBUG_MSG_LEN];
+
+} VIPERLOG_PACKET;
+
+
+/*
+ * The configuration information
+ */
+typedef struct {
+
+ unsigned short module_filters[LOGGING_MAX_MODULES];
+ MSG_Q_ID msg_q_id;
+ int log_socket;
+ BOOL log_socket_opened;
+
+ FILE *log_file;
+ BOOL log_file_opened;
+ unsigned long log_record_counter;
+ unsigned long log_pkt_counter;
+
+ char net_packet[VIPERLOG_MAX_NET_PKT_SIZE];
+ int net_buff_index;
+
+ struct sockaddr_in dest_address;
+
+ BOOL shutdown_message_received;
+
+ BOOL console_output_detailed;
+
+} VIPERLOG_CONFIGURATION,*PVIPERLOG_CONFIGURATION;
+
+
+
+
+/*
+ * The DbgOutput class
+ */
+class DbgOutput
+{
+ private:
+
+ VIPERLOG_PACKET m_log_packet;
+
+ void PreparePacket (short severity_level, int binLength = 0, bool bFormat = false);
+
+ public:
+
+ DbgOutput() {};
+
+ DbgOutput(char *function_name,int module_id)
+ {
+ strncpy((char *)m_log_packet.function_name,(const char *)function_name,
+ VIPERLOG_MAX_FUNC_NAME_LEN);
+ /* Making sure it is null-terminated */
+ m_log_packet.function_name[VIPERLOG_MAX_FUNC_NAME_LEN-1] = 0;
+ m_log_packet.module_id = module_id;
+ };
+
+ void Func(char *function_name,int module_id)
+ {
+ strncpy((char *)m_log_packet.function_name,(const char *)function_name,
+ VIPERLOG_MAX_FUNC_NAME_LEN);
+ /* Making sure it is null-terminated */
+ m_log_packet.function_name[VIPERLOG_MAX_FUNC_NAME_LEN-1] = 0;
+ m_log_packet.module_id = module_id;
+ };
+ void Enter (void);
+ void Leave (void);
+ void Trace (char *format, ...);
+ void Warning (char *format, ...);
+ void Error (char *format, ...);
+ void CallTrace(unsigned long call_id , char *format,...);
+ void HexDump (unsigned char *StartPtr, int byteCount , bool bFormat = false);
+
+ /* Changes for new logging function */
+ void SetModuleId(int module_id)
+ {
+ m_log_packet.module_id = module_id;
+ }
+
+ void SetFuncName(char *function_name)
+ {
+ strcpy((char *)m_log_packet.function_name, (const char *)function_name);
+ }
+
+};
+
+
+#define DBG_FUNC(x,y); DbgOutput Dbg(x,y);
+#define DBG_ENTER(); Dbg.Enter();
+#define DBG_LEAVE(); Dbg.Leave();
+#define DBG_TRACE Dbg.Trace
+#define DBG_CALL_TRACE Dbg.CallTrace
+#define DBG_WARNING Dbg.Warning
+#define DBG_ERROR Dbg.Error
+#define DBG_HEXDUMP(x,y); Dbg.HexDump(x,y);
+#define DBG_HEXDUMP_FMT(x,y); Dbg.HexDump(x,y,true);
+
+
+#ifdef DBG
+#define ASSERT assert
+#endif
+
+#ifdef DEBUG
+#define ASSERT assert
+#endif
+
+
+void init_log_task (void);
+void shutdown_log_task (void);
+VOID viper_log (void);
+BOOL viperlog_check_module_filter(int module_id, short severity_level);
+void viperlog_display_filter_info(short filter_value);
+void viperlog_get_output_device (int module_id,BOOL *output_file,BOOL *output_console,BOOL *output_network);
+void viperlog_send_net_msg (char *msg_buff);
+char *viperlog_get_severity_name (VIPERLOG_SEVERITY severity);
+char *viperlog_get_module_name (LOGGING_MODULE_ID module_id);
+char *viperlog_get_network_broadcast_addr(void);
+
+
+extern "C"
+{
+ void ViperLogSetModuleFilters (int module_id,short severity_level);
+ void ViperLogShowAllFilters();
+ void ViperLogSetDestPort(int port_no);
+ void ViperLogSetDestAddress(char *ip_address);
+}
+
+#endif /* #ifndef VCLOGGING_HDR_INC */ \ No newline at end of file
diff --git a/data/mnet/Common/include/bssgp/bssgp_api.h b/data/mnet/Common/include/bssgp/bssgp_api.h
new file mode 100644
index 0000000..1aff6f1
--- /dev/null
+++ b/data/mnet/Common/include/bssgp/bssgp_api.h
@@ -0,0 +1,600 @@
+/*
+ ****************************************************************************************
+ * *
+ * Copyright Cisco Systems, Inc 2000 All rights reserved *
+ * *
+ * File : bssgp_api.h *
+ * *
+ * Description : API data structures for the BSS-GP layer module *
+ * *
+ * Author : Dinesh Nambisan *
+ * *
+ *----------------------- Revision history ---------------------------------------------*
+ * Time | Date | Name | Description *
+ *--------------------------------------------------------------------------------------*
+ * 00:00 |10/10/00 | DSN | File created *
+ * | | | *
+ ****************************************************************************************
+ */
+#ifndef _BSSGP_API_HDR_INC_
+#define _BSSGP_API_HDR_INC_
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "bssgp_prot.h"
+#include "jcstddef.h"
+/*
+ * RIL3 (4.08) includes
+ */
+#include "ril3/ie_tlli.h"
+#include "ril3/ie_bvci.h"
+#include "ril3/ie_mobile_id.h"
+#include "ril3/ie_location_area_id.h"
+#include "ril3/ie_qos_profile.h"
+#include "ril3/ril3_gmm_msg.h"
+#include "ril3/ie_reject_cause.h"
+#include "ril3/ie_cell_id.h"
+#include "ril3/ie_radio_cause_id.h"
+#include "ril3/ie_priority.h"
+#include "ril3/ie_pdu_lifetime.h"
+#include "ril3/ie_lsa_information.h"
+#include "ril3/ie_cell_identifier.h"
+#include "ril3/ie_lsa_identifier_list.h"
+#include "ril3/ie_bss_area_indication.h"
+#include "ril3/ie_bssgp_cause.h"
+#include "ril3/ie_bvc_measurement.h"
+
+
+/*
+ * LLC_PDU value; will depend on
+ * interface agreed upon and the
+ * platform in question
+ */
+#if defined (MNET_GP10)
+typedef struct {
+ UINT8 *data;
+ UINT16 data_len;
+} LLC_PDU;
+#elif defined (MNET_GS)
+typedef struct {
+ UINT8 *data;
+ UINT16 data_len;
+} LLC_PDU;
+#include "llcmsg.h"
+#elif defined(WIN32)
+typedef struct {
+ UINT8 *data;
+ UINT16 data_len;
+} LLC_PDU;
+#endif
+
+
+
+/*
+ * BSSGP API message type
+ */
+typedef enum {
+
+ BSSGP_API_MSG_DL_UNITDATA,
+ BSSGP_API_MSG_UL_UNITDATA,
+ BSSGP_API_MSG_PAGING_PS,
+ BSSGP_API_MSG_RADIO_STATUS,
+ BSSGP_API_MSG_SUSPEND,
+ BSSGP_API_MSG_SUSPEND_ACK,
+ BSSGP_API_MSG_SUSPEND_NACK,
+ BSSGP_API_MSG_RESUME,
+ BSSGP_API_MSG_RESUME_ACK,
+ BSSGP_API_MSG_RESUME_NACK,
+ BSSGP_API_MSG_LOCATION_UPDATE,
+ BSSGP_API_MSG_LOCATION_UPDATE_ACK,
+ BSSGP_API_MSG_LOCATION_UPDATE_NACK,
+ BSSGP_API_MSG_RADIO_CAP,
+ BSSGP_API_MSG_RADIO_CAP_UPDATE,
+ BSSGP_API_MSG_RADIO_CAP_UPDATE_ACK,
+ BSSGP_API_MSG_FLUSH_LL,
+ BSSGP_API_MSG_FLUSH_LL_ACK,
+ BSSGP_API_MSG_LLC_DISCARDED,
+ BSSGP_API_MSG_FLOW_CONTROL_BVC,
+ BSSGP_API_MSG_FLOW_CONTROL_BVC_ACK,
+ BSSGP_API_MSG_FLOW_CONTROL_MS,
+ BSSGP_API_MSG_FLOW_CONTROL_MS_ACK,
+ BSSGP_API_MSG_BVC_BLOCK,
+ BSSGP_API_MSG_BVC_BLOCK_ACK,
+ BSSGP_API_MSG_BVC_UNBLOCK,
+ BSSGP_API_MSG_BVC_UNBLOCK_ACK,
+ BSSGP_API_MSG_BVC_RESET,
+ BSSGP_API_MSG_BVC_RESET_ACK,
+ BSSGP_API_MSG_STATUS,
+ BSSGP_API_MAX_MSGS
+
+} BSSGP_API_MSG_TYPE;
+
+
+
+/*
+ * The downlink & uplink unitdata messages are
+ * handled slightly differently from the other
+ * signalling messages; basically in the message
+ * only the pointer to the actual msg is passed
+ * via regular interfaces, and actual content will
+ * be in a mbuf somewhere.... Dinesh N.
+ */
+
+/*
+ * DL-UnitData
+ */
+
+typedef struct {
+
+ RIL3_TLLI tlli;
+ T_RIL3_IE_QOS_PROFILE_ID qos_profile;
+ /* Cisco proprietary */
+ T_CNI_RIL3_IE_QOS qos_params;
+ RIL3_IE_PDU_LIFETIME pdu_lifetime;
+ T_CNI_RIL3_IE_MS_RADIO_ACCESS_CAPABILITY radio_access_cap;
+ RIL3_IE_PRIORITY priority; /* GSM 08.08 */
+ T_CNI_RIL3_IE_DRX_PARAMETER drx_params;
+ T_CNI_RIL3_IE_MOBILE_ID imsi;
+ RIL3_TLLI tlli_old;
+ RIL3_IE_LSA_INFORMATION lsa_info;
+ LLC_PDU pdu;
+
+} BSSGP_DL_UNITDATA_MSG;
+
+
+
+
+/*
+ * UL-UnitData
+ */
+typedef struct {
+
+ RIL3_TLLI tlli;
+ T_RIL3_IE_QOS_PROFILE_ID qos_profile;
+ RIL3_IE_CELL_IDENTIFIER cell_id;
+ RIL3_IE_LSA_IDENTIFIER_LIST lsa_id_list;
+ LLC_PDU pdu;
+
+} BSSGP_UL_UNITDATA_MSG;
+
+
+
+
+
+/*
+ * The Paging msg api structure & defns
+ *
+ *
+ */
+typedef struct {
+
+ T_CNI_RIL3_IE_MOBILE_ID imsi;
+ RIL3_BVCI bvci;
+ T_CNI_RIL3_IE_LOCATION_AREA_ID location_area;
+ T_CNI_RIL3_IE_ROUTING_AREA_ID routing_area;
+ RIL3_BSS_AREA_INDICATION bss_area;
+ T_CNI_RIL3_IE_DRX_PARAMETER drx_params;
+ T_RIL3_IE_QOS_PROFILE_ID qos_profile;
+ T_CNI_RIL3_IE_MOBILE_ID tmsi;
+
+} BSSGP_PAGING_PS_MSG;
+
+/*
+ * Radio Status msg
+ */
+typedef struct {
+
+ RIL3_TLLI tlli;
+ T_CNI_RIL3_IE_MOBILE_ID tmsi;
+ T_CNI_RIL3_IE_MOBILE_ID imsi;
+ T_RIL3_IE_RADIO_CAUSE_ID cause;
+
+} BSSGP_RADIO_STATUS_MSG;
+
+
+/*
+ * Suspend msg
+ */
+typedef struct {
+
+ RIL3_TLLI tlli;
+ T_CNI_RIL3_IE_ROUTING_AREA_ID routing_area;
+
+} BSSGP_SUSPEND_MSG;
+
+/*
+ * Suspend Ack
+ */
+typedef struct {
+
+ RIL3_TLLI tlli;
+ T_CNI_RIL3_IE_ROUTING_AREA_ID routing_area;
+ char suspend_ref_num;
+
+} BSSGP_SUSPEND_ACK_MSG;
+
+
+/*
+ * Suspend Nack
+ */
+typedef struct {
+
+ RIL3_TLLI tlli;
+ T_CNI_RIL3_IE_ROUTING_AREA_ID routing_area;
+ RIL3_BSSGP_CAUSE exception_cause;
+
+} BSSGP_SUSPEND_NACK_MSG;
+
+/*
+ * Resume
+ */
+typedef struct {
+
+ RIL3_TLLI tlli;
+ T_CNI_RIL3_IE_ROUTING_AREA_ID routing_area;
+ char suspend_ref_num;
+
+} BSSGP_RESUME_MSG;
+
+
+/*
+ * Resume Ack
+ */
+typedef struct {
+
+ RIL3_TLLI tlli;
+ T_CNI_RIL3_IE_ROUTING_AREA_ID routing_area;
+
+} BSSGP_RESUME_ACK_MSG;
+
+/*
+ * Resume Nack
+ */
+typedef struct {
+
+ RIL3_TLLI tlli;
+ T_CNI_RIL3_IE_ROUTING_AREA_ID routing_area;
+ RIL3_BSSGP_CAUSE exception_cause;
+
+} BSSGP_RESUME_NACK_MSG;
+
+
+
+/*
+ * Location Update
+ */
+typedef struct {
+
+ T_CNI_RIL3_IE_MOBILE_ID imsi;
+ RIL3_BVCI bvci;
+ T_CNI_RIL3_IE_LOCATION_AREA_ID location_area;
+ T_CNI_RIL3_IE_ROUTING_AREA_ID routing_area;
+
+} BSSGP_LOCATION_UPDATE_MSG;
+
+
+/*
+ * Location Update Ack
+ */
+typedef struct {
+
+ T_CNI_RIL3_IE_MOBILE_ID imsi;
+ T_CNI_RIL3_IE_LOCATION_AREA_ID location_area;
+
+} BSSGP_LOCATION_UPDATE_ACK_MSG;
+
+
+/*
+ * Location Update Nack
+ */
+typedef struct {
+
+ T_CNI_RIL3_IE_MOBILE_ID imsi;
+ T_CNI_RIL3_IE_LOCATION_AREA_ID location_area;
+ T_CNI_RIL3_IE_REJECT_CAUSE reject_cause;
+
+} BSSGP_LOCATION_UPDATE_NACK_MSG;
+
+
+/*
+ * Radio-Access-Capability
+ */
+typedef struct {
+
+ RIL3_TLLI tlli;
+ T_CNI_RIL3_IE_MS_RADIO_ACCESS_CAPABILITY ra_cap;
+
+} BSSGP_RADIO_CAP_MSG;
+
+
+/*
+ * Radio-Access-Capability-Update
+ */
+typedef struct {
+
+ RIL3_TLLI tlli;
+ UINT8 tag;
+
+} BSSGP_RADIO_CAP_UPDATE_MSG;
+
+
+/*
+ * Radio-Access-Capability-Update-Ack
+ */
+typedef struct {
+
+ RIL3_TLLI tlli;
+ UINT8 tag;
+ T_CNI_RIL3_IE_MOBILE_ID imsi;
+ RA_CAP_UPD_CAUSE cause;
+ T_CNI_RIL3_IE_MS_RADIO_ACCESS_CAPABILITY ra_cap;
+
+} BSSGP_RADIO_CAP_UPDATE_ACK_MSG;
+
+
+/*
+ * Flush-LL
+ */
+typedef struct {
+
+ RIL3_TLLI tlli;
+ RIL3_BVCI bvci_old;
+ RIL3_BVCI bvci_new;
+
+} BSSGP_FLUSH_LL_MSG;
+
+
+/*
+ * Flush-LL-ACK
+ */
+typedef struct {
+
+ RIL3_TLLI tlli;
+ BSSGP_FLUSH_ACTION flush_action;
+ RIL3_BVCI bvci_new;
+ UINT32 num_octets;
+
+} BSSGP_FLUSH_LL_ACK_MSG;
+
+
+/*
+ * LLC-Discarded
+ */
+typedef struct {
+
+ RIL3_TLLI tlli;
+ UINT8 num_frames;
+ RIL3_BVCI bvci;
+ UINT32 num_octets;
+
+} BSSGP_LLC_DISCARDED_MSG;
+
+
+/*
+ * Flow-Control-BVC
+ */
+typedef struct {
+
+ UINT8 tag;
+ UINT16 bvc_bucket_size;
+ UINT16 bucket_leak_rate;
+ UINT16 bmax;
+ UINT16 r_default;
+ RIL3_BVC_MEASUREMENT bvc_meas;
+
+} BSSGP_FLOW_CONTROL_BVC_MSG;
+
+
+/*
+ * Flow-Control-BVC-ACK
+ */
+typedef struct {
+
+ UINT8 tag;
+
+} BSSGP_FLOW_CONTROL_BVC_ACK_MSG;
+
+
+/*
+ * Flow-Control-MS
+ */
+typedef struct {
+
+ RIL3_TLLI tlli;
+ UINT8 tag;
+ UINT16 ms_bucket_size;
+ UINT16 bucket_leak_rate;
+
+} BSSGP_FLOW_CONTROL_MS_MSG;
+
+
+/*
+ * Flow-Control-MS-ACK
+ */
+typedef struct {
+
+ RIL3_TLLI tlli;
+ UINT8 tag;
+
+} BSSGP_FLOW_CONTROL_MS_ACK_MSG;
+
+
+/*
+ * BVC-Block
+ */
+typedef struct {
+
+ RIL3_BVCI bvci;
+ RIL3_BSSGP_CAUSE cause;
+
+} BSSGP_BVC_BLOCK_MSG;
+
+
+/*
+ * BVC-Block-ACK
+ */
+typedef struct {
+
+ RIL3_BVCI bvci;
+
+} BSSGP_BVC_BLOCK_ACK_MSG;
+
+
+/*
+ * BVC-Unblock
+ */
+typedef struct {
+
+ RIL3_BVCI bvci;
+
+} BSSGP_BVC_UNBLOCK_MSG;
+
+
+/*
+ * BVC-Unblock-ACK
+ */
+typedef struct {
+
+ RIL3_BVCI bvci;
+
+} BSSGP_BVC_UNBLOCK_ACK_MSG;
+
+
+/*
+ * BVC-Reset
+ */
+typedef struct {
+
+ RIL3_BVCI bvci;
+ RIL3_BSSGP_CAUSE cause;
+ RIL3_IE_CELL_IDENTIFIER cell_id;
+
+} BSSGP_BVC_RESET_MSG;
+
+
+/*
+ * BVC-Reset-ACK
+ */
+typedef struct {
+
+ RIL3_BVCI bvci;
+ RIL3_IE_CELL_IDENTIFIER cell_id;
+
+} BSSGP_BVC_RESET_ACK_MSG;
+
+
+/*
+ * BVC-Status
+ */
+typedef struct {
+
+ RIL3_BSSGP_CAUSE cause;
+ RIL3_BVCI bvci;
+
+} BSSGP_BVC_STATUS_MSG;
+
+
+/*
+ * The main API msg; which is overloaded with
+ * all the individual msgs
+ */
+typedef struct {
+
+ BSSGP_API_MSG_TYPE msg_type;
+ BSSGP_BVCI bvci;
+ int magic;
+
+ union {
+ BSSGP_DL_UNITDATA_MSG dl_unitdata; /* From GS --> GP-10 */
+ BSSGP_UL_UNITDATA_MSG ul_unitdata; /* From GP10 --> GS */
+ BSSGP_PAGING_PS_MSG paging_ps; /* From GS --> GP-10 */
+ BSSGP_RADIO_STATUS_MSG radio_status; /* From GP-10 --> GS */
+ BSSGP_SUSPEND_MSG suspend; /* From GP-10 --> GS */
+ BSSGP_SUSPEND_ACK_MSG suspend_ack; /* From GS --> GP-10 */
+ BSSGP_SUSPEND_NACK_MSG suspend_nack; /* From GS --> GP-10 */
+ BSSGP_RESUME_MSG resume; /* From GP-10 --> GS */
+ BSSGP_RESUME_ACK_MSG resume_ack; /* From GS --> GP-10 */
+ BSSGP_RESUME_NACK_MSG resume_nack; /* From GS --> GP-10 */
+ BSSGP_LOCATION_UPDATE_MSG location_update; /* From GS --> GP-10 */
+ BSSGP_LOCATION_UPDATE_ACK_MSG location_update_ack; /* From GP-10 --> GS */
+ BSSGP_LOCATION_UPDATE_NACK_MSG location_update_nack; /* From GP-10 --> GS */
+ BSSGP_RADIO_CAP_MSG radio_cap; /* From GS --> GP-10 */
+ BSSGP_RADIO_CAP_UPDATE_MSG radio_cap_update; /* From GP-10 --> GS */
+ BSSGP_RADIO_CAP_UPDATE_ACK_MSG radio_cap_update_ack; /* From GS --> GP-10 */
+ BSSGP_FLUSH_LL_MSG flush_ll; /* From GS --> GP-10 */
+ BSSGP_FLUSH_LL_ACK_MSG flush_ll_ack; /* From GP-10 --> GS */
+ BSSGP_LLC_DISCARDED_MSG llc_discarded; /* From GP-10 --> GS */
+ BSSGP_FLOW_CONTROL_BVC_MSG flow_control_bvc; /* From GP-10 --> GS */
+ BSSGP_FLOW_CONTROL_BVC_ACK_MSG flow_control_bvc_ack; /* From GS --> GP-10 */
+ BSSGP_FLOW_CONTROL_MS_MSG flow_control_ms; /* From GP-10 --> GS */
+ BSSGP_FLOW_CONTROL_MS_ACK_MSG flow_control_ms_ack; /* From GS --> GP-10 */
+ BSSGP_BVC_BLOCK_MSG bvc_block; /* From GS --> GP-10 */
+ BSSGP_BVC_BLOCK_ACK_MSG bvc_block_ack; /* From GP-10 --> GS */
+ BSSGP_BVC_UNBLOCK_MSG bvc_unblock; /* From GP-10 --> GS */
+ BSSGP_BVC_UNBLOCK_ACK_MSG bvc_unblock_ack; /* From GS --> GP-10 */
+ BSSGP_BVC_RESET_MSG bvc_reset; /* From GS <--> GP-10 */
+ BSSGP_BVC_RESET_ACK_MSG bvc_reset_ack; /* From GS <--> GP-10 */
+ BSSGP_BVC_STATUS_MSG bvc_status; /* From GS <--> GP-10 */
+ } msg;
+
+} BSSGP_API_MSG;
+
+
+
+
+/*
+ * API function prototypes
+ */
+
+/*
+ * This function below will be called by :-
+ * On GP-10 : GMM1 and RLC/MAC layers
+ * On GS : GMM2 and LLC
+ */
+BOOL bssgp_api_send_msg(BSSGP_API_MSG msg);
+
+/*
+ * Callback function provided by :
+ * GMM1 on GP-10
+ * GMM2 on GS
+ */
+BOOL gmm_bssgp_msg_callback(BSSGP_API_MSG msg);
+/* GRR needs to be called for packet-switched paging msg only */
+BOOL rm_bssgp_msg_callback(BSSGP_API_MSG msg);
+
+
+/*
+ * Common facility on both platforms to add a BVCI
+ */
+BSSGP_BVCI bssgp_net_add_bvci(char *peer_ip_addr, T_CNI_RIL3_IE_CELL_ID cell_id,UINT8 rac);
+
+
+#if defined(MNET_GP10)
+/*
+ * Callbacks defined by
+ * RLC/MAC on the GP-10
+ */
+BOOL rlc_bssgp_msg_callback(BSSGP_API_MSG msg);
+
+#elif defined(MNET_GS)
+
+/*
+ * interface to LLC on the GS
+ */
+BOOL bssgp_llc_api_handler(GS_BssgpDlUnitdataReq_t dl_unitdata);
+
+/*
+ *
+ */
+void bssgp_api_send_ul_unitdata(TLLI tlli,T_CNI_RIL3_IE_CELL_ID cell_id,T_CNI_RIL3_IE_ROUTING_AREA_ID rai,UINT8 *pdu_data,UINT16 pdu_len,BSSGP_BVCI bvci);
+
+
+UINT16 bssgp_api_get_bvc_leak_rate_by_cell_id_rac(T_CNI_RIL3_IE_CELL_ID cell_id,UINT8 rac);
+BSSGP_BVCI bssgp_net_get_bvci_by_cell_id_rac(T_CNI_RIL3_IE_CELL_ID cell_id,UINT8 rac);
+void bssgp_net_delete_bvci(BSSGP_BVCI bvci);
+void bssgp_net_delete_bvci_by_cell_id_rac(T_CNI_RIL3_IE_CELL_ID cell_id,UINT8 rac);
+
+#endif
+
+
+#endif /* #ifndef _BSSGP_API_HDR_INC_ */ \ No newline at end of file
diff --git a/data/mnet/Common/include/bssgp/bssgp_decoder.h b/data/mnet/Common/include/bssgp/bssgp_decoder.h
new file mode 100644
index 0000000..77d8f86
--- /dev/null
+++ b/data/mnet/Common/include/bssgp/bssgp_decoder.h
@@ -0,0 +1,68 @@
+/*
+ ****************************************************************************************
+ * *
+ * Copyright Cisco Systems, Inc 2000 All rights reserved *
+ * *
+ * File : bssgp_decoder.h *
+ * *
+ * Description : Decoding function prototypes for the BSS-GP layer module *
+ * *
+ * Author : Dinesh Nambisan *
+ * *
+ *----------------------- Revision history ---------------------------------------------*
+ * Time | Date | Name | Description *
+ *--------------------------------------------------------------------------------------*
+ * 00:00 |10/10/00 | DSN | File created *
+ * | | | *
+ ****************************************************************************************
+ */
+#ifndef BSSGP_DECODER_HDR_INCLUDE
+#define BSSGP_DECODER_HDR_INCLUDE
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "bssgp_prot.h"
+#include "bssgp_util.h"
+#include "bssgp_api.h"
+
+/*
+ * Just the function prototypes
+ */
+BOOL bssgp_decode_msg(UINT8 *msg,UINT16 msg_len,BOOL incoming,
+ BSSGP_NETWORK_QOS_LEVEL qos_level,BSSGP_BVCI bvci,BOOL *free_buff);
+BOOL bssgp_decode_dl_unitdata(UINT8 *msg,UINT16 *len, BSSGP_NETWORK_QOS_LEVEL qos_level);
+BOOL bssgp_decode_ul_unitdata(UINT8 *msg,UINT16 *len,BSSGP_NETWORK_QOS_LEVEL qos_level,BSSGP_BVCI bvci);
+BOOL bssgp_decode_paging_ps(UINT8 *msg,UINT16 *msg_len, BOOL incoming);
+BOOL bssgp_decode_radio_status(UINT8 *msg,UINT16 *msg_len, BOOL incoming);
+BOOL bssgp_decode_suspend(UINT8 *msg,UINT16 *msg_len, BOOL incoming);
+BOOL bssgp_decode_suspend_ack(UINT8 *msg,UINT16 *msg_len, BOOL incoming);
+BOOL bssgp_decode_suspend_nack(UINT8 *msg,UINT16 *msg_len, BOOL incoming);
+BOOL bssgp_decode_resume(UINT8 *msg,UINT16 *msg_len, BOOL incoming);
+BOOL bssgp_decode_resume_ack(UINT8 *msg,UINT16 *msg_len, BOOL incoming);
+BOOL bssgp_decode_resume_nack(UINT8 *msg,UINT16 *msg_len, BOOL incoming);
+BOOL bssgp_decode_location_update(UINT8 *msg,UINT16 *msg_len, BOOL incoming);
+BOOL bssgp_decode_location_update_ack(UINT8 *msg,UINT16 *msg_len, BOOL incoming);
+BOOL bssgp_decode_location_update_nack(UINT8 *msg,UINT16 *msg_len, BOOL incoming);
+BOOL bssgp_decode_radio_cap(UINT8 *msg,UINT16 *msg_len, BOOL incoming);
+BOOL bssgp_decode_radio_cap_update(UINT8 *msg,UINT16 *msg_len, BOOL incoming);
+BOOL bssgp_decode_radio_cap_update_ack(UINT8 *msg,UINT16 *msg_len, BOOL incoming);
+BOOL bssgp_decode_flow_control_ms(UINT8 *msg,UINT16 *msg_len, BOOL incoming);
+BOOL bssgp_decode_flow_control_ms_ack(UINT8 *msg,UINT16 *msg_len, BOOL incoming);
+BOOL bssgp_decode_flush_ll(UINT8 *msg,UINT16 *msg_len, BOOL incoming);
+BOOL bssgp_decode_flush_ll_ack(UINT8 *msg,UINT16 *msg_len, BOOL incoming);
+BOOL bssgp_decode_llc_discarded(UINT8 *msg,UINT16 *msg_len, BOOL incoming);
+BOOL bssgp_decode_flow_control_bvc(UINT8 *msg,UINT16 *msg_len, BOOL incoming);
+BOOL bssgp_decode_flow_control_bvc_ack(UINT8 *msg,UINT16 *msg_len, BOOL incoming);
+BOOL bssgp_decode_block(UINT8 *msg,UINT16 *msg_len, BOOL incoming);
+BOOL bssgp_decode_block_ack(UINT8 *msg,UINT16 *msg_len, BOOL incoming);
+BOOL bssgp_decode_unblock(UINT8 *msg,UINT16 *msg_len, BOOL incoming);
+BOOL bssgp_decode_unblock_ack(UINT8 *msg,UINT16 *msg_len, BOOL incoming);
+BOOL bssgp_decode_reset(UINT8 *msg,UINT16 *msg_len, BOOL incoming);
+BOOL bssgp_decode_reset_ack(UINT8 *msg,UINT16 *msg_len, BOOL incoming);
+BOOL bssgp_decode_status(UINT8 *msg,UINT16 *msg_len, BOOL incoming);
+
+
+#ifdef WIN32
+void llcwin32_pdu_handler(LLC_PDU);
+#endif
+#endif /* #ifndef BSSGP_DECODER_HDR_INCLUDE */ \ No newline at end of file
diff --git a/data/mnet/Common/include/bssgp/bssgp_encoder.h b/data/mnet/Common/include/bssgp/bssgp_encoder.h
new file mode 100644
index 0000000..517b4d8
--- /dev/null
+++ b/data/mnet/Common/include/bssgp/bssgp_encoder.h
@@ -0,0 +1,69 @@
+/*
+ ****************************************************************************************
+ * *
+ * Copyright Cisco Systems, Inc 2000 All rights reserved *
+ * *
+ * File : bssgp_encoder.h *
+ * *
+ * Description : Encoding function prototypes for the BSS-GP layer module *
+ * *
+ * Author : Dinesh Nambisan *
+ * *
+ *----------------------- Revision history ---------------------------------------------*
+ * Time | Date | Name | Description *
+ *--------------------------------------------------------------------------------------*
+ * 00:00 |10/10/00 | DSN | File created *
+ * | | | *
+ ****************************************************************************************
+ */
+#ifndef BSSGP_ENCODER_HDR_INCLUDE
+#define BSSGP_ENCODER_HDR_INCLUDE
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "bssgp_prot.h"
+#include "bssgp_util.h"
+#include "bssgp_api.h"
+
+
+BOOL bssgp_encode_msg(BSSGP_API_MSG *api_msg,UINT8 *msg,UINT16 *msg_len,
+ BSSGP_NETWORK_QOS_LEVEL *qos_reqd, BOOL *tx_msg);
+BOOL bssgp_encode_dl_unitdata(BSSGP_DL_UNITDATA_MSG dl_unitdata_msg ,UINT8 *msg,
+ UINT16 *len, BSSGP_NETWORK_QOS_LEVEL *qos_reqd, BOOL *tx_msg);
+BOOL bssgp_encode_ul_unitdata(BSSGP_UL_UNITDATA_MSG ul_unitdata_msg,UINT8 *msg,UINT16 *len,
+ BSSGP_NETWORK_QOS_LEVEL *qos_reqd, BOOL *tx_msg);
+BOOL bssgp_encode_paging_ps(BSSGP_PAGING_PS_MSG paging_msg ,UINT8 *msg,UINT16 *msg_len);
+BOOL bssgp_encode_radio_status(BSSGP_RADIO_STATUS_MSG radio_status_msg ,UINT8 *msg,UINT16 *msg_len);
+BOOL bssgp_encode_suspend(BSSGP_SUSPEND_MSG suspend_msg,UINT8 *msg,UINT16 *msg_len);
+BOOL bssgp_encode_suspend_ack(BSSGP_SUSPEND_ACK_MSG suspend_ack_msg ,UINT8 *msg,UINT16 *msg_len);
+BOOL bssgp_encode_suspend_nack(BSSGP_SUSPEND_NACK_MSG suspend_nack_msg ,UINT8 *msg,UINT16 *msg_len);
+BOOL bssgp_encode_resume(BSSGP_RESUME_MSG resume_msg ,UINT8 *msg,UINT16 *msg_len);
+BOOL bssgp_encode_resume_ack(BSSGP_RESUME_ACK_MSG resume_ack_msg ,UINT8 *msg,UINT16 *msg_len);
+BOOL bssgp_encode_resume_nack(BSSGP_RESUME_NACK_MSG resume_nack_msg ,UINT8 *msg,UINT16 *msg_len);
+BOOL bssgp_encode_location_update(BSSGP_LOCATION_UPDATE_MSG location_update_msg ,UINT8 *msg,UINT16 *msg_len);
+BOOL bssgp_encode_location_update_ack(BSSGP_LOCATION_UPDATE_ACK_MSG location_update_ack ,
+ UINT8 *msg,UINT16 *msg_len);
+BOOL bssgp_encode_location_update_nack(BSSGP_LOCATION_UPDATE_NACK_MSG location_update_nack ,UINT8 *msg,
+ UINT16 *msg_len);
+BOOL bssgp_encode_radio_cap(BSSGP_RADIO_CAP_MSG radio_cap ,UINT8 *msg,UINT16 *msg_len);
+BOOL bssgp_encode_radio_cap_update(BSSGP_RADIO_CAP_UPDATE_MSG radio_cap_update ,UINT8 *msg,
+ UINT16 *msg_len);
+BOOL bssgp_encode_radio_cap_update_ack(BSSGP_RADIO_CAP_UPDATE_ACK_MSG radio_cap_update_ack ,UINT8 *msg,
+ UINT16 *msg_len);
+BOOL bssgp_encode_flow_control_ms(BSSGP_FLOW_CONTROL_MS_MSG flow_control_ms,UINT8 *msg,UINT16 *msg_len);
+BOOL bssgp_encode_flow_control_ms_ack(BSSGP_FLOW_CONTROL_MS_ACK_MSG flow_control_ms_ack,UINT8 *msg,UINT16 *msg_len);
+BOOL bssgp_encode_flush_ll(BSSGP_FLUSH_LL_MSG flush_ll,UINT8 *msg,UINT16 *msg_len);
+BOOL bssgp_encode_flush_ll_ack(BSSGP_FLUSH_LL_ACK_MSG flush_ll_ack,UINT8 *msg,UINT16 *msg_len);
+BOOL bssgp_encode_flow_control_bvc(BSSGP_FLOW_CONTROL_BVC_MSG flow_control_bvc, UINT8 *msg,UINT16 *msg_len);
+BOOL bssgp_encode_flow_control_bvc_ack(BSSGP_FLOW_CONTROL_BVC_ACK_MSG flow_control_bvc_ack, UINT8 *msg,UINT16 *msg_len);
+BOOL bssgp_encode_llc_discarded(BSSGP_LLC_DISCARDED_MSG llc_discarded,UINT8 *msg,UINT16 *msg_len);
+BOOL bssgp_encode_bvc_block(BSSGP_BVC_BLOCK_MSG bvc_block,UINT8 *msg,UINT16 *msg_len);
+BOOL bssgp_encode_bvc_block_ack(BSSGP_BVC_BLOCK_ACK_MSG bvc_block_ack,UINT8 *msg,UINT16 *msg_len);
+BOOL bssgp_encode_bvc_unblock(BSSGP_BVC_UNBLOCK_MSG bvc_unblock,UINT8 *msg,UINT16 *msg_len);
+BOOL bssgp_encode_bvc_unblock_ack(BSSGP_BVC_UNBLOCK_ACK_MSG bvc_unblock_ack,UINT8 *msg,UINT16 *msg_len);
+BOOL bssgp_encode_bvc_reset(BSSGP_BVC_RESET_MSG bvc_reset,UINT8 *msg,UINT16 *msg_len);
+BOOL bssgp_encode_bvc_reset_ack(BSSGP_BVC_RESET_ACK_MSG bvc_reset_ack,UINT8 *msg,UINT16 *msg_len);
+BOOL bssgp_encode_bvc_status(BSSGP_BVC_STATUS_MSG bvc_status,UINT8 *msg,UINT16 *msg_len);
+
+
+#endif /* #ifndef BSSGP_ENCODER_HDR_INCLUDE */ \ No newline at end of file
diff --git a/data/mnet/Common/include/bssgp/bssgp_ie_decoder.h b/data/mnet/Common/include/bssgp/bssgp_ie_decoder.h
new file mode 100644
index 0000000..fd8f8f3
--- /dev/null
+++ b/data/mnet/Common/include/bssgp/bssgp_ie_decoder.h
@@ -0,0 +1,77 @@
+/****************************************************************************************
+ * *
+ * Copyright Cisco Systems, Inc 2000 All rights reserved *
+ * *
+ * File : bssgp_ie_decoder.h *
+ * *
+ * Description : Function prototypes for the IEI decoder module of BSSGP *
+ * *
+ * Author : Dinesh Nambisan *
+ * *
+ *----------------------- Revision history ---------------------------------------------*
+ * Time | Date | Name | Description *
+ *--------------------------------------------------------------------------------------*
+ * 00:00 |10/10/00 | DSN | File created *
+ * | | | *
+ ****************************************************************************************
+ */
+
+#ifndef BSSGP_IE_DEC_HDR_INCLUDE
+#define BSSGP_IE_DEC_HDR_INCLUDE
+
+#include <stdio.h>
+#include "bssgp_prot.h"
+#include "bssgp_api.h"
+
+
+/*
+ * All the function prototpes
+ */
+BOOL bssgp_ie_decode_alignment_octets(UINT8 *msg,UINT16 *len);
+BOOL bssgp_ie_decode_bmax_def_ms(UINT16 *bmax, UINT8 *msg,UINT16 *len);
+BOOL bssgp_ie_decode_bss_area_ind(RIL3_BSS_AREA_INDICATION *bss_area, UINT8 *msg,UINT16 *len);
+BOOL bssgp_ie_decode_bucket_leak_rate(UINT16 *r_value, UINT8 *msg,UINT16 *len);
+BOOL bssgp_ie_decode_bvc_bucket_size(UINT16 *bmax, UINT8 *msg,UINT16 *len);
+BOOL bssgp_ie_decode_bvci(RIL3_BVCI *bvci,UINT8 *msg,UINT16 *len);
+BOOL bssgp_ie_decode_bvc_measurement(RIL3_BVC_MEASUREMENT *delay_val, UINT8 *msg,UINT16 *len);
+BOOL bssgp_ie_decode_exception_cause(RIL3_BSSGP_CAUSE *cause,UINT8 *msg,UINT16 *len);
+BOOL bssgp_ie_decode_cell_id(RIL3_IE_CELL_IDENTIFIER *cell_id,UINT8 *msg,UINT16 *len);
+BOOL bssgp_ie_decode_channel_needed(UINT8 *val, UINT8 *msg,UINT16 *len);
+BOOL bssgp_ie_decode_drx_params(T_CNI_RIL3_IE_DRX_PARAMETER *drx_params,UINT8 *msg,UINT16 *len);
+BOOL bssgp_ie_decode_emlpp_priority(UINT8 *val, UINT8 *msg,UINT16 *len);
+BOOL bssgp_ie_decode_flush_action(BSSGP_FLUSH_ACTION *action, UINT8 *msg,UINT16 *len);
+BOOL bssgp_ie_decode_imsi(T_CNI_RIL3_IE_MOBILE_ID *imsi,UINT8 *msg,UINT16 *msg_len);
+BOOL bssgp_ie_decode_llc_pdu(BSSGP_DL_UNITDATA_MSG *dl_unitdata,UINT8 *msg,UINT16 *len);
+UINT8* bssgp_ie_decode_llc_pdu_ext(UINT16 *pdu_len,UINT8 *msg,UINT16 *len);
+
+BOOL bssgp_ie_decode_llc_frames_discarded(UINT8 *frames, UINT8 *msg,UINT16 *len);
+BOOL bssgp_ie_decode_location_area(T_CNI_RIL3_IE_LOCATION_AREA_ID *location_area,UINT8 *msg,UINT16 *len);
+BOOL bssgp_ie_decode_lsa_identifier_list(RIL3_IE_LSA_IDENTIFIER_LIST *lsa_id_list,UINT8 *msg,UINT16 *len);
+BOOL bssgp_ie_decode_lsa_info(RIL3_IE_LSA_INFORMATION *lsa_info, UINT8 *msg,UINT16 *len);
+BOOL bssgp_ie_decode_mobile_id(UINT8 *msg,UINT16 *len);
+BOOL bssgp_ie_decode_ms_bucket_size(UINT16 *bmax, UINT8 *msg,UINT16 *len);
+BOOL bssgp_ie_decode_ms_ra_cap(T_CNI_RIL3_IE_MS_RADIO_ACCESS_CAPABILITY *ra_cap,UINT8 *msg,UINT16 *len);
+BOOL bssgp_ie_decode_omc_id(UINT8 *msg,UINT16 *len);
+BOOL bssgp_ie_decode_pdu_in_error(UINT8 *llc_pdu,UINT16 *pdu_len,UINT8 *msg,UINT16 *len);
+BOOL bssgp_ie_decode_pdu_lifetime(RIL3_IE_PDU_LIFETIME *delay, UINT8 *msg,UINT16 *len);
+BOOL bssgp_ie_decode_priority(RIL3_IE_PRIORITY *priority, UINT8 *msg,UINT16 *len);
+BOOL bssgp_ie_decode_qos_params(T_CNI_RIL3_IE_QOS *qos_params, UINT8 *msg, UINT16 *len);
+BOOL bssgp_ie_decode_qos_profile(T_RIL3_IE_QOS_PROFILE_ID *qos_profile,UINT8 *msg,UINT16 *len, BSSGP_IEI_FORMAT format);
+BOOL bssgp_ie_decode_radio_cause(T_RIL3_IE_RADIO_CAUSE_ID *radio_cause,UINT8 *msg,UINT16 *len);
+BOOL bssgp_ie_decode_ra_cap_update_cause(RA_CAP_UPD_CAUSE *ra_cause,UINT8 *msg,UINT16 *len);
+BOOL bssgp_ie_decode_reject_cause(T_CNI_RIL3_IE_REJECT_CAUSE *reject_cause, UINT8 *msg, UINT16 *len);
+BOOL bssgp_ie_decode_routing_area(T_CNI_RIL3_IE_ROUTING_AREA_ID *routing_area,UINT8 *msg,UINT16 *len);
+BOOL bssgp_ie_decode_r_def_ms(UINT16 *r_default,UINT8 *msg,UINT16 *len);
+BOOL bssgp_ie_decode_suspend_ref_num(UINT8 *suspend_ref_num,UINT8 *msg,UINT16 *len);
+BOOL bssgp_ie_decode_tag(UINT8 *tag,UINT8 *msg,UINT16 *len);
+BOOL bssgp_ie_decode_tlli(RIL3_TLLI *tlli,UINT8 *msg,UINT16 *len, BSSGP_IEI_FORMAT format);
+BOOL bssgp_ie_decode_tmsi(T_CNI_RIL3_IE_MOBILE_ID *tmsi,UINT8 *msg,UINT16 *len);
+BOOL bssgp_ie_decode_trace_ref(UINT8 *msg,UINT16 *len);
+BOOL bssgp_ie_decode_trace_type(UINT8 *msg,UINT16 *len);
+BOOL bssgp_ie_decode_txn_id(UINT8 *msg,UINT16 *len);
+BOOL bssgp_ie_decode_trigger_id(UINT8 *msg,UINT16 *len);
+BOOL bssgp_ie_decode_num_octets_affected(UINT32 *num,UINT8 *msg,UINT16 *len);
+UINT16 bssgp_ie_decode_iei_length(UINT8 *msg,UINT16 *msg_len);
+
+
+#endif /* #ifndef BSSGP_IE_DEC_HDR_INCLUDE */ \ No newline at end of file
diff --git a/data/mnet/Common/include/bssgp/bssgp_ie_encoder.h b/data/mnet/Common/include/bssgp/bssgp_ie_encoder.h
new file mode 100644
index 0000000..ba84b9a
--- /dev/null
+++ b/data/mnet/Common/include/bssgp/bssgp_ie_encoder.h
@@ -0,0 +1,75 @@
+/****************************************************************************************
+ * *
+ * Copyright Cisco Systems, Inc 2000 All rights reserved *
+ * *
+ * File : bssgp_ie_encoder.h *
+ * *
+ * Description : Function prototypes for the IEI encoder module of BSSGP *
+ * *
+ * Author : Dinesh Nambisan *
+ * *
+ *----------------------- Revision history ---------------------------------------------*
+ * Time | Date | Name | Description *
+ *--------------------------------------------------------------------------------------*
+ * 00:00 |10/10/00 | DSN | File created *
+ * | | | *
+ ****************************************************************************************
+ */
+
+#ifndef BSSGP_IE_ENC_HDR_INCLUDE
+#define BSSGP_IE_ENC_HDR_INCLUDE
+
+#include <stdio.h>
+#include "bssgp_prot.h"
+#include "bssgp_api.h"
+
+
+/*
+ * All the function prototpes
+ */
+void bssgp_ie_encode_alignment_octets(UINT8 count,UINT8 *msg,UINT16 *len);
+void bssgp_ie_encode_bmax_def_ms(UINT16 bmax,UINT8 *msg,UINT16 *len);
+void bssgp_ie_encode_bss_area_ind(RIL3_BSS_AREA_INDICATION bss_area,UINT8 *msg,UINT16 *len);
+void bssgp_ie_encode_bucket_leak_rate(UINT16 leak_rate,UINT8 *msg,UINT16 *len);
+void bssgp_ie_encode_bvc_bucket_size(UINT16 bucket_size,UINT8 *msg,UINT16 *len);
+void bssgp_ie_encode_bvci(RIL3_BVCI bvci,UINT8 *msg,UINT16 *len);
+void bssgp_ie_encode_bvc_measurement(RIL3_BVC_MEASUREMENT bvc_meas,UINT8 *msg,UINT16 *len);
+void bssgp_ie_encode_exception_cause(RIL3_BSSGP_CAUSE cause,UINT8 *msg,UINT16 *len);
+void bssgp_ie_encode_cell_id(RIL3_IE_CELL_IDENTIFIER cell_id,UINT8 *msg,UINT16 *len);
+void bssgp_ie_encode_channel_needed(UINT8 *msg,UINT16 *len);
+void bssgp_ie_encode_drx_params(T_CNI_RIL3_IE_DRX_PARAMETER drx_params,UINT8 *msg,UINT16 *len);
+void bssgp_ie_encode_emlpp_priority(UINT8 *msg,UINT16 *len);
+void bssgp_ie_encode_flush_action(BSSGP_FLUSH_ACTION flush_action,UINT8 *msg,UINT16 *len);
+void bssgp_ie_encode_imsi(T_CNI_RIL3_IE_MOBILE_ID imsi,UINT8 *msg,UINT16 *msg_len);
+void bssgp_ie_encode_llc_pdu(UINT8* llc_pdu, UINT16 pdu_len,UINT8 *msg,UINT16 *len);
+void bssgp_ie_encode_llc_frames_discarded(UINT8 num_frames,UINT8 *msg,UINT16 *len);
+void bssgp_ie_encode_location_area(T_CNI_RIL3_IE_LOCATION_AREA_ID location_area,UINT8 *msg,UINT16 *len);
+void bssgp_ie_encode_lsa_identifier_list(RIL3_IE_LSA_IDENTIFIER_LIST lsa_id_list,UINT8 *msg,UINT16 *len);
+void bssgp_ie_encode_lsa_info(RIL3_IE_LSA_INFORMATION lsa_info,UINT8 *msg,UINT16 *len);
+void bssgp_ie_encode_mobile_id(UINT8 *msg,UINT16 *len);
+void bssgp_ie_encode_ms_bucket_size(UINT16 bucket_size,UINT8 *msg,UINT16 *len);
+void bssgp_ie_encode_ms_ra_cap(T_CNI_RIL3_IE_MS_RADIO_ACCESS_CAPABILITY ra_cap,UINT8 *msg,UINT16 *len);
+void bssgp_ie_encode_omc_id(UINT8 *msg,UINT16 *len);
+void bssgp_ie_encode_pdu_in_error(BSSGP_PDU_TYPE pdu_type,UINT8 *msg,UINT16 *len);
+void bssgp_ie_encode_pdu_lifetime(RIL3_IE_PDU_LIFETIME pdu_lifetime,UINT8 *msg,UINT16 *len);
+void bssgp_ie_encode_priority(RIL3_IE_PRIORITY priority,UINT8 *msg,UINT16 *len);
+void bssgp_ie_encode_qos_params(T_CNI_RIL3_IE_QOS qos_params, UINT8 *msg, UINT16 *len);
+void bssgp_ie_encode_qos_profile(T_RIL3_IE_QOS_PROFILE_ID qos_profile,UINT8 *msg,UINT16 *len, BSSGP_IEI_FORMAT format);
+void bssgp_ie_encode_radio_cause(T_RIL3_IE_RADIO_CAUSE_ID radio_cause,UINT8 *msg,UINT16 *len);
+void bssgp_ie_encode_reject_cause(T_CNI_RIL3_IE_REJECT_CAUSE reject_cause, UINT8 *msg, UINT16 *len);
+void bssgp_ie_encode_ra_cap_update_cause(RA_CAP_UPD_CAUSE ra_cause,UINT8 *msg,UINT16 *len);
+void bssgp_ie_encode_routing_area(T_CNI_RIL3_IE_ROUTING_AREA_ID routing_area,UINT8 *msg,UINT16 *len);
+void bssgp_ie_encode_r_def_ms(UINT16 r_default,UINT8 *msg,UINT16 *len);
+void bssgp_ie_encode_suspend_ref_num(UINT8 suspend_ref_num,UINT8 *msg,UINT16 *len);
+void bssgp_ie_encode_tag(UINT8 tag,UINT8 *msg,UINT16 *len);
+void bssgp_ie_encode_tlli(RIL3_TLLI tlli,UINT8 *msg,UINT16 *len, BSSGP_IEI_FORMAT format);
+void bssgp_ie_encode_tmsi(T_CNI_RIL3_IE_MOBILE_ID tmsi,UINT8 *msg,UINT16 *len);
+void bssgp_ie_encode_trace_ref(UINT8 *msg,UINT16 *len);
+void bssgp_ie_encode_trace_type(UINT8 *msg,UINT16 *len);
+void bssgp_ie_encode_txn_id(UINT8 *msg,UINT16 *len);
+void bssgp_ie_encode_trigger_id(UINT8 *msg,UINT16 *len);
+void bssgp_ie_encode_num_octets_affected(UINT32 num_octets,UINT8 *msg,UINT16 *len);
+void bssgp_ie_encode_iei_length(int iei_len,UINT8 *msg,UINT16 *msg_len);
+
+
+#endif /* BSSGP_IE_ENC_HDR_INCLUDE */
diff --git a/data/mnet/Common/include/bssgp/bssgp_net.h b/data/mnet/Common/include/bssgp/bssgp_net.h
new file mode 100644
index 0000000..68f61f8
--- /dev/null
+++ b/data/mnet/Common/include/bssgp/bssgp_net.h
@@ -0,0 +1,83 @@
+/*
+ ****************************************************************************************
+ * *
+ * Copyright Cisco Systems, Inc 2000 All rights reserved *
+ * *
+ * File : bssgp_net.h *
+ * *
+ * Description : Network handling functions for the BSS-GP layer module *
+ * *
+ * Author : Dinesh Nambisan *
+ * *
+ *----------------------- Revision history ---------------------------------------------*
+ * Time | Date | Name | Description *
+ *--------------------------------------------------------------------------------------*
+ * 00:00 |10/10/00 | DSN | File created *
+ * | | | *
+ ****************************************************************************************
+ */
+#ifndef BSSGP_NET_HDR_INCLUDE
+#define BSSGP_NET_HDR_INCLUDE
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "bssgp_prot.h"
+#include "bssgp_util.h"
+#include "bssgp_api.h"
+#include "ril3/ie_cell_id.h"
+
+typedef struct {
+
+ BOOL used;
+ char peer_ip_addr[INET_ADDR_LEN];
+ T_CNI_RIL3_IE_CELL_ID cell_id;
+ UINT8 routing_area_code;
+ UINT16 leak_rate;
+ BSSGP_BVCI peer_bvci;
+
+} BSSGP_BVCI_ENTRY;
+
+
+typedef struct {
+
+ int socks[BSSGP_MAX_NETWORK_QOS_LEVELS];
+ unsigned short ports[BSSGP_MAX_NETWORK_QOS_LEVELS];
+ unsigned short base_port;
+ BOOL continue_processing;
+
+ BSSGP_BVCI_ENTRY bvci_list[BSSGP_MAX_BVCI];
+
+ int init_magic;
+
+} BSSGP_NET_CONFIG;
+
+
+/*
+ * Function prototypes
+ */
+BOOL bssgp_net_initialize(void);
+void bssgp_net_task(void);
+void bssgp_net_rx_handler(int index,int rx_bytes);
+BOOL bssgp_net_init_bvcis(void);
+BSSGP_BVCI bssgp_net_get_bvci_by_ip(char *ip_addr);
+char *bssgp_net_get_ip_by_bvci(BSSGP_BVCI bvci);
+#if defined(MNET_GS)
+/*
+ ******************************************************************
+ * Network Functions specific to the GS Platform
+ ******************************************************************
+ */
+BOOL bssgp_net_tx_msg(BSSGP_BVCI bvci,BSSGP_NETWORK_QOS_LEVEL qos_level,UINT8 *msg,UINT16 msg_len);
+
+#elif defined(MNET_GP10)
+/*
+ ******************************************************************
+ * Network Functions specific to the GP-10 Platform
+ ******************************************************************
+ */
+BOOL bssgp_net_tx_msg(BSSGP_NETWORK_QOS_LEVEL qos_level,UINT8 *msg,UINT16 msg_len);
+
+#endif
+
+
+#endif /* #ifndef BSSGP_NET_HDR_INCLUDE */ \ No newline at end of file
diff --git a/data/mnet/Common/include/bssgp/bssgp_prot.h b/data/mnet/Common/include/bssgp/bssgp_prot.h
new file mode 100644
index 0000000..c1465ff
--- /dev/null
+++ b/data/mnet/Common/include/bssgp/bssgp_prot.h
@@ -0,0 +1,180 @@
+/****************************************************************************************
+ * *
+ * Copyright Cisco Systems, Inc 2000 All rights reserved *
+ * *
+ * File : bssgp_prot.h *
+ * *
+ * Description : Header file containing data structures & definitions for the *
+ * BSS-GP layer *
+ * *
+ * Author : Dinesh Nambisan *
+ * *
+ *----------------------- Revision history ---------------------------------------------*
+ * Time | Date | Name | Description *
+ *--------------------------------------------------------------------------------------*
+ * 00:00 |10/10/00 | DSN | File created *
+ * | | | *
+ ****************************************************************************************
+ */
+
+#ifndef BSSGP_PROT_HDR_INCLUDE
+#define BSSGP_PROT_HDR_INCLUDE
+
+#define BSSGP_MAGIC 0x1234
+#define BSSGP_BVCI unsigned short /* just an index into an array, really */
+#define BSSGP_MAX_BVCI 10
+#define BSSGP_ROOT_BVCI 0 /* for the GP-10 there is only 1 BVCI */
+
+/*
+ * The IE Identifier types
+ */
+typedef enum {
+
+ BSSGP_IEI_ALIGNMENT_OCTETS = 0x00,
+ BSSGP_IEI_BMAX_DEFAULT_MS = 0x01,
+ BSSGP_IEI_BSS_AREA_IND = 0x02,
+ BSSGP_IEI_BUCKET_LEAK_RATE = 0x03,
+ BSSGP_IEI_BVCI = 0x04,
+ BSSGP_IEI_BVC_BUCKET_SIZE = 0x05,
+ BSSGP_IEI_BVC_MEASUREMENT = 0x06,
+ BSSGP_IEI_CAUSE = 0x07,
+ BSSGP_IEI_CELL_ID = 0x08,
+ BSSGP_IEI_CHAN_NEEDED = 0x09,
+ BSSGP_IEI_DRX_PARAMS = 0x0a,
+ BSSGP_IEI_EMLPP_PRIORITY = 0x0b,
+ BSSGP_IEI_FLUSH_ACTION = 0x0c,
+ BSSGP_IEI_IMSI = 0x0d,
+ BSSGP_IEI_LLC_PDU = 0x0e,
+ BSSGP_IEI_LLC_FRAMES_DISCARDED = 0x0f,
+ BSSGP_IEI_LOCATION_AREA = 0x10,
+ BSSGP_IEI_MOBILE_ID = 0x11,
+ BSSGP_IEI_MS_BUCKET_SIZE = 0x12,
+ BSSGP_IEI_MS_RADIO_ACCESS_CAP = 0x13,
+ BSSGP_IEI_OMC_ID = 0x14,
+ BSSGP_IEI_PDU_IN_ERROR = 0x15,
+ BSSGP_IEI_PDU_LIFETIME = 0x16,
+ BSSGP_IEI_PRIORITY = 0x17,
+ BSSGP_IEI_QOS_PROFILE = 0x18,
+ BSSGP_IEI_RADIO_CAUSE = 0x19,
+ BSSGP_IEI_RA_CAP_UPD_CAUSE = 0x1a,
+ BSSGP_IEI_ROUTING_AREA = 0x1b,
+ BSSGP_IEI_R_DEFAULT_MS = 0x1c,
+ BSSGP_IEI_SUSPEND_REF_NUM = 0x1d,
+ BSSGP_IEI_TAG = 0x1e,
+ BSSGP_IEI_TLLI = 0x1f,
+ BSSGP_IEI_TMSI = 0x20,
+ BSSGP_IEI_TRACE_REF = 0x21,
+ BSSGP_IEI_TRACE_TYPE = 0x22,
+ BSSGP_IEI_TRANSACTION_ID = 0x23,
+ BSSGP_IEI_TRIGGER_ID = 0x24,
+ BSSGP_IEI_NUM_OCTETS_AFFECTED = 0x25,
+ BSSGP_IEI_LSA_ID_LIST = 0x26,
+ BSSGP_IEI_LSA_INFORMATION = 0x27,
+
+ /* Cisco-EWTBU proprietary extensions */
+ BSSGP_IEI_QOS_PARAMS = 0x28,
+ BSSGP_IEI_LA_REJECT_CAUSE = 0x29,
+
+
+ BSSGP_IEI_MAX_TYPES = 0x30
+
+} BSSGP_IEI_TYPE;
+
+/*
+ * Information Element Format
+ */
+typedef enum {
+ BSSGP_FORMAT_V = 0x0,
+ BSSGP_FORMAT_TLV = 0x1
+} BSSGP_IEI_FORMAT;
+
+/*
+ * PDU Types
+ */
+typedef enum {
+
+ BSSGP_PDU_DL_UNITDATA = 0x00,
+ BSSGP_PDU_UL_UNITDATA = 0x01,
+ BSSGP_PDU_RA_CAP = 0x02,
+ BSSGP_PDU_PTM_UNITDATA = 0x03,
+
+ BSSGP_PDU_PAGING_PS = 0x06,
+ BSSGP_PDU_PAGING_CS = 0x07,
+ BSSGP_PDU_RA_CAP_UPDATE = 0x08,
+ BSSGP_PDU_RA_CAP_UPDATE_ACK = 0x09,
+ BSSGP_PDU_RADIO_STATUS = 0x0a,
+ BSSGP_PDU_SUSPEND = 0x0b,
+ BSSGP_PDU_SUSPEND_ACK = 0x0c,
+ BSSGP_PDU_SUSPEND_NACK = 0x0d,
+ BSSGP_PDU_RESUME = 0x0e,
+ BSSGP_PDU_RESUME_ACK = 0x0f,
+ BSSGP_PDU_RESUME_NACK = 0x10,
+
+ BSSGP_PDU_BVC_BLOCK = 0x20,
+ BSSGP_PDU_BVC_BLOCK_ACK = 0x21,
+ BSSGP_PDU_RESET = 0x22,
+ BSSGP_PDU_RESET_ACK = 0x23,
+ BSSGP_PDU_UNBLOCK = 0x24,
+ BSSGP_PDU_UNBLOCK_ACK = 0x25,
+ BSSGP_PDU_FLOW_CONTROL_BVC = 0x26,
+ BSSGP_PDU_FLOW_CONTROL_BVC_ACK = 0x27,
+ BSSGP_PDU_FLOW_CONTROL_MS = 0x28,
+ BSSGP_PDU_FLOW_CONTROL_MS_ACK = 0x29,
+ BSSGP_PDU_FLUSH_LL = 0x2a,
+ BSSGP_PDU_FLUSH_LL_ACK = 0x2b,
+ BSSGP_PDU_LLC_DISCARDED = 0x2c,
+
+ BSSGP_PDU_LOCATION_UPDATE = 0x30,
+ BSSGP_PDU_LOCATION_UPDATE_ACK = 0x31,
+ BSSGP_PDU_LOCATION_UPDATE_NACK = 0x32,
+ BSSGP_PDU_ROUTING_AREA_UPDATE = 0x33,
+
+ BSSGP_PDU_SGSN_INVOKE_TRACE = 0x40,
+ BSSGP_PDU_STATUS = 0x42,
+ BSSGP_PDU_MAX_TYPES = 0x43
+
+} BSSGP_PDU_TYPE;
+
+
+/*
+ * The QOS levels on the
+ * network side
+ */
+typedef enum {
+
+ BSSGP_NETWORK_QOS_LEVEL_1 = 0,
+ BSSGP_NETWORK_QOS_LEVEL_2 = 1,
+ BSSGP_NETWORK_QOS_LEVEL_3 = 2,
+ BSSGP_NETWORK_QOS_LEVEL_4 = 3,
+ BSSGP_MAX_NETWORK_QOS_LEVELS = 4
+
+} BSSGP_NETWORK_QOS_LEVEL;
+
+
+/*
+ * Radio-Access-Capability-Update Cause
+ */
+typedef enum {
+
+ RA_CAP_UPD_CAUSE_IE_PRESENT = 0x00,
+ RA_CAP_UPD_CAUSE_TLLI_UNKNOWN = 0x01,
+ RA_CAP_UPD_CAUSE_NO_RA_CAP = 0x02
+
+} RA_CAP_UPD_CAUSE;
+
+
+/*
+ * Flush Action
+ */
+typedef enum {
+
+ BSSGP_LLC_PDU_DELETED = 0x00,
+ BSSGP_LLC_PDU_TRANSFERRED = 0x01
+
+} BSSGP_FLUSH_ACTION;
+
+
+
+
+
+#endif /* #ifndef BSSGP_PROT_HDR_INCLUDE */ \ No newline at end of file
diff --git a/data/mnet/Common/include/bssgp/bssgp_unitdata.h b/data/mnet/Common/include/bssgp/bssgp_unitdata.h
new file mode 100644
index 0000000..a935a61
--- /dev/null
+++ b/data/mnet/Common/include/bssgp/bssgp_unitdata.h
@@ -0,0 +1,221 @@
+/****************************************************************************************
+ * *
+ * Copyright Cisco Systems, Inc 2000 All rights reserved *
+ * *
+ * File : unitdata.h *
+ * *
+ * Description : Header file containing data structures & definitions for *
+ * handling the unitdata buffers *
+ * *
+ * Author : Dinesh Nambisan *
+ * *
+ *----------------------- Revision history ---------------------------------------------*
+ * Time | Date | Name | Description *
+ *--------------------------------------------------------------------------------------*
+ * 00:00 |10/10/00 | DSN | File created *
+ * | | | *
+ ****************************************************************************************
+ */
+
+#ifndef BSSGP_UNITDATA_HDR_INCLUDE
+#define BSSGP_UNITDATA_HDR_INCLUDE
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "bssgp_prot.h"
+#include "bssgp_util.h"
+#include "bssgp_api.h"
+
+
+
+/*
+ * Maximum number of pre-allocated buffers
+ */
+#define BSSGP_UNITDATA_MAX_BUFFERS 10240
+/*
+ * Maximum number of pre-allocated TLLI lists
+ */
+#define BSSGP_UNITDATA_MAX_TLLI_LISTS 75
+/*
+ * Its Magic !!!
+ */
+#define BSSGP_UNITDATA_MAGIC 0x2222
+
+/*
+ * The basic structure to hold information
+ * about the UNITDATA PDU. This will be in a doubly-linked
+ * list on a per-QoS-level per TLLI basis
+ */
+typedef struct _UDT_BUFFER_{
+
+ struct _UDT_BUFFER_ *prev;
+ struct _UDT_BUFFER_ *next;
+ UINT32 magic;
+ UINT32 index;
+ UINT32 data_size;
+ BSSGP_DL_UNITDATA_MSG dl_unitdata;
+ void *data; /* Whatever, placeholder, for now */
+
+} BSSGP_UDT_BUFFER,*PBSSGP_UDT_BUFFER;
+
+/*
+ * the QoS queue structure; each QoS Q will hold
+ * a doubly linked list of UDT buffers (above) for
+ * a particular QoS level. There should be 4/four of
+ * these QoS Qs per TLLI Q/List
+ */
+typedef struct {
+
+ UINT32 buff_count;
+ UINT32 rx_bytes;
+ BSSGP_NETWORK_QOS_LEVEL qos_level;
+ PBSSGP_UDT_BUFFER buff_list_head;
+ PBSSGP_UDT_BUFFER buff_list_tail;
+
+} BSSGP_UDT_QOS_Q, *PBSSGP_UDT_QOS_Q;
+
+
+/*
+ * the TLLI Q structure; a doubly-linked list which
+ * is allocated per TLLI, each of which holds four/4
+ * QoS queues of UNITDATA PDUs on the QoS level basis
+ */
+typedef struct _TLLI_Q_ {
+
+ struct _TLLI_Q_ *prev;
+ struct _TLLI_Q_ *next;
+ TLLI tlli;
+ UINT32 magic;
+ UINT32 index;
+ UINT32 buff_count;
+ UINT32 rx_bytes;
+
+ BOOL high_watermark_indicated;
+
+ BSSGP_UDT_QOS_Q qos_queues[BSSGP_MAX_NETWORK_QOS_LEVELS];
+
+
+} BSSGP_UDT_TLLI_Q,*PBSSGP_UDT_TLLI_Q;
+
+
+/*
+ * The basic structure to hold information
+ * used to implement a PDU lifetime
+ */
+typedef struct _UDT_TIMEOUT_BUFFER_{
+
+ BSSGP_UDT_BUFFER *prev;
+ BSSGP_UDT_BUFFER *next;
+ UINT32 timeoutTicks;
+ BOOL used;
+
+} BSSGP_UDT_TIMEOUT_BUFFER, *PBSSGP_UDT_TIMEOUT_BUFFER;
+
+
+
+/*
+ * Wrapper for the TLLI_Q structure to
+ * allocate/deallocate into a pool
+ */
+typedef struct {
+
+ PBSSGP_UDT_TLLI_Q entry;
+ BOOL used;
+
+} BSSGP_UDT_TLLI_POOL_ENTRY, *PBSSGP_UDT_TLLI_POOL_ENTRY;
+
+
+/*
+ * Wrapper for the UDT_BUFFER structure to
+ * allocate/deallocate into a pool
+ */
+typedef struct {
+
+ PBSSGP_UDT_BUFFER entry;
+ BOOL used;
+
+} BSSGP_UDT_BUFF_POOL_ENTRY, *PBSSGP_UDT_BUFF_POOL_ENTRY;
+
+
+
+
+typedef void (*BSSGP_UDT_WATERMARK_CB)(TLLI tlli,UINT32 rx_bytes,UINT32 rx_buffs,BOOL high);
+
+
+
+
+/*
+ * The core UNITDATA configuration structure
+ * for holding configuration information for
+ * the unitdata buffer queuing mechanisms
+ */
+typedef struct {
+ /*
+ * The num of UDT buffers to be pre-allocated
+ * and placed into the pool
+ */
+ UINT32 udt_buff_count;
+
+ /*
+ * The num of TLLI Qs/Lists to be pre-allocated
+ * and placed into the pool
+ */
+ UINT32 tlli_list_count;
+
+ UINT32 tlli_high_watermark_bytes;
+ /*
+ * indicates the num of bytes, which if
+ * exceeded, flow-control should be enabled
+ */
+
+ UINT32 tlli_low_watermark_bytes;
+ /*
+ * indicates the num of bytes, which if the list
+ * count falls below, flow-control can be
+ * disabled
+ */
+
+ PBSSGP_UDT_TLLI_Q tlli_q_head; /* head of the TLLI doubly-linked list */
+ PBSSGP_UDT_TLLI_Q tlli_q_tail; /* tail of the TLLI doubly-linked list */
+
+ /*
+ * Pools for holding TLLI Lists and UDT Buffers
+ *
+ */
+ BSSGP_UDT_TLLI_POOL_ENTRY *tlli_pool;
+
+ BSSGP_UDT_BUFF_POOL_ENTRY *udt_buff_pool;
+
+ BSSGP_UDT_TIMEOUT_BUFFER **udt_timeout_pool;
+
+ /*
+ * Callback functions to be called when the high or
+ * low watermarks are reached for a particular TLLI
+ */
+ BSSGP_UDT_WATERMARK_CB watermark_cb;
+
+} BSSGP_UNITDATA_CONFIG;
+
+
+/*
+ * Function prototypes
+ */
+BOOL bssgp_udt_initialize(int tlli_list_count,int bssgp_udt_buffer_count,BSSGP_UDT_WATERMARK_CB watermark_cb);
+BOOL bssgp_udt_put_buffer_in_q(TLLI tlli,BSSGP_NETWORK_QOS_LEVEL qos_level,UINT8 *buff, int buff_size,BSSGP_DL_UNITDATA_MSG dl_unitdata);
+UINT8 *bssgp_udt_get_buff_by_tlli(TLLI tlli,BSSGP_DL_UNITDATA_MSG*);
+UINT8 *bssgp_udt_get_buff_by_qos(BSSGP_NETWORK_QOS_LEVEL qos_level,BSSGP_DL_UNITDATA_MSG*);
+UINT8 *bssgp_udt_get_buff_by_tlli_qos(TLLI tlli, BSSGP_NETWORK_QOS_LEVEL qos_level,BSSGP_DL_UNITDATA_MSG*);
+BOOL bssgp_udt_check_buff_by_tlli(TLLI tlli, BSSGP_DL_UNITDATA_MSG **dl_unitdata);
+BOOL bssgp_udt_check_buff_by_qos(BSSGP_NETWORK_QOS_LEVEL qos_level, BSSGP_DL_UNITDATA_MSG **dl_unitdata);
+void bssgp_udt_flush_tlli(TLLI tlli);
+BOOL bssgp_udt_allocate_buff_pool();
+BOOL bssgp_udt_free_buff_pool();
+PBSSGP_UDT_BUFFER bssgp_udt_get_buff_from_pool();
+void bssgp_udt_return_buff_to_pool(PBSSGP_UDT_BUFFER bssgp_udt_buff);
+BOOL bssgp_udt_allocate_tlli_pool();
+BOOL bssgp_udt_free_tlli_pool();
+PBSSGP_UDT_TLLI_Q bssgp_udt_get_tlli_list_from_pool();
+void bssgp_udt_return_tlli_list_to_pool(PBSSGP_UDT_TLLI_Q tlli_q);
+void bssgp_udt_free_qos_list_buffs(PBSSGP_UDT_QOS_Q qos_q, UINT32 *bytes_freed, UINT32 *buffs_freed);
+
+#endif /* #ifndef BSSGP_UNITDATA_HDR_INCLUDE */ \ No newline at end of file
diff --git a/data/mnet/Common/include/bssgp/bssgp_util.h b/data/mnet/Common/include/bssgp/bssgp_util.h
new file mode 100644
index 0000000..9b80415
--- /dev/null
+++ b/data/mnet/Common/include/bssgp/bssgp_util.h
@@ -0,0 +1,97 @@
+/****************************************************************************************
+ * *
+ * Copyright Cisco Systems, Inc 2000 All rights reserved *
+ * *
+ * File : bssgp_util.h *
+ * *
+ * Description : Header file containing function prototypes of the utility *
+ * module within BSSGP layer *
+ * *
+ * Author : Dinesh Nambisan *
+ * *
+ *----------------------- Revision history ---------------------------------------------*
+ * Time | Date | Name | Description *
+ *--------------------------------------------------------------------------------------*
+ * 00:00 |10/10/00 | DSN | File created *
+ * | | | *
+ ****************************************************************************************
+ */
+
+#ifndef BSSGP_UTIL_HDR_INCLUDE
+#define BSSGP_UTIL_HDR_INCLUDE
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include "bssgp_prot.h"
+#include "bssgp_api.h"
+
+
+#if defined(MNET_GS)
+
+#define BSSGP_LAYER GS_LOG_BSSGP
+#define BSSGP_ENCODER_LAYER GS_LOG_BSSGP_ENCODER
+#define BSSGP_DECODER_LAYER GS_LOG_BSSGP_DECODER
+#define BSSGP_NET_LAYER GS_LOG_BSSGP_NET
+#define BSSGP_UNITDATA_LAYER GS_LOG_BSSGP_UNITDATA
+
+#include "logmodules.h"
+#include "vclogging.h"
+
+
+#elif defined(MNET_GP10)
+
+
+#include "logging/vcmodules.h"
+#include "logging/vclogging.h"
+
+
+#elif defined(WIN32)
+
+#include "dbgout.h"
+#include <winsock.h>
+
+#define INET_ADDR_LEN 20
+
+/* This to be defined in the driving stub */
+void bssgp_api_send_ul_unitdata(TLLI tlli,T_CNI_RIL3_IE_CELL_ID cell_id,UINT8 *pdu_data,UINT16 pdu_len);
+
+
+
+#endif
+
+#ifndef ASSERT
+#define ASSERT assert
+#endif
+
+#define bssgp_assert_on_not_implemented 1
+#define bssgp_assert_on_invalid_msg 2
+
+
+
+typedef struct {
+#if defined(MNET_GS)
+ int magic;
+#elif defined(MNET_GP10)
+ T_CNI_RIL3_IE_CELL_ID cell_id;
+ T_CNI_RIL3_IE_ROUTING_AREA_ID routing_area_id;
+#endif
+} BSSGP_CONFIGURATION;
+
+/*
+ * Function prototypes
+ */
+char *bssgp_util_get_iei_str(BSSGP_IEI_TYPE iei_type);
+char *bssgp_util_get_pdu_type_str(BSSGP_PDU_TYPE pdu_type);
+char *bssgp_util_get_api_msg_str(BSSGP_API_MSG_TYPE api_msg);
+
+char *bssgp_util_get_radio_cause_str(UINT8 radio_cause);
+char *bssgp_util_get_exception_cause_str(BSSGP_EXCEPTION_CAUSE cause);
+char *bssgp_util_get_ra_cap_cause_str(RA_CAP_UPD_CAUSE ra_cause);
+
+BOOL bssgp_util_init_rx_buffs(void);
+char *bssgp_util_get_rx_buff(int reqd_buff_size);
+void bssgp_util_return_rx_buff(char *);
+int bssgp_util_get_rx_buff_size();
+#endif /* #ifndef BSSGP_UTIL_HDR_INCLUDE */ \ No newline at end of file
diff --git a/data/mnet/Common/include/cdr/CdrSSA.h b/data/mnet/Common/include/cdr/CdrSSA.h
new file mode 100644
index 0000000..4785b67
--- /dev/null
+++ b/data/mnet/Common/include/cdr/CdrSSA.h
@@ -0,0 +1,77 @@
+// *******************************************************************
+//
+// (c) Copyright Cisco 2000
+// All Rights Reserved
+//
+// *******************************************************************
+// CdrSSA.h: interface for the CCdrSSA class.
+//
+//////////////////////////////////////////////////////////////////////
+#ifndef _CDR_SSA_H_
+#define _CDR_SSA_H_
+
+#include "cdr\include\CdrBase.h"
+
+typedef enum {
+ CDR_SS_ACTION_REGISTRATION = 0,
+ CDR_SS_ACTION_ERASURE = 1,
+ CDR_SS_ACTION_ACTIVATION = 2,
+ CDR_SS_ACTION_DEACTIVATION = 3,
+ CDR_SS_ACTION_INTERROGATION = 4,
+ CDR_SS_ACTION_INVOCATION = 5,
+ CDR_SS_ACTION_PASSWORD_REGISTRATION = 6
+} T_CDR_SS_ACTION;
+
+class CCdrSSA : public CCdrBase
+{
+private:
+ bool isInit ;
+ bool basic_service_set ;
+ unsigned char basic_service_selector ;
+ unsigned char basic_service_code ;
+ CCdrFieldE164 redirected_dn ;
+ CCdrFieldE164 translated_redirected_dn ;
+ CCdrFieldE164 transfer_dn ;
+ CCdrFieldE164 translated_transfer_dn ;
+ bool correlated_event_ref_number_set;
+ T_CDR_EVENT_REFERENCE_NUMBER correlated_event_ref_number ;
+
+public:
+ CCdrSSA ();
+ virtual ~CCdrSSA ();
+
+ virtual void initialize ();
+
+ void setTeleServiceCode (unsigned char code);
+ void setBearerServiceCode (unsigned char code);
+ void setCorrelatedEventRefNumber (T_CDR_EVENT_REFERENCE_NUMBER event_number);
+ void setRedirectedNumber (T_SUBSC_IE_ISDN * p_DN);
+ void setTranslatedRedirectedNumber(T_SUBSC_IE_ISDN * p_DN);
+ void setTransferNumber (T_SUBSC_IE_ISDN * p_DN);
+ void setTranslatedTransferNumber (T_SUBSC_IE_ISDN * p_DN);
+ void generateRecord (T_CDR_SS_ACTION ss_action,
+ unsigned char ss_code ,
+ T_CNI_RIL3_CAUSE_VALUE ss_cause);
+};
+
+
+// Sample usage of SSA record
+//
+// #include "CdrSSA.h"
+// ....
+// {
+// CCdrSSA ssa_record;
+// .....
+// ssa_record.setServedIMSI( <pointer-to-IMSI> );
+// ssa_record.setServedMSISDN( <pointer-to-MSISDN> );
+// ssa_record.setTeleServiceCode( <code> );
+// ssa_record.setCorrelatedEventRefNumber( <event-ref-number> );
+// ssa_record.setRedirectedNumber( <pointer-to-E164> );
+// ssa_record.setTranslatedRedirectedNumber( <pointer-to-E164> );
+// ssa_record.generateRecord();
+// // at this point, the record is generated, and the ssa_record can be safely discard!
+//
+// }
+
+
+#endif
diff --git a/data/mnet/Common/include/dbgfunc.h b/data/mnet/Common/include/dbgfunc.h
new file mode 100644
index 0000000..66521a5
--- /dev/null
+++ b/data/mnet/Common/include/dbgfunc.h
@@ -0,0 +1,40 @@
+#ifndef __DBGFUNC_H__
+#define __DBGFUNC_H__
+// *******************************************************************
+//
+// (c) Copyright CISCO Systems Inc. 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// File : dbgfunc.h
+// Author(s) : Igal Gutkin
+// Create Date : 8/22/01
+// Description :
+//
+// *******************************************************************
+
+#include "defs.h"
+
+extern "C"
+{
+ // print hex dump to the buffer
+ void FormatHexDump (unsigned char *pSrc, int length, char *pDest);
+ void PlainHexDump (unsigned char *pSrc, int length, char *pDest);
+
+ // stdio direct debug output
+ void dbg_print (char *format, ...);
+ void HexDump (unsigned char *pSrc, int length);
+
+ // Set debug checkpoint
+ void DbgCheckPoint (char * pFile = NULL, int line = 0);
+}
+
+#define SET_CHECKPOINT DbgCheckPoint(__FILE__,__LINE__)
+
+
+
+#endif //__DBGFUNC_H__ \ No newline at end of file
diff --git a/data/mnet/Common/include/defs.h b/data/mnet/Common/include/defs.h
new file mode 100644
index 0000000..ecf451c
--- /dev/null
+++ b/data/mnet/Common/include/defs.h
@@ -0,0 +1,127 @@
+#ifndef __DEFS_H__
+#define __DEFS_H__
+
+// *******************************************************************
+//
+// (c) Copyright CISCO Systems Inc. 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// Status : Under development
+// File : defs.h
+// Author(s) : Igal Gutkin
+// Create Date : 6/21/00
+// Description : Common defs.h to be used by APM, CDR and possibly
+// other modules or applications.
+//
+// *******************************************************************
+
+/*******************************************************************
+ typedef
+********************************************************************/
+
+// Elementary type definitions
+typedef unsigned char ubyte ;
+typedef unsigned short ubyte2;
+typedef unsigned long ubyte4;
+typedef char sbyte ;
+typedef short sbyte2;
+typedef long sbyte4;
+
+
+#ifndef min
+ #define min(a,b) (((a) < (b)) ? (a) : (b))
+#endif
+
+#ifndef MAX_PATH
+ #define MAX_PATH 260
+#endif
+
+#define SOC_STATUS_OK 0
+
+#define SOC_STATUS int
+#define RET_SOC_STATUS int
+#define ALARM_STATUS int
+
+#if defined(_WINDOWS_) || defined(WIN32)
+ #define DIR_DELIMITER '\\'
+ #define ERROR_NUM (WSAGetLastError())
+ #define SOC_STATUS_ERROR SOCKET_ERROR
+ #define OS_SPECIFIC_SOCKET_HANDLE SOCKET
+
+#else
+ #define DIR_DELIMITER '/'
+ #define ERROR_NUM errno
+ #define SOC_STATUS_ERROR (-1)
+ typedef ubyte4 OS_SPECIFIC_SOCKET_HANDLE;
+ typedef ubyte4 OS_SPECIFIC_DGRAM_HANDLE;
+
+#endif // WINDOWS
+
+
+// Windows definitions
+#if !defined (_WINDOWS_) && !defined (WIN32)
+ #define INVALID_SOCKET (OS_SPECIFIC_SOCKET_HANDLE)(~0)
+
+ // manifest constants for shutdown()
+ #define SD_RECEIVE 0x00
+ #define SD_SEND 0x01
+ #define SD_BOTH 0x02
+
+ // Windows redirected socket error codes
+ #define WSAEMSGSIZE EMSGSIZE
+ #define WSAENOBUFS ENOBUFS
+ #define WSAEMSGSIZE EMSGSIZE
+ #define WINAPI
+ #define FAR
+
+ // Windows data types
+ typedef char *LPSTR , *PSTR;
+ typedef char *DWORD ;
+ typedef const char *LPCSTR;
+
+#endif
+
+
+#if defined (_WINDOWS_) || defined (WIN32)
+ #define SysCloseSocket(x) closesocket(x)
+#else
+ #define SysCloseSocket(x) close(x)
+#endif
+
+
+// Internet address conversion
+#define BYTE_1(a) (((a)>>24)&0xFF)
+#define BYTE_2(a) (((a)>>16)&0xFF)
+#define BYTE_3(a) (((a)>>8)&0xFF)
+#define BYTE_4(a) ((a)&0xFF)
+
+#if defined CPU_FAMILY && (CPU_FAMILY==PPC)
+ // PowerPC on VxWorks
+ #define IP_BYTES(ip) BYTE_1(ip),BYTE_2(ip),BYTE_3(ip),BYTE_4(ip)
+#else
+ // Wintel platform
+ #define IP_BYTES(ip) BYTE_4(ip),BYTE_3(ip),BYTE_2(ip),BYTE_1(ip)
+#endif
+
+
+// Socket error codes
+#define SOCKET_STATUS_OK SOC_STATUS_OK
+#define SOCKET_STATUS_MSG_TOO_LONG 1
+#define SOCKET_STATUS_TEMP_SOC_ERR 2
+#define SOCKET_STATUS_FATAL_SOC_ERR SOC_STATUS_ERROR
+
+// Default root directory
+#if defined (MNET_GP10)
+ #define DEF_ROOT_DIR "/ata/vipercall";
+#elif defined (MNET_GMC)
+ #define DEF_ROOT_DIR "/sd0/gmc";
+#else
+ #define DEF_ROOT_DIR ".";
+#endif
+
+#endif /* __DEFS_H__ */ \ No newline at end of file
diff --git a/data/mnet/Common/include/gglink/gglink_api.h b/data/mnet/Common/include/gglink/gglink_api.h
new file mode 100644
index 0000000..c7f8074
--- /dev/null
+++ b/data/mnet/Common/include/gglink/gglink_api.h
@@ -0,0 +1,336 @@
+/*
+ ****************************************************************************************
+ * *
+ * Copyright Cisco Systems, Inc 2000 All rights reserved *
+ * *
+ * File : gglink_api.h *
+ * *
+ * Description : API data structures for the SGSN-GMC layer module *
+ * *
+ * Author : Dinesh Nambisan *
+ * *
+ *----------------------- Revision history ---------------------------------------------*
+ * Time | Date | Name | Description *
+ *--------------------------------------------------------------------------------------*
+ * 00:00 |12/14/00 | DSN | File created *
+ * | | | *
+ ****************************************************************************************
+ */
+#ifndef _GGLINK_API_HDR_INC_
+#define _GGLINK_API_HDR_INC_
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "subsc/SubscInfoType.h"
+#include "subsc/SubscGPRSInfoType.h"
+
+/*
+ * RIL3 (4.08) includes
+ */
+#include "ril3/ie_tlli.h"
+#include "ril3/ie_mobile_id.h"
+#include "ril3/ie_location_area_id.h"
+#include "ril3/ie_qos_profile.h"
+#include "ril3/ril3_gmm_msg.h"
+#include "ril3/ie_reject_cause.h"
+#include "ril3/ie_cell_id.h"
+
+#define GGLINK_API_MAGIC_VALUE 1111
+
+#define MAX_GSN_ADDR_LENGTH 16
+
+/*
+ * GGLINK API message type
+ */
+typedef enum {
+
+ GGLINK_API_MSG_GS_SRQ, /* GS -> GMC */
+ GGLINK_API_MSG_GS_SRS, /* GMC -> GS */
+ GGLINK_API_MSG_GS_RRQ, /* GS -> GMC */
+ GGLINK_API_MSG_GS_RCF, /* GMC -> GS */
+ GGLINK_API_MSG_GS_RRJ, /* GMC -> GS */
+ GGLINK_API_MSG_GS_PRQ, /* GS -> GMC */
+ GGLINK_API_MSG_GS_PRS, /* GMC -> GS */
+ GGLINK_API_MSG_GS_URQ, /* GMC -> GS */
+ GGLINK_API_MSG_SRI_REQ, /* GS -> GMC , send routing info*/
+ GGLINK_API_MSG_SRI_ACK, /* GMC -> GS , send routing info*/
+ GGLINK_API_MSG_FR, /* GS -> GMC , failure report */
+ GGLINK_API_MSG_FR_ACK, /* GMC -> GS , failure report Ack*/
+ GGLINK_API_MSG_GPRS_PRE, /* GMC -> GS , Note MS GPRS Present */
+ GGLINK_API_MSG_GPRS_PRE_ACK, /* GS -> GMC , Note MS GPRS Present Ack*/
+ GGLINK_API_MSG_SSRI_REQ, /* GS -> GMC , Send SGSN Routing Info Request */
+ GGLINK_API_MSG_SSRI_RSP, /* GMC -> GS , Send SGSN Routing Info Response */
+ GGLINK_API_MSG_ECHO_REQ, /* GS -> GMC */
+ GGLINK_API_MSG_ECHO_RSP, /* GMC -> GS */
+ GGLINK_API_MAX_MSGS
+
+} GGLINK_API_MSG_TYPE;
+
+
+#define GGLINK_CAUSE_REQ_ACCEPTED 0
+#define GGLINK_CAUSE_NO_RESOURCES_AVAIL 1
+#define GGLINK_CAUSE_SERVICE_NOT_SUPPORTED 2
+#define GGLINK_CAUSE_SYSTEM_FAILURE 3
+#define GGLINK_CAUSE_UNKNOWN_ROUTING_AREA 4
+
+
+/*
+ *
+ */
+typedef struct {
+ bool ie_present;
+ unsigned char cause_code;
+} GGLINK_IE_CAUSE;
+
+/*
+ *
+ */
+typedef struct {
+ bool ie_present;
+ unsigned char map_error_code;
+} GGLINK_IE_MAP_CAUSE;
+
+
+/*
+ *
+ */
+typedef struct {
+ bool ie_present;
+ short gsn_addr_length; // will we have an IE for GTP interface?
+ unsigned char addr_octets[MAX_GSN_ADDR_LENGTH];
+} GGLINK_IE_GSN_ADDRESS;
+
+
+/*
+ * GGLINK_GS_SRQ_MSG
+ */
+
+typedef struct {
+ T_CNI_RIL3_IE_MOBILE_ID imsi;
+} GGLINK_GS_SRQ_MSG;
+
+/*
+ * GGLINK_GS_SRS_MSG
+ */
+
+typedef struct {
+ T_CNI_RIL3_IE_MOBILE_ID imsi;
+ T_SEC_IE_AUTH_LIST triplet_list;
+} GGLINK_GS_SRS_MSG;
+
+/*
+ * GGLINK_GS_RRQ_MSG
+ */
+
+typedef struct {
+ T_CNI_RIL3_IE_MOBILE_ID imsi;
+ T_CNI_RIL3_IE_ROUTING_AREA_ID rai;
+ // SGSN number
+ // SGSN address
+} GGLINK_GS_RRQ_MSG;
+
+/*
+ * GGLINK_GS_RCF_MSG
+ */
+
+typedef struct {
+ T_CNI_RIL3_IE_MOBILE_ID imsi;
+} GGLINK_GS_RCF_MSG;
+
+/*
+ * GGLINK_GS_RRJ_MSG
+ */
+
+typedef struct {
+ T_CNI_RIL3_IE_MOBILE_ID imsi;
+ T_CNI_RIL3_REJECT_CAUSE_VALUE cause;
+} GGLINK_GS_RRJ_MSG;
+
+/*
+ * GGLINK_GS_PRQ_MSG
+ */
+
+typedef struct {
+ T_CNI_RIL3_IE_MOBILE_ID imsi;
+
+} GGLINK_GS_PRQ_MSG;
+
+/*
+ * GGLINK_GS_PRS_MSG
+ */
+
+typedef struct {
+ T_CNI_RIL3_IE_MOBILE_ID imsi;
+ short data_size;
+ char data[1024];
+} GGLINK_GS_PRS_MSG;
+
+/*
+ * GGLINK_GS_URQ_MSG
+ */
+
+typedef struct {
+ T_CNI_RIL3_IE_MOBILE_ID imsi;
+
+} GGLINK_GS_URQ_MSG;
+
+/*
+ * GGLINK_SRI_REQ_MSG
+ */
+
+typedef struct {
+ // send routing info
+ short gsn_seqno;
+ T_CNI_RIL3_IE_MOBILE_ID imsi;
+ GGLINK_IE_GSN_ADDRESS ggsn_addr;
+} GGLINK_SRI_REQ_MSG;
+
+/*
+ * GGLINK_SRI_ACK_MSG
+ */
+
+typedef struct {
+ // send routing info ack
+ short gsn_seqno;
+ T_CNI_RIL3_IE_MOBILE_ID imsi;
+ GGLINK_IE_CAUSE cause;
+ GGLINK_IE_MAP_CAUSE map_cause;
+ GGLINK_IE_GSN_ADDRESS sgsn_addr;
+ GGLINK_IE_GSN_ADDRESS ggsn_addr;
+} GGLINK_SRI_ACK_MSG;
+
+/*
+ * GGLINK_FR_MSG
+ */
+
+typedef struct {
+ // failure report
+ short gsn_seqno;
+ T_CNI_RIL3_IE_MOBILE_ID imsi;
+} GGLINK_FR_MSG;
+
+/*
+ * GGLINK_FR_ACK_MSG
+ */
+
+typedef struct {
+ // failure report ack
+ short gsn_seqno;
+ T_CNI_RIL3_IE_MOBILE_ID imsi;
+ GGLINK_IE_CAUSE cause;
+ GGLINK_IE_MAP_CAUSE map_cause;
+} GGLINK_FR_ACK_MSG;
+
+/*
+ * GGLINK_MS_GPRS_PRE_MSG
+ */
+
+typedef struct {
+ // Note MS GPRS PRESENT
+ T_CNI_RIL3_IE_MOBILE_ID imsi;
+ GGLINK_IE_GSN_ADDRESS gsn_addr;
+} GGLINK_MS_GPRS_PRE_MSG;
+
+/*
+ * GGLINK_MS_GPRS_PRE_ACK_MSG
+ */
+
+typedef struct {
+ // Note MS GPRS PRESENT ack
+ T_CNI_RIL3_IE_MOBILE_ID imsi;
+ GGLINK_IE_GSN_ADDRESS gsn_addr;
+ GGLINK_IE_CAUSE cause;
+} GGLINK_MS_GPRS_PRE_ACK_MSG;
+
+
+/*
+ * Send SGSN Routing Info Request
+ */
+
+typedef struct {
+ // send sgsn routing info
+ short gsn_seqno;
+ T_CNI_RIL3_IE_ROUTING_AREA_ID rai;
+} GGLINK_SSRI_REQ_MSG;
+
+
+/*
+ * Send SGSN Routing Info Response
+ */
+
+typedef struct {
+ // send sgsn routing info response
+ short gsn_seqno;
+ GGLINK_IE_CAUSE cause;
+ T_CNI_RIL3_IE_ROUTING_AREA_ID rai;
+ GGLINK_IE_GSN_ADDRESS sgsn_addr;
+} GGLINK_SSRI_RSP_MSG;
+
+/*
+ * The main API msg; which is overloaded with
+ * all the individual msgs
+ */
+typedef struct {
+
+ GGLINK_API_MSG_TYPE msg_type;
+ int magic;
+ union {
+ GGLINK_GS_SRQ_MSG security_req;
+ GGLINK_GS_SRS_MSG security_rsp;
+ GGLINK_GS_RRQ_MSG ra_update_req;
+ GGLINK_GS_RCF_MSG ra_update_cnf;
+ GGLINK_GS_RRJ_MSG ra_update_rej;
+ GGLINK_GS_PRQ_MSG profile_req;
+ GGLINK_GS_PRS_MSG profile_rsp;
+ GGLINK_GS_URQ_MSG unregister_req;
+
+ // for location management
+ GGLINK_SRI_REQ_MSG send_routing_info_req;
+ GGLINK_SRI_ACK_MSG send_routing_info_ack;
+ GGLINK_FR_MSG fr_req;
+ GGLINK_FR_ACK_MSG fr_ack;
+ GGLINK_MS_GPRS_PRE_MSG ms_gprs_pre_req;
+ GGLINK_MS_GPRS_PRE_ACK_MSG ms_gprs_pre_ack;
+
+ // for SGSN-SGSN routing Area information
+ GGLINK_SSRI_REQ_MSG ssri_req;
+ GGLINK_SSRI_RSP_MSG ssri_rsp;
+ } msg;
+
+} GGLINK_API_MSG;
+
+
+
+BOOL DecodeGGLinkMessage(
+ int &maxlength, // max length of input buffer
+ unsigned char * &ptr, // starting address of input buffer
+ GGLINK_API_MSG &msg // output msg data structure
+ );
+BOOL EncodeGGLinkMessage(
+ int &maxlength, // max length of output buffer
+ unsigned char * &ptr, // starting address of output buffer
+ GGLINK_API_MSG &msg // input msg data structure
+ );
+/*
+ * API function prototypes
+ */
+
+/*
+ * This function below will be called by :-
+ * On GMC : MAP interface layers
+ * On GS : GMM2
+ */
+BOOL gglink_api_send_msg(GGLINK_API_MSG &msg);
+
+/*
+ * Callback function provided by :
+ * MAP IF on GMC
+ * GMM2 on GS
+ */
+BOOL gglink_msg_callback(GGLINK_API_MSG msg);
+BOOL gglink_gsn_msg_callback(GGLINK_API_MSG &msg);
+
+
+
+#endif /* #ifndef _GGLINK_API_HDR_INC_ */
diff --git a/data/mnet/Common/include/gplink/gplink_prot.h b/data/mnet/Common/include/gplink/gplink_prot.h
new file mode 100644
index 0000000..a313262
--- /dev/null
+++ b/data/mnet/Common/include/gplink/gplink_prot.h
@@ -0,0 +1,62 @@
+/*
+ ****************************************************************************************
+ * *
+ * Copyright Cisco Systems, Inc 2000 All rights reserved *
+ * *
+ * File : gplink_prot.h *
+ * *
+ * Description : Definitions for the GPLink Protocol *
+ * *
+ * Author : Dinesh Nambisan *
+ * *
+ *----------------------- Revision history ---------------------------------------------*
+ * Time | Date | Name | Description *
+ *--------------------------------------------------------------------------------------*
+ * 00:00 |01/25/01 | DSN | File created *
+ * | | | *
+ ****************************************************************************************
+ */
+#ifndef GPLINK_PROT_HDR_INCLUDE
+#define GPLINK_PROT_HDR_INCLUDE
+
+
+#define GPLINK_TCP_PORT 52172
+
+
+typedef enum {
+
+ GPLINK_MSG_TYPE_REG_REQ = 1,
+ GPLINK_MSG_TYPE_REG_CNF = 2,
+ GPLINK_MSG_TYPE_REG_REJ = 3,
+ GPLINK_MSG_TYPE_REG_UPDATE_REQ = 4,
+ GPLINK_MSG_MAX_TYPES = 5
+
+} GPLINK_PROTOCOL_MSG_TYPE;
+
+typedef enum {
+
+ GPLINK_IE_CELL_ID = 1,
+ GPLINK_IE_LOCATION_AREA_ID = 2,
+ GPLINK_IE_ROUTING_AREA_ID = 3,
+ GPLINK_IE_CAUSE = 4,
+ GPLINK_MAX_IE_TYPES = 5
+
+} GPLINK_IE_TYPE;
+
+
+typedef enum {
+
+ GPLINK_EVENT_CELL_CONNECTED = 0,
+ GPLINK_EVENT_CELL_DISCONNECTED = 1,
+ GPLINK_EVENT_CELL_INFO_UPDATE = 2,
+ GPLINK_MAX_EVENTS = 3
+
+} GPLINK_EVENT;
+
+
+typedef enum {
+ GPLINK_GS_CAPACITY_EXCEEDED = 0
+} GPLINK_REJECT_CAUSE;
+
+
+#endif /* #ifndef GPLINK_PROT_HDR_INCLUDE */ \ No newline at end of file
diff --git a/data/mnet/Common/include/gprsdefs.h b/data/mnet/Common/include/gprsdefs.h
new file mode 100644
index 0000000..13c44c2
--- /dev/null
+++ b/data/mnet/Common/include/gprsdefs.h
@@ -0,0 +1,34 @@
+#ifndef __GPRSDEFS_H__
+#define __GPRSDEFS_H__
+/*********************************************************************
+//
+// (c) Copyright CISCO Systems, Inc 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// Status : Under development
+// File : gprsefs.h
+// Author(s) : Igal Gutkin
+// Create Date : 10/31/00
+// Description : Shared definitions for GPRS modules
+//
+// Notes : IMPORTANT - DO NOT use C++ style comments "//" in this file
+//
+// *******************************************************************/
+
+
+#define MAX_L3_PDU_LENGTH (1520) /* max byte size in a L3 GPRS PDU */
+#define MAX_LLC_OVERHEAD_LENGTH (36) /* max byte size for LLC frame overhead */
+
+/* max bytes in a DL GPRS PDU */
+#define MAX_DL_PDU_LENGTH (MAX_L3_PDU_LENGTH+MAX_LLC_OVERHEAD_LENGTH)
+
+#define TLLI_UNASSIGN_VALUE (0xFFFFFFFF)
+
+typedef UINT32 TLLI_t;
+
+#endif /* __GPRSDEFS_H__ */ \ No newline at end of file
diff --git a/data/mnet/Common/include/oam_api.h b/data/mnet/Common/include/oam_api.h
new file mode 100644
index 0000000..766cf9c
--- /dev/null
+++ b/data/mnet/Common/include/oam_api.h
@@ -0,0 +1,323 @@
+/*********************************************************************/
+/* */
+/* (c) Copyright Cisco 2000 */
+/* All Rights Reserved */
+/* */
+/*********************************************************************/
+
+/*********************************************************************/
+/* */
+/* Version : 1.0 */
+/* Status : Under development */
+/* File : oam_api.h */
+/* Author(s) : Bhawani Sapkota */
+/* Create Date : 07/11/99 */
+/* Description : This file contains Oam Api prototypes */
+/* */
+/*********************************************************************/
+/* REVISION HISTORY */
+/*___________________________________________________________________*/
+/*----------+--------+-----------------------------------------------*/
+/* Name | Date | Reason */
+/*----------+--------+-----------------------------------------------*/
+/* Bhawani |09/28/00| Initial Draft */
+/* Bhawani |11/20/00| resturctured to share among GP, GMS and GS */
+/*----------+--------+-----------------------------------------------*/
+/*********************************************************************/
+
+#ifndef OAM_API_H
+#define OAM_API_H
+
+/******************************************************************
+ ** Include Files.
+ ******************************************************************/
+
+#include <msgqLib.h>
+#include "MnetModuleId.h"
+#include "MibTags.h"
+#include "oam_trap.h"
+#include "asn1conf.h"
+
+
+#ifndef True
+#define True 1
+#endif
+
+#ifndef False
+#define False 0
+#endif
+
+
+/******************************************************************
+ ** Trap Message Format
+ ******************************************************************/
+
+typedef enum MsgType {
+ MT_TRAP = 0, /* Currently only TRAP is used */
+ MT_REQUEST,
+ MT_REPLY,
+ MT_ACK,
+ MT_NOTIFICATION
+}MsgType;
+
+
+typedef enum ValueType{
+ VT_VALUE = 0, /* an ordinary integer value */
+ VT_ADDRESS, /* an address, in case of structure, byte array and table */
+ VT_TABLE /* an individual item of a table */
+}ValueType;
+
+
+
+/* This structure holds the value and index number of
+ * a table field.
+ */
+
+typedef struct TblField_t
+{
+ OCTET_T idx;
+ INT_32_T value;
+}TableField;
+
+
+/* The following structure used to send trap from agent to an
+ * application. If the MIB tag being trapped is a non-scalar, the
+ * application should use get API to retrieve the structure
+ * or array. See below
+ */
+
+typedef struct ipc_msg_t
+{
+ OCTET_T srcModuleId; /* source module ID (SNMP_AGENT_ID) */
+ OCTET_T msgType; /* message type (MT_TRAP) */
+ MibTag mibTag; /* mib tag */
+ OCTET_T valType; /* value or address */
+ union {
+ INT_32_T varVal; /* actual value */
+ void * varAdr; /* address of the table or array */
+ TableField varTbl; /* table field */
+ }val;
+}TrapMsg;
+
+
+/******************************************************************
+ ** API used to revirve MIB variables
+ ******************************************************************/
+/* The actual value MODULE_OAM is defined in jcc/include/sys_const.h
+ * file and its current value is 7
+ */
+#define STATUS_OK 0x00
+#define STATUS_INVALID_TAG -1
+#define STATUS_INVALID_PARAMS -2
+#define STATUS_NO_MEMORY -3
+#define STATUS_NOT_FOUND -4
+#define STATUS_MSGQ_SEND_ERROR -5
+#define STATUS_NOK -6
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/******************************************************************
+ ** API used to retrive MIB variable address
+ ******************************************************************/
+
+/*
+ * gets address of a single MIB tag. Index is optional
+ * parameter if the tag is table entry of filed.
+ */
+
+void *oam_getMibAddress(MibTag tag, ...);
+
+/* get address of scalar mib variable */
+STATUS oam_getMibVarAdr(MibTag varTag, void ** mibVarAdr);
+
+/******************************************************************
+ ** API used to retrive MIB variable address
+ ******************************************************************/
+
+/* gets value of a single MIB tag. The variable is a simple 4-byte integer */
+STATUS oam_getMibIntVar(MibTag varTag, INT_32_T *varPtr);
+
+/* get value of MIB variable array. Number of elements to be
+ * retrieved depends on the aryCount. It is also assumed that
+ * the application has allocated enough memory to hold aryCount
+ * elements at aryPtr.
+ */
+
+
+STATUS oam_getMibByteAry(MibTag aryTag, OCTET_T *byteAryPtr, INT_32_T byteCount);
+
+/* get the entire structure.
+ */
+STATUS oam_getMibStruct(MibTag structTag, OCTET_T * structPtr, int structSize);
+
+/* get value of a MIB table. Application allocates enough space to hold entryCount
+ * elements at tblPtr.
+ */
+
+/******************************************************************
+ ** API used to manupulate MIB tables
+ ******************************************************************/
+
+/* returns size,in bytes, of the table entry.
+ * returns -1 if the tag is invalid
+ */
+int oam_getMibTblEntSz(MibTag tblTag);
+
+/* returns number of current entries in the table.
+ * returns -1 if the tag is invalid
+ */
+int oam_getMibTblEntCount(MibTag tblTag);
+
+/* retrieves entire table into the memory supplied */
+STATUS oam_getMibTbl(MibTag tblTag, void *tblBuf, int bufSize);
+
+/* retrieves an entry of the table into the memory supplied */
+
+STATUS oam_getMibTblEntry(MibTag tblTag, int idx, void *buffer, int bufSize);
+
+/* get the address of an entry */
+void *oam_getMibTblEntAdr(MibTag tblTag, int idx, int *entrySize);
+
+/* get the address of an number and IP address type entry */
+STATUS oam_getMibTblNumberField(MibTag colTag, int idx, INT_32_T *value);
+
+
+/* get the address of an string type entry */
+STATUS oam_getMibTblStringField(MibTag tblStrTag, int idx, OCTET_T *buffer, INT_32_T size);
+
+#ifdef MNET_GP10
+
+/* convert int to three digit mnc */
+STATUS oam_getMncFromInt(int nMnc, UINT8 *pszMnc);
+
+/* returns 3 bytes of MNC as an arrary */
+STATUS oam_getMnc(UINT8 *pszMnc);
+
+#endif /* MNET_GP10 */
+
+
+#ifdef MNET_GMC
+
+/* add new msrn value into next available slot in msrn table */
+STATUS msrn_addTblEntry(char *msrnValue);
+
+/* delete msrn entry from msrn table and mark slot as empty */
+STATUS msrn_delTblEntry(char *msrnValue);
+
+/* return next msrn value in table; NULL if end of table is reached */
+char *msrn_getNextEntry(int *counter);
+
+/* get MNC and fill into the specified byte array { array size must be 3 bytes } */
+STATUS oam_getMnc(UINT8 *pszMnc);
+
+/* get MCC and fill into the specified byte array { array size must be 3 bytes } */
+STATUS oam_getMcc(UINT8 *pszMcc);
+
+/* get MNC and fill into the specified byte array { array size must be 3 bytes } */
+STATUS oam_getAdjacentLocationAreaMNC(UINT8 *pszMnc, int idx);
+
+/* get MCC and fill into the specified byte array { array size must be 3 bytes } */
+STATUS oam_getAdjacentLocationAreaMCC(UINT8 *pszMcc, int idx);
+
+
+#endif /* MNET_GMC */
+
+
+#ifdef MNET_GS
+
+/*
+This API expects pszAPN parameter in ASCII null terminated
+string format (Ex: "gprs.cisco.com"). Stores IP Address
+in pIpAddr if operation is successful. Return value
+indicates the status of the operation.
+
+This API first looks-up in the local table. If the lookup fails
+and the DNS server is configured then performs DNS lookup.
+
+Note that a call to this routine may be blocked
+for long time (up to 10 seconds or more if the DNS server
+is not responding). Caller should be prepared for such
+long delays.
+*/
+STATUS oam_getGgsnIpAddress(char *pszAPN, UINT32 *pIpAddr);
+
+/*
+Returns name of the default APN. Willl return NULL if
+no default APN name is configured by the user. Return value
+is null terminated. Format for the return value is ASCII
+(Ex: "gprs.cisco.com")
+*/
+char * oam_getDefaultAPN();
+
+#endif /* MNET_GS */
+/******************************************************************
+ ** API used to set MIB variables.
+ ******************************************************************/
+
+
+/* The same set of API are used to set MIB variables by both agent
+ * and application modules. Source Module ID is passed so that the
+ * implementation knows the direction of message flow.
+ */
+
+/* sets a single mib variable. The variable is a */
+STATUS oam_setMibIntVar(OCTET_T srcModuleId, MibTag varTag, INT_32_T varVal);
+
+/* sets aryCount elements of an array specified by aryTag */
+STATUS oam_setMibByteAry(OCTET_T srcModuleId, MibTag aryTag, OCTET_T *ByteAryPtr, INT_32_T byteCount);
+
+/* sets an entry of a Table, an entry is actually is row of MIB table */
+STATUS oam_setMibTblEntry(OCTET_T srcModuleId, MibTag tblTag, int idx, void *tblEntBuf, int bufSize);
+
+/* sets a field of the given entry table */
+STATUS oam_setTblEntryField(OCTET_T srcModuleId, MibTag tblTag, int entNo, INT_32_T varVal);
+
+
+/******************************************************************
+ ** API used to subscribe and unsubscribe trap
+ ******************************************************************/
+
+/*
+ * Applications interested in receiving notification
+ * when the value of certain managed MIB object get changed can do so
+ * by calling following APIs.
+ */
+
+
+/* setting trap on a single MIB variable */
+STATUS oam_setTrap (OCTET_T srcModuleId, MSG_Q_ID msgQid, MibTag mibTag);
+STATUS setTrap (OCTET_T srcModuleId, MSG_Q_ID msgQid, MibTag mibTag);
+
+
+/* setting trap on a multiple MIB variables */
+STATUS oam_setMultipleTrap (OCTET_T srcModuleId, MSG_Q_ID msgQid, MibTag mibTag[], INT_32_T tagCount);
+
+/* unsetting trap on a MIB variable */
+STATUS oam_unsetTrap(OCTET_T srcModuleId, MibTag mibTag);
+
+/* unsetting trap for all the variable for the module */
+STATUS oam_unsetTrapByModule(OCTET_T srcModuleId);
+
+/******************************************************************
+ ** Misc Library
+ ******************************************************************/
+
+STATUS oam_getByteAryByInt(INT_32_T intVal, char * byteAry, int size);
+STATUS oam_processTrap(OCTET_T srcMdlId, MibTag tag, OCTET_T valueType, INT_32_T newValue, int idx);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+/* to support older interfaces */
+#define getMibIntVar oam_getMibIntVar
+#define getMibStruct oam_getMibStruct
+#define getMibTbl oam_getMibTbl
+#define getByteAryByInt oam_getByteAryByInt
+
+
+#endif /* OAM_API_H */
diff --git a/data/mnet/Common/include/oam_trap.h b/data/mnet/Common/include/oam_trap.h
new file mode 100644
index 0000000..35e2b1e
--- /dev/null
+++ b/data/mnet/Common/include/oam_trap.h
@@ -0,0 +1,93 @@
+/*********************************************************
+*
+* (c) Copyright Cisco 2000
+* All Rights Reserved
+*
+**********************************************************/
+
+#if (!defined(OAM_TRAP_H))
+#define OAM_TRAP_H
+
+/******************************************************************
+ ** Include Files.
+ ******************************************************************/
+
+#include <stdio.h>
+#include <msgQLib.h>
+#include <semLib.h>
+#include <snmp/asn1conf.h>
+#include "mibtags.h"
+#include "oam_api.h"
+#include "vipermib.h"
+#include "vipertbl.h"
+
+typedef struct ListNode_t
+{
+ struct ListNode_t * next;
+ MibTag tag;
+ MSG_Q_ID qid; /* typedef msg_q * MSG_Q_ID */
+ OCTET_T mid; /* module id of the subscriber */
+}ListNode, *ListNodePtr;
+
+
+typedef struct ListHead_t
+{
+ ListNodePtr first; /* first element of the list */
+ ListNodePtr last; /* last valid element of the list */
+ int nodeCount; /* No of items */
+}ListHead, *ListHeadPtr;
+
+typedef struct MibInitIntTable_T
+{
+ MibTag tag;
+ INT_32_T value;
+}MibInitIntTable;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ListNodePtr oam_newListNode(MibTag tag, MSG_Q_ID id);
+STATUS oam_insertNode(ListHeadPtr head, ListNodePtr aNode);
+STATUS oam_insertNodeSortedByTag(ListHeadPtr head, ListNodePtr aNode);
+STATUS oam_appendNode(ListHeadPtr head, ListNodePtr aNode);
+ListNodePtr oam_getNodeByID(ListHeadPtr head, MSG_Q_ID id);
+ListNodePtr oam_getFirstNodeByTag(ListHeadPtr head, INT_32_T tag);
+STATUS oam_deleteNode(ListHeadPtr head, MibTag tag, OCTET_T mid);
+STATUS oam_deleteNodeByModule(ListHeadPtr head, OCTET_T mid);
+STATUS oam_deleteNodeByQ(ListHeadPtr head, MSG_Q_ID qid);
+void oam_printList(ListHeadPtr head);
+void oam_oamError( char * formatString, ...);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+/* function in api_init.cpp */
+STATUS oam_initApi(int debugLevel);
+ListHeadPtr oam_getTrapTableHead();
+ListHeadPtr oam_newListHead();
+
+/* function in mib_init.cpp */
+STATUS oam_initializeMib();
+
+void oam_lockMutex();
+void oam_unlockMutex();
+
+/* debugging and printing */
+void oam_msgPrint(char *format, ...) ;
+
+#define LOG_ERROR(XX); \
+ printf("OAM API ERROR at %s:", fname); \
+ oam_msgPrint XX;
+
+#ifdef _DEBUG
+#define LOG_TRACE(XX); \
+ printf("OAM API Trace at %s:", fname); \
+ oam_msgPrint XX;
+#else
+#define LOG_TRACE(XX);
+#endif
+
+#endif
diff --git a/data/mnet/Common/include/socket/GenClientSocket.h b/data/mnet/Common/include/socket/GenClientSocket.h
new file mode 100644
index 0000000..44eaec8
--- /dev/null
+++ b/data/mnet/Common/include/socket/GenClientSocket.h
@@ -0,0 +1,79 @@
+#ifndef __GENCLIENTSOCKET_H__
+#define __GENCLIENTSOCKET_H__
+
+// *******************************************************************
+//
+// (c) Copyright CISCO Systems, Inc 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// Status : Under development
+// File : GenClientSocket.h
+// Author(s) : Igal Gutkin
+// Create Date : 06/20/00
+// Description : interface for the GenClientSocket class.
+//
+// *******************************************************************
+
+#include "GenSocketSSL.h"
+
+
+class GenClientSocket : public GenSocketSSL
+{
+
+public:
+ GenClientSocket ();
+ GenClientSocket (int sndSize, int rcvSize);
+
+ // allow SSL settings
+ GenClientSocket (bool bEnableSSL, bool bEnableEncryption = true);
+ GenClientSocket (int sndSize , int rcvSize ,
+ bool bEnableSSL, bool bEnableEncryption = true);
+
+ virtual
+ ~GenClientSocket () {;}
+
+ virtual
+ int serve (const fd_set *set, GenSocket *& soc)
+ { return (GenSocket::serve(set, soc)) ; }
+
+ void setLinger (linger& val) { lingerVal_ = val ; setLinger_ = true; }
+ bool connectServer (ubyte4 ipAddr, ubyte2 tcpPort);
+ bool reconnect ();
+
+ virtual void printInfo ();
+
+ static bool initSslContext (LPSTR lpPswd = NULL);
+ static void cleanSslContext() { GenSocketSSL::cleanSslContext(pCtx_); }
+
+protected:
+
+ virtual bool create ();
+ virtual bool isContext ();
+ virtual SSL_CTX *getContext();
+
+ void reset ();
+
+private:
+
+// Data members
+protected:
+
+ static SSL_CTX * pCtx_; // SSL context (one per all clients on the host)
+
+ int rcvBuffLen_,
+ sndBuffLen_;
+ linger lingerVal_ ;
+ bool setLinger_ ;
+
+ ubyte4 srvAddr_ ;
+ ubyte2 srvPort_ ;
+
+};
+
+
+#endif //__GENCLIENTSOCKET_H__ \ No newline at end of file
diff --git a/data/mnet/Common/include/socket/GenSecServerSocket.h b/data/mnet/Common/include/socket/GenSecServerSocket.h
new file mode 100644
index 0000000..7225424
--- /dev/null
+++ b/data/mnet/Common/include/socket/GenSecServerSocket.h
@@ -0,0 +1,59 @@
+#ifndef __GENSECSERVERSOCKET_H__
+#define __GENSECSERVERSOCKET_H__
+
+// *******************************************************************
+//
+// (c) Copyright CISCO Systems, Inc 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// Status : Under development
+// File : GenSecServerSocket.h
+// Author(s) : Igal Gutkin
+// Create Date : 06/20/00
+// Description : interface for the GenSecServerSocket (Secondary Server)
+// class
+//
+// *******************************************************************
+
+#include "socket\GenServerSocket.h"
+
+#ifndef SOC_RCV_BUFF_LEN
+ #define SOC_RCV_BUFF_LEN (0x2000)
+#endif
+
+#ifndef SOC_SND_BUFF_LEN
+ #define SOC_SND_BUFF_LEN (0x500)
+#endif
+
+class GenSecServerSocket : public GenServerSocket
+{
+public:
+// Constructors
+ GenSecServerSocket () : GenServerSocket () { ; }
+
+ GenSecServerSocket (OS_SPECIFIC_SOCKET_HANDLE socket);
+
+ // the following constructor contains a blocking SSL API call,
+ // when invoked with enableSSL = true
+ GenSecServerSocket (OS_SPECIFIC_SOCKET_HANDLE socket, bool enableSSL,
+ bool enableEncryption = true );
+// Destractor
+ virtual
+ ~GenSecServerSocket ();
+
+// Primary methods
+ virtual
+ int serve (const fd_set *, GenSocket *&) { return (false); }
+
+private:
+
+ void reset (OS_SPECIFIC_SOCKET_HANDLE socket);
+};
+
+
+#endif //__GENSECSERVERSOCKET_H__ \ No newline at end of file
diff --git a/data/mnet/Common/include/socket/GenServerSocket.h b/data/mnet/Common/include/socket/GenServerSocket.h
new file mode 100644
index 0000000..5f6ca74
--- /dev/null
+++ b/data/mnet/Common/include/socket/GenServerSocket.h
@@ -0,0 +1,74 @@
+#ifndef __GenServerSocket_H__
+#define __GenServerSocket_H__
+
+
+// *******************************************************************
+//
+// (c) Copyright CISCO Systems, Inc 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// Status : Under development
+// File : GenServerSocket.h
+// Author(s) : Igal Gutkin
+// Create Date : 06/20/00
+// Description : GenServerSocket.h: interface for the GenServerSocket class.
+//
+// *******************************************************************
+
+#include "socket\GenSocketSSL.h"
+
+// Defaults
+#define kTCP_LISTEN_BACKLOG 10
+
+// Socket receive buffer size
+#define SOC_MRCV_BUFF_LEN (0x2000)
+// Socket send buffer size
+#define SOC_MSND_BUFF_LEN (0x500)
+
+
+class GenServerSocket : public GenSocketSSL
+{
+public:
+ GenServerSocket ()
+ : GenSocketSSL (), port_(0) { ; }
+
+ GenServerSocket (bool bEnableSSL, bool bEnableEncryption = true);
+
+ virtual
+ ~GenServerSocket ();
+
+ virtual
+ int serve (const fd_set *, GenSocket *&)
+ { return false; }
+ bool open (ubyte2 Port);
+
+ static bool initSslContext (LPSTR lpPswd = NULL);
+ static void cleanSslContext() { GenSocketSSL::cleanSslContext(pCtx_); }
+
+protected:
+ virtual bool isContext ();
+ virtual SSL_CTX *getContext();
+
+ bool acceptConnection (OS_SPECIFIC_SOCKET_HANDLE& accSoc);
+ bool bind2Address (ubyte2 Port);
+
+private:
+ void setPort (ubyte2 Port) { if (Port) port_ = Port;}
+
+// Data members
+protected:
+
+ static SSL_CTX * pCtx_ ; // SSL context (one per all servers on the host)
+
+ ubyte2 port_;
+
+};
+
+
+
+#endif //__GenServerSocket_H__ \ No newline at end of file
diff --git a/data/mnet/Common/include/socket/GenSocket.h b/data/mnet/Common/include/socket/GenSocket.h
new file mode 100644
index 0000000..b059894
--- /dev/null
+++ b/data/mnet/Common/include/socket/GenSocket.h
@@ -0,0 +1,131 @@
+#ifndef __GENSOCKET_H__
+#define __GENSOCKET_H__
+
+
+// *******************************************************************
+//
+// (c) Copyright CISCO Systems, Inc 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// Status : Under development
+// File : GenSocket.h
+// Author(s) : Igal Gutkin
+// Create Date : 06/20/00
+// Description : interface for the GenSocket class.
+//
+// *******************************************************************
+
+// system includes
+#ifdef __VXWORKS__
+ #include <vxworks.h>
+ #include <stdio.h>
+ #include <ctype.h>
+
+ #include <string.h>
+ #include <time.h>
+
+ #include <sockLib.h>
+ #include <hostLib.h>
+ #include <ioLib.h>
+
+ #include "socdefs.h"
+
+#elif (defined(_WINDOWS) || defined(WIN32) )
+ #include <iostream.h>
+ #include <winsock2.h>
+ #include <wsnetbs.h>
+ #include <wsipx.h>
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <stdarg.h>
+
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include <direct.h>
+
+ #include <limits.h>
+ #include <io.h>
+ #include <fcntl.h>
+
+ #include <time.h>
+
+#include "StdAfx.h"
+
+#endif // system includes
+
+#include "defs.h"
+#include "CdrDbg.h"
+
+
+typedef char IpAddrPool_t [20];
+
+typedef enum {
+ SOCKET_NOT_CONNECTED = 0,
+ SOCKET_CONNECTED = 1,
+ SOCKET_CONNECTED_READABLE = 2
+} SocketState_t;
+
+
+class GenSocket
+{
+public:
+ GenSocket();
+ virtual ~GenSocket();
+
+ static ubyte4 getLocalHostAddress ();
+ static const LPSTR getIp (ubyte4 ipAddr);
+
+ virtual bool isValid () {return (sock_ != INVALID_SOCKET && sock_);}
+
+ // print socket info
+ virtual int tcpReceive (sbyte *pBuf, int BufSize);
+ virtual int tcpSend (sbyte *pBuf, int BufSize);
+ virtual void releaseSocket (bool grace = false );
+ virtual void printInfo ();
+
+ // Socket-specific method will test and serve the socket upon need
+ virtual int serve (const fd_set *, GenSocket *&)
+ {return (false);}
+
+ OS_SPECIFIC_SOCKET_HANDLE
+ getSocket () {return (sock_);};
+ SocketState_t isConnected ();
+
+protected:
+
+ static ubyte4 getHostAddress (LPSTR);
+ virtual bool create ();
+ // close the socket and reset class variables
+ virtual void cleanup ();
+
+ bool setSocket (OS_SPECIFIC_SOCKET_HANDLE Socket);
+ ubyte4 getRemoteHostAddress ();
+
+private:
+ void resetSocket () {sock_ = INVALID_SOCKET;}
+
+
+// data members
+protected:
+ static bool bMoreInfo_;
+
+private:
+ OS_SPECIFIC_SOCKET_HANDLE sock_ ;
+
+ // temporary storage for translated IP address
+ // will be overwitten with every call using it
+ static IpAddrPool_t szIpAddr_;
+
+ // Used for select write_fd
+ static const struct timeval timeOut_;
+
+};
+
+
+
+#endif //__GENSOCKET_H__ \ No newline at end of file
diff --git a/data/mnet/Common/include/socket/GenSocketSSL.h b/data/mnet/Common/include/socket/GenSocketSSL.h
new file mode 100644
index 0000000..ecc7cde
--- /dev/null
+++ b/data/mnet/Common/include/socket/GenSocketSSL.h
@@ -0,0 +1,218 @@
+#ifndef __GENSOCKETSSL_H__
+#define __GENSOCKETSSL_H__
+// *******************************************************************
+//
+// (c) Copyright CISCO Systems, Inc 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// File : GenSocketSSL.h
+// Author(s) : Igal Gutkin
+// Create Date : 05/17/01
+// Description : interface for the GenSocketSSL class.
+//
+// *******************************************************************
+
+#include "socket\GenSocket.h"
+#include "socket\SslIntf.h"
+
+typedef enum
+{
+ ALLSUITES ,
+ DESCBC3SHA,
+ NOSSL
+
+} CipherSuite_t;
+
+// SSL error codes
+typedef enum
+{
+ SSL_NO_ERROR = 0,
+ SSL_GENERIC_ERROR = 1,
+ SSL_BAD_PASSWORD = 2,
+ SSL_BAD_KEY = 3,
+ SSL_BAD_CA_ERROR = 4,
+ SSL_BAD_USER_CERT = 5,
+ SSL_BAD_PEER_CERT = 6,
+
+ SSL_GEN_ERROR ,
+
+ SSL_ERROR_MAX
+
+} SslError_t;
+
+
+typedef enum
+{
+ CertNoError ,
+ CertMiscError ,
+ CertUnspecifiedError ,
+ CertNotYetValid ,
+ CertExpired ,
+ CertNotBeforeError ,
+ CertNotAfterError ,
+ CertCrlLastUpdateError ,
+ CertCrlNextUpdateError ,
+ CertPathLengthExceed ,
+ CertInvalidPurpose ,
+ CertUntrusted ,
+ CertInvalidCA ,
+ CertZeroSelfSigned , // selfsigned and not trusted
+ CertRevoked ,
+ CertOneNotSelfSigned , // the only certificate in the chain is not selfsigned
+ CertNoIssuer ,
+ CertUntrustedNoRoot , // no local root
+ CertUnableDecryptSignature,
+ CertUnableDecodeIssuerKey ,
+ CertInvalidSignature ,
+ CertNoIssuerCert // can not find issuer certificate locally
+
+} SslValidationCodes_t;
+
+extern "C"
+{
+ // Password read\write utilities
+ bool encryptPassword (const char *pwd, const char *filename);
+ bool decryptPassword (char *pwdout , const char *filename);
+
+ // Class info
+ void SocDataPrint ();
+
+}
+
+
+class GenSocketSSL : public GenSocket
+{
+// friends definition
+friend int verify_callback (int ok, X509_STORE_CTX *pStoreCtx);
+
+public:
+
+// Constructors & destructor
+ GenSocketSSL ()
+ : GenSocket () ,
+ bEnableSsl_ (false),
+ bEnableEncryption_(false),
+ pSsl_ (NULL ),
+ pSbio_ (NULL ) { ; }
+
+ GenSocketSSL (bool enableSSL, bool enableEncryption = true,
+ SSL_CTX *pCtx = NULL)
+ : GenSocket () ,
+ bEnableSsl_ (isSSL() ? enableSSL : false),
+ bEnableEncryption_(bEnableSsl_ ? enableEncryption : false),
+ pSsl_ (NULL ),
+ pSbio_ (NULL ) { ; }
+
+ virtual ~GenSocketSSL () { ; }
+
+ // Primary methods
+
+ static bool isSupportSSL () { return (isSSL ()!=0); }
+ bool isEnableSSL () { return (bEnableSsl_); }
+ bool isInitSSL () { return (isValid () && isContext() && pSsl_ && pSbio_); }
+
+ virtual int tcpReceive (sbyte *pBuf, int BufSize);
+
+ virtual int tcpSend (sbyte *pBuf, int BufSize);
+
+ virtual void releaseSocket (bool grace = false);
+ virtual void printInfo ();
+
+ static void classPrintInfo();
+
+ static SslError_t getError() { return (errorCode_); }
+
+ static void printVerifyError (long code);
+
+ // password manipulation methods
+ static bool setPassword (LPCSTR lpPswd);
+ static void resetPassword();
+ static LPCSTR getPassword () { return (szPswd_ ); }
+ static bool isPswdSet () { return (szPswd_[0] != 0); }
+
+ // configure SSL library
+ static void initSslLib ();
+ static void cleanSslLib () {/*SSL_library_cleanup()*/ ; }
+
+ static int getStats () { return (count_) ; }
+
+
+protected:
+
+ virtual bool isContext () = 0;
+ virtual SSL_CTX *getContext() = 0;
+
+ static void setError (SslError_t code) { errorCode_ = code ; }
+ static void resetError (SslError_t code) { errorCode_ = SSL_NO_ERROR; }
+
+ static bool verifyCert (long code);
+ static LPSTR getCertError (long code);
+
+ // init\clean SSL context
+ // using one shared context per application
+ static bool initSslContext (SSL_CTX *& pCtx, bool bServer, LPSTR password = NULL);
+ static void cleanSslContext (SSL_CTX *& pCtx);
+
+ // init\clean socket-specific SSL resources
+ bool initSsl ();
+ void cleanSsl ();
+
+ // handle SSL connection setup
+ bool acceptSsl ();
+ bool connectSsl ();
+
+ // send\receive data through SSL connection
+ int readSsl (sbyte *pBuf, int BufSize);
+ int writeSsl (sbyte *pBuf, int BufSize);
+
+ void printSession();
+ int getSocNum () { return (count_); }
+
+private:
+
+// data members
+protected:
+
+ SSL *pSsl_ ; // SSL connection
+ BIO *pSbio_ ; // SSL socket wrapper
+
+ static LPCSTR cipherSuite_[];
+
+private:
+
+ static bool bInitLib_ ;
+
+ static char szPswd_[SSL_MAX_PASSWORD_LENGTH+2]; // pointer to password string
+
+#ifdef __SSL_USE_TEMP_KEY__
+ static RSA * pRsa_ ; // temporary key (server only)
+#endif //__SSL_USE_TEMP_KEY__
+
+ // keeps the last application error code (application will not reset the code!)
+ static SslError_t errorCode_;
+
+ // when false SSL functionality is bypassed
+ // otherwise, authentication is enabled and
+ // ciphering is depend on enableEncryption_
+ const bool bEnableSsl_ ;
+
+ // when false, SSL encryption is disabled
+ // but using authentication on connect
+ const bool bEnableEncryption_ ;
+
+ static char szKeyFile_ [MAX_PATH]; // private key
+ static char szCertFile_[MAX_PATH]; // certificate
+ static char szCaFile_ [MAX_PATH]; // trusted CA List
+
+ // Count SSL sockets
+ static int count_;
+
+};
+
+
+#endif //__GENSOCKETSSL_H__ \ No newline at end of file
diff --git a/data/mnet/Common/include/socket/SslIntf.h b/data/mnet/Common/include/socket/SslIntf.h
new file mode 100644
index 0000000..d2dc9be
--- /dev/null
+++ b/data/mnet/Common/include/socket/SslIntf.h
@@ -0,0 +1,41 @@
+#ifndef __SSLINTF_H__
+#define __SSLINTF_H__
+// *******************************************************************
+//
+// (c) Copyright CISCO Systems, Inc 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// File : SslIntf.h
+// Author(s) : Igal Gutkin
+// Create Date : 05/17/01
+// Description : generic interface between SSL Socket library and SSL
+// implementations
+//
+// *******************************************************************
+
+#if defined (_OPEN_SSL_LIB_)
+ #include <openssl/rand.h>
+ #include <openssl/ssl.h>
+ #include <openssl/bio.h>
+ #include <openssl/err.h>
+
+#elif defined (_RSA_SSL_LIB_)
+ #include "rsa/ssl_rsa.h"
+
+#endif
+
+#define SSL_MIN_PASSWORD_LENGTH 4
+#define SSL_MAX_PASSWORD_LENGTH 32 // must be a multiple of LENGTH_OF_CBLOCK
+#define LENGTH_OF_CBLOCK 8
+
+// specifies whether SSL is supported by the library (false for the stub)
+
+extern "C" { int isSSL (); }
+
+
+#endif //__SSLINTF_H__ \ No newline at end of file
diff --git a/data/mnet/Common/include/subsc/SubscGPRSInfoType.h b/data/mnet/Common/include/subsc/SubscGPRSInfoType.h
new file mode 100644
index 0000000..52d9e75
--- /dev/null
+++ b/data/mnet/Common/include/subsc/SubscGPRSInfoType.h
@@ -0,0 +1,69 @@
+
+// *******************************************************************
+//
+// (c) Copyright Cisco 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// Status : Under development
+// File : SubscGPRSInfoType.h
+// Author(s) : Kevin Lim
+// Create Date : 12-12-00
+// Description : message and ie interface among GUDB and other modules
+//
+// *******************************************************************
+
+#ifndef SUBSC_GPRS_INFO_TYPE_H
+#define SUBSC_GPRS_INFO_TYPE_H
+
+#include "ril3/ril3_sm_msg.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define MAX_NUM_SUBSC_GPRS_DATA 16 // was 50
+#define MAX_LEN_SUBSC_PDP_ADDR 16
+#define MAX_LEN_SUBSC_APN CNI_RIL3_MAX_ACCESS_POINT_NAME_LENGTH
+
+typedef struct {
+ CNI_RIL3_QOS_DELAY_CLASS delay_class;
+ CNI_RIL3_QOS_RELIABILITY_CLASS reliability_class;
+ CNI_RIL3_QOS_PRECEDENCE_CLASS precedence_class;
+ CNI_RIL3_QOS_PEAK_THROUGHPUT peak_throughput;
+ CNI_RIL3_QOS_MEAN_THROUGHPUT mean_throughput;
+} T_SUBSC_QOS_DATA;
+
+typedef struct {
+ unsigned char pdpContextId;
+ CNI_RIL3_PDP_ADDRESS_TYPE pdpType;
+ unsigned char pdpAddress[MAX_LEN_SUBSC_PDP_ADDR];
+ T_SUBSC_QOS_DATA qosSubscribed;
+ unsigned char vplmnAddressAllowed;
+ unsigned char apn_length;
+ unsigned char apn[MAX_LEN_SUBSC_APN];
+ // extension
+} T_SUBSC_GPRS_DATA;
+
+typedef struct {
+// T_SUBSC_INFO_IE_TYPE ie_type; // only in encoded message
+ short num_data;
+ T_SUBSC_GPRS_DATA data[MAX_NUM_SUBSC_GPRS_DATA];
+} T_SUBSC_IE_GPRS_DATA_INFO;
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // SUBSC_GPRS_INFO_TYPE_H
+
+
+
+
+
diff --git a/data/mnet/Common/include/subsc/SubscINProfileType.h b/data/mnet/Common/include/subsc/SubscINProfileType.h
new file mode 100644
index 0000000..4a26da1
--- /dev/null
+++ b/data/mnet/Common/include/subsc/SubscINProfileType.h
@@ -0,0 +1,47 @@
+
+// *******************************************************************
+//
+// (c) Copyright Cisco 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// Status : Under development
+// File : SubscINProfileType.h
+// Author(s) : Ji-Hoon Yoon
+// Create Date : 09-25-01
+// Description : message and ie interface among GUDB and other modules
+//
+// *******************************************************************
+
+#ifndef SUBSC_IN_PROFILE_TYPE_H
+#define SUBSC_IN_PROFILE_TYPE_H
+
+#include "ril3/ril3_sm_msg.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct {
+ unsigned char classId;
+} T_SUBSC_IN_PROFILE_CLASS_INFO;
+
+typedef struct {
+ bool isPrepaid;
+} T_SUBSC_IN_PROFILE_PREPAID_INDICATOR;
+
+typedef struct {
+ bool isPresent;
+ T_SUBSC_IN_PROFILE_CLASS_INFO classInfo;
+ T_SUBSC_IN_PROFILE_PREPAID_INDICATOR prepaidIndicator;
+} T_SUBSC_IE_IN_PROFILE; // 2.1.2
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // SUBSC_IN_PROFILE_TYPE_H \ No newline at end of file
diff --git a/data/mnet/Common/include/subsc/SubscInfoType.h b/data/mnet/Common/include/subsc/SubscInfoType.h
new file mode 100644
index 0000000..5f6c651
--- /dev/null
+++ b/data/mnet/Common/include/subsc/SubscInfoType.h
@@ -0,0 +1,619 @@
+
+// *******************************************************************
+//
+// (c) Copyright Cisco 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// Status : Under development
+// File : SubscInfoType.h
+// Author(s) : Kevin Lim
+// Create Date : 06-16-99
+// Description : message and ie interface among LUDB and other modules
+//
+// *******************************************************************
+
+#ifndef SUBSC_INFO_TYPE_H
+#define SUBSC_INFO_TYPE_H
+
+#include "SubscGPRSInfoType.h"
+#include "SubscINProfileType.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// version history
+// 2.0.3 combine IMSI fields as one
+// 2.0.4 added num_plan in ISDN
+// 2.0.5 added SS_DATA type in SS_INFO
+// 2.0.6 added SS_INFO_INDEX
+// 2.0.7 breaking SS_INFO_TYPE into three structure instead of union
+// 2.0.8 added SUPP_SERV_BIC_ROAM
+// 2.1.0 added GPRS data with encoder/decoder change - G.2.
+// 2.1.1 added CLIR feature support
+// 2.1.2 added IN profile support
+
+#define SUBSC_ENC_VER0 2
+#define SUBSC_ENC_VER1 1
+#define SUBSC_ENC_VER2 2
+
+typedef struct {
+ short v0;
+ short v1;
+ short v2;
+} T_SUBSC_VERSION;
+
+typedef enum {
+ SUBSC_INFO_IE_VERSION_NUMBER = 0x00,
+ SUBSC_INFO_IE_MOBILE_ID_IMSI = 0x01,
+ SUBSC_INFO_IE_ISDN = 0x02,
+ SUBSC_INFO_IE_SUBADDR = 0x03,
+ SUBSC_INFO_IE_PROVISION_BS = 0x05,
+ SUBSC_INFO_IE_PROVISION_TS = 0x06,
+ SUBSC_INFO_IE_PROVISION_SS = 0x07,
+ SUBSC_INFO_IE_SUBSC_STATUS = 0x08,
+ SUBSC_INFO_IE_ODB_DATA = 0x09,
+ SUBSC_INFO_IE_SS_INFO_LIST = 0x0A,
+ SUBSC_INFO_IE_USER_INFO = 0x0B,
+ SUBSC_INFO_IE_GPRS_DATA = 0x0C,
+
+ SUBSC_INFO_IE_AUTH_LIST = 0x11,
+} T_SUBSC_INFO_IE_TYPE;
+
+typedef enum {
+ ALL_BEARER_SERVICES = 0x00,
+
+ ALL_DATA_CDA = 0x10,
+ DATA_CDA_300BPS = 0x11,
+ DATA_CDA_1200BPS = 0x12,
+ DATA_CDA_1200_75BPS = 0x13,
+ DATA_CDA_2400BPS = 0x14,
+ DATA_CDA_4800BPS = 0x15,
+ DATA_CDA_9600BPS = 0x16, // supported by ViperCell
+ DATA_CDA_14400BPS = 0x66, // supported by ViperCell
+ DATA_CDA_GENERAL = 0x17,
+
+ ALL_DATA_CDS = 0x18,
+ DATA_CDS_1200BPS = 0x1A,
+ DATA_CDS_2400BPS = 0x1C,
+ DATA_CDS_4800BPS = 0x1D,
+ DATA_CDS_9600BPS = 0x1E,
+ DATA_CDS_GENERAL = 0x1F,
+
+ ALL_PAD_ACCESS_CA = 0x20,
+ PAD_ACCESS_CA_300BPS = 0x21,
+ PAD_ACCESS_CA_1200BPS = 0x22,
+ PAD_ACCESS_CA_1200_75BPS = 0x23,
+ PAD_ACCESS_CA_2400BPS = 0x24,
+ PAD_ACCESS_CA_4800BPS = 0x25,
+ PAD_ACCESS_CA_9600BPS = 0x26,
+ PAD_ACCESS_CA_GENERAL = 0x27,
+
+ ALL_DATA_PDS = 0x28,
+ DATA_PDS_2400BPS = 0x2C,
+ DATA_PDS_4800BPS = 0x2D,
+ DATA_PDS_9600BPS = 0x2E,
+ DATA_PDS_GENERAL = 0x2F,
+
+ ALL_ALT_SPEECH_DATA_CDA = 0x30,
+ ALL_ALT_SPEECH_DATA_CDS = 0x38,
+ ALL_SPEECH_FOLL_DATA_CDA = 0x40,
+ ALL_SPEECH_FOLL_DATA_CDS = 0x48,
+
+ ALL_PLMN_SPECIFIC_BS = 0xD0,
+ PLMN_SPECIFIC_BS_1 = 0xD1,
+ PLMN_SPECIFIC_BS_2 = 0xD2,
+ PLMN_SPECIFIC_BS_3 = 0xD3,
+ PLMN_SPECIFIC_BS_4 = 0xD4,
+ PLMN_SPECIFIC_BS_5 = 0xD5,
+ PLMN_SPECIFIC_BS_6 = 0xD6,
+ PLMN_SPECIFIC_BS_7 = 0xD7,
+ PLMN_SPECIFIC_BS_8 = 0xD8,
+ PLMN_SPECIFIC_BS_9 = 0xD9,
+ PLMN_SPECIFIC_BS_A = 0xDA,
+ PLMN_SPECIFIC_BS_B = 0xDB,
+ PLMN_SPECIFIC_BS_C = 0xDC,
+ PLMN_SPECIFIC_BS_D = 0xDD,
+ PLMN_SPECIFIC_BS_E = 0xDE,
+ PLMN_SPECIFIC_BS_F = 0xDF,
+
+} T_SUBSC_INFO_BEARER_SERVICE_CODE;
+
+typedef enum {
+ ALL_TELE_SERVICES = 0x00,
+
+ ALL_SPEECH_SERVICES = 0x10,
+ TELEPHONY_SERVICES = 0x11, // supported by ViperCell
+ EMERGENCY_CALLS = 0x12, // supported by ViperCell
+
+ ALL_SMS = 0x20,
+ SMS_MT_PP = 0x21, // supported by ViperCell
+ SMS_MO_PP = 0x22, // supported by ViperCell
+
+ ALL_FACS = 0x60,
+ FACS_GRP3_ALT_SPEECH = 0x61, // supported by ViperCell
+ AUTO_FACS_GRP3 = 0x62, // supported by ViperCell
+ FACS_GRP4 = 0x63,
+
+ ALL_VOICE_GROUP_CALL = 0x90,
+ VOICE_GROUP_CALL = 0x91,
+ VOICE_BROADCAST = 0x92,
+
+ ALL_PLMN_SPECIFIC_TS = 0xD0,
+ PLMN_SPECIFIC_TS_1 = 0xD1,
+ PLMN_SPECIFIC_TS_2 = 0xD2,
+ PLMN_SPECIFIC_TS_3 = 0xD3,
+ PLMN_SPECIFIC_TS_4 = 0xD4,
+ PLMN_SPECIFIC_TS_5 = 0xD5,
+ PLMN_SPECIFIC_TS_6 = 0xD6,
+ PLMN_SPECIFIC_TS_7 = 0xD7,
+ PLMN_SPECIFIC_TS_8 = 0xD8,
+ PLMN_SPECIFIC_TS_9 = 0xD9,
+ PLMN_SPECIFIC_TS_A = 0xDA,
+ PLMN_SPECIFIC_TS_B = 0xDB,
+ PLMN_SPECIFIC_TS_C = 0xDC,
+ PLMN_SPECIFIC_TS_D = 0xDD,
+ PLMN_SPECIFIC_TS_E = 0xDE,
+ PLMN_SPECIFIC_TS_F = 0xDF,
+
+} T_SUBSC_INFO_TELE_SERVICE_CODE;
+
+typedef enum {
+ SUPP_SERV_ALL_LI = 0x10,
+ SUPP_SERV_CLIP = 0x11,
+ SUPP_SERV_CLIR = 0x12,
+ SUPP_SERV_COLP = 0x13,
+ SUPP_SERV_COLR = 0x14,
+ SUPP_SERV_ALL_FWD = 0x20,
+ SUPP_SERV_CFU = 0x21,
+ SUPP_SERV_ALL_CCF = 0x28, // all conditional call forwarding
+ SUPP_SERV_CFB = 0x29,
+ SUPP_SERV_CFNRY = 0x2A,
+ SUPP_SERV_CFNRC = 0x2B,
+ SUPP_SERV_ALL_CO = 0x30,
+ SUPP_SERV_ECT = 0x31,
+ SUPP_SERV_ALL_CC = 0x40,
+ SUPP_SERV_CW = 0x41,
+ SUPP_SERV_HOLD = 0x42,
+ SUPP_SERV_ALL_MULT = 0x50,
+ SUPP_SERV_MPTY = 0x51,
+ SUPP_SERV_ALL_BAR = 0x90,
+ SUPP_SERV_BAOC = 0x92,
+ SUPP_SERV_BOIC = 0x93,
+ SUPP_SERV_BOICE = 0x94,
+ SUPP_SERV_BAIC = 0x9A,
+ SUPP_SERV_BIC_ROAM = 0x9B, // added 06/19/2000 kevinlim
+} T_SUBSC_INFO_SUPP_SERVICE_CODE;
+
+typedef enum { // 2.0.7
+ SS_INFO_IND_FORW_CFU = 0,
+ SS_INFO_IND_FORW_CFB = 1,
+ SS_INFO_IND_FORW_CFNRC = 2,
+ SS_INFO_IND_FORW_CFNRY = 3,
+ SS_INFO_IND_FORW_MAX
+} T_SUBSC_SS_INFO_FORW_INDEX;
+
+typedef enum {
+ SS_INFO_IND_DATA_CW = 0,
+ SS_INFO_IND_DATA_HOLD = 1,
+ SS_INFO_IND_DATA_CLIP = 2,
+ SS_INFO_IND_DATA_CLIR = 3,
+ SS_INFO_IND_DATA_COLP = 4,
+ SS_INFO_IND_DATA_COLR = 5,
+ SS_INFO_IND_DATA_ECT = 6,
+ SS_INFO_IND_DATA_MPTY = 7,
+ SS_INFO_IND_DATA_MAX
+} T_SUBSC_SS_INFO_DATA_INDEX;
+
+typedef enum {
+ SS_INFO_IND_BAR_BAOC = 0,
+ SS_INFO_IND_BAR_BOIC = 1,
+ SS_INFO_IND_BAR_BOICE = 2,
+ SS_INFO_IND_BAR_BAIC = 3,
+ SS_INFO_IND_BAR_BIC_ROAM = 4,
+ SS_INFO_IND_BAR_MAX
+} T_SUBSC_SS_INFO_BAR_INDEX;
+
+/*
+typedef enum { // 2.0.6
+ SS_INFO_IND_CFU = 0,
+ SS_INFO_IND_CFB = 1,
+ SS_INFO_IND_CFNRC = 2,
+ SS_INFO_IND_CFNRY = 3,
+ SS_INFO_IND_CW = 4,
+ SS_INFO_IND_HOLD = 5,
+ SS_INFO_IND_CLIP = 6,
+ SS_INFO_IND_CLIR = 7,
+ SS_INFO_IND_COLP = 8,
+ SS_INFO_IND_COLR = 9,
+ SS_INFO_IND_ECT = 10,
+ SS_INFO_IND_MPTY = 11,
+ SS_INFO_IND_BAOC = 12,
+ SS_INFO_IND_BOIC = 13,
+ SS_INFO_IND_BOICE = 14,
+ SS_INFO_IND_BAIC = 15,
+} T_SUBSC_SS_INFO_INDEX;
+*/
+
+typedef enum {
+ ODB_GEN_BIT_ALL_OG = 0,
+ ODB_GEN_BIT_INTRN_OG = 1,
+ ODB_GEN_BIT_INTRN_OG_NOT_HPLMN = 2,
+ ODB_GEN_BIT_PREM_INFO = 3,
+ ODB_GEN_BIT_PREM_ENT = 4,
+ ODB_GEN_BIT_SS_ACCESS = 5,
+ ODB_GEN_BIT_INTRZ_OG = 6,
+ ODB_GEN_BIT_INTRZ_OG_NOT_HPLMN = 7,
+
+ ODB_GEN_BIT_INTRZ_INTRN_NOT_HPLMN = 0,
+ ODB_GEN_BIT_ALL_ECT = 1,
+ ODB_GEN_BIT_CHARGE_ECT = 2,
+ ODB_GEN_BIT_INTRN_ECT = 3,
+ ODB_GEN_BIT_INTRZ_ECT = 4,
+ ODB_GEN_BIT_DBL_CHARGE_ECT = 5,
+ ODB_GEN_BIT_MULTI_ECT = 6,
+
+} T_ODB_GEN_BIT;
+
+typedef enum {
+ ODB_HPLMN_BIT_TYPE_1 = 0,
+ ODB_HPLMN_BIT_TYPE_2 = 1,
+ ODB_HPLMN_BIT_TYPE_3 = 2,
+ ODB_HPLMN_BIT_TYPE_4 = 3,
+} T_ODB_HPLMN_BIT;
+
+typedef enum {
+ SS_STATUS_A_BIT = 0,
+ SS_STATUS_R_BIT = 1,
+ SS_STATUS_P_BIT = 2,
+ SS_STATUS_Q_BIT = 3,
+} T_SS_STATUS_BIT;
+
+
+#define MAX_NUM_SUBSC_IMSI 18
+
+#define SUBSC_MCC_LEN 3
+#define SUBSC_MNC_LEN 2
+#define SUBSC_MSIN_LEN 10
+
+typedef struct {
+// T_SUBSC_INFO_IE_TYPE ie_type; // only in encoded message
+ unsigned char num_digit;
+ unsigned char imsi[MAX_NUM_SUBSC_IMSI];
+} T_SUBSC_IE_MOBILE_ID_IMSI;
+
+
+// this struct can be changed to 9 byte long TBCD format, if necessary.
+#define MAX_NUM_SUBSC_ISDN 18
+#define NUM_PLAN_LEN 1
+typedef struct {
+// T_SUBSC_INFO_IE_TYPE ie_type; // only in encoded message
+ short num_digit;
+ unsigned char digits[MAX_NUM_SUBSC_ISDN];
+ unsigned char num_plan[NUM_PLAN_LEN];
+} T_SUBSC_IE_ISDN;
+
+#define NUM_SUBADDR_INFO 1 // was 20
+typedef struct {
+// T_SUBSC_INFO_IE_TYPE ie_type; // only in encoded message
+ short subaddr_type;
+ unsigned char info[NUM_SUBADDR_INFO];
+} T_SUBSC_IE_SUBADDR;
+
+#define MAX_NUM_BEARER_SERVICE 5 // was 50
+typedef struct {
+// T_SUBSC_INFO_IE_TYPE ie_type; // only in encoded message
+ short num_srv;
+ T_SUBSC_INFO_BEARER_SERVICE_CODE bs_code[MAX_NUM_BEARER_SERVICE];
+} T_SUBSC_IE_PROVISION_BS;
+
+#define MAX_NUM_TELE_SERVICE 10 // was 20
+typedef struct {
+// T_SUBSC_INFO_IE_TYPE ie_type; // only in encoded message
+ short num_srv;
+ T_SUBSC_INFO_TELE_SERVICE_CODE ts_code[MAX_NUM_TELE_SERVICE];
+} T_SUBSC_IE_PROVISION_TS;
+
+#define MAX_NUM_SUPP_SERVICE 21 // was 30
+typedef struct {
+// T_SUBSC_INFO_IE_TYPE ie_type; // only in encoded message
+ short num_srv;
+ T_SUBSC_INFO_SUPP_SERVICE_CODE ss_code[MAX_NUM_SUPP_SERVICE];
+} T_SUBSC_IE_PROVISION_SS;
+
+typedef enum {
+ SUBSC_STATUS_SERVICE_GRANTED = 0,
+ SUBSC_STATUS_ODBARRING = 1,
+} T_SUBSC_STATUS_TYPE;
+
+typedef struct {
+// T_SUBSC_INFO_IE_TYPE ie_type; // only in encoded message
+ T_SUBSC_STATUS_TYPE status;
+} T_SUBSC_IE_SUBSC_STATUS;
+
+typedef struct {
+ unsigned char all_og_barred;
+ unsigned char intrn_og_barred;
+ unsigned char intrn_og_not_hplmn_barred;
+ unsigned char premium_info_og_barred;
+ unsigned char premium_enter_og_barred;
+ unsigned char ss_access_barred;
+ unsigned char intrz_og_barred;
+ unsigned char intrz_og_not_hplmn_barred;
+ unsigned char intrz_intrn_og_not_hplmn_barred;
+ unsigned char all_ect_barred;
+ unsigned char chargeable_ect_barred;
+ unsigned char intrn_ect_barred;
+ unsigned char intrz_ect_barred;
+ unsigned char double_chargeable_ect_barred;
+ unsigned char multiple_ect_barred;
+} T_ODB_GEN_FLAGS;
+
+typedef struct {
+ unsigned char plmn_specific_type1;
+ unsigned char plmn_specific_type2;
+ unsigned char plmn_specific_type3;
+ unsigned char plmn_specific_type4;
+} T_ODB_PLMN_FLAGS;
+
+typedef enum {
+ BEARER_SERVICE_TYPE = 0,
+ TELE_SERVICE_TYPE = 1,
+} T_SUBSC_INFO_BASIC_SERVICE_TYPE;
+
+typedef struct {
+ T_SUBSC_INFO_BASIC_SERVICE_TYPE service_type;
+ union {
+ unsigned char ex_bs_code[5]; // octet 2-5 reserved
+ unsigned char ex_ts_code[5]; // octet 2-5 reserved
+ };
+} T_SUBSC_INFO_EXT_BASIC_SERVICE;
+
+typedef struct {
+ unsigned char ss_status_A;
+ unsigned char ss_status_R;
+ unsigned char ss_status_P;
+ unsigned char ss_status_Q;
+} T_SS_STATUS_FLAG;
+
+typedef enum {
+ NO_NOTIFICATION_TO_FORWARDING = 0,
+ NOTIFICATION_TO_FORWARDING = 1,
+} T_NOTIFY_FORW_FLAG;
+
+typedef enum {
+ NO_NOTIFICATION_TO_CALLING = 0,
+ NOTIFICATION_TO_CALLING = 1,
+} T_NOTIFY_CALLING_FLAG;
+
+typedef enum {
+ MS_NOT_REACHABLE = 0,
+ MS_BUSY = 1,
+ NO_REPLY = 2,
+ UNCONDITIONAL = 3,
+} T_FORW_REASON_FLAG;
+
+typedef enum {
+ SS_NOTIFY_FORW_FLAG_BIT = 0,
+ SS_NOTIFY_CALLING_FLAG_BIT = 1,
+ SS_FORW_REASON_FLAG_BIT = 2,
+} T_SS_FORW_OPTION_BITS;
+
+typedef struct {
+ T_NOTIFY_FORW_FLAG notify_forw_party;
+ T_NOTIFY_CALLING_FLAG notify_calling_party;
+ T_FORW_REASON_FLAG forw_reason;
+} T_SS_FORW_OPTION;
+
+typedef struct {
+// T_SUBSC_INFO_IE_TYPE ie_type; // only in encoded message
+ T_ODB_GEN_FLAGS odb_general;
+ T_ODB_PLMN_FLAGS odb_plmn;
+} T_SUBSC_IE_ODB_DATA;
+
+typedef struct {
+ T_SUBSC_INFO_EXT_BASIC_SERVICE basic_service;
+ T_SS_STATUS_FLAG ss_status;
+ T_SUBSC_IE_ISDN forw_to_num;
+ T_SUBSC_IE_SUBADDR forw_to_sub;
+ T_SS_FORW_OPTION forw_options;
+ short no_reply_cond_time;
+} T_SUBSC_FORW_FEATURE;
+
+typedef struct {
+ T_SUBSC_INFO_EXT_BASIC_SERVICE basic_service;
+ T_SS_STATUS_FLAG ss_status;
+} T_SUBSC_BARR_FEATURE;
+
+#define MAX_NUM_EXT_FEATURE 1 // was 20 -> 5 -> 1 (2.0.7)
+
+typedef struct {
+ T_SUBSC_INFO_SUPP_SERVICE_CODE ss_code;
+ short num_feature;
+ T_SUBSC_FORW_FEATURE list[MAX_NUM_EXT_FEATURE];
+} T_SUBSC_IE_SS_INFO_FORW;
+
+typedef struct {
+ T_SUBSC_INFO_SUPP_SERVICE_CODE ss_code;
+ short num_feature;
+ T_SUBSC_BARR_FEATURE list[MAX_NUM_EXT_FEATURE];
+} T_SUBSC_IE_SS_INFO_BAR;
+
+typedef enum {
+ SS_SUBSC_OPTION_CLIR_OPTION = 2,
+ SS_SUBSC_OPTION_OVERRIDE_CATEGORY = 1,
+} T_SS_SUBSC_OPTION_TYPE; // 2.1.1
+
+typedef enum {
+ CLIR_PERMANENT = 0,
+ CLIR_TEMP_DFT_RESTRICTED = 1,
+ CLIR_TEMP_DFT_ALLOWED = 2,
+} T_SS_SUBSC_CLIR_OPTION; // 2.1.1
+
+typedef enum {
+ OVERRIDE_ENABLED = 0,
+ OVERRIDE_DISABLED = 1,
+} T_SS_SUBSC_OVERRIDE_CATEGORY; // 2.1.1
+
+typedef struct {
+ bool isPresent;
+ T_SS_SUBSC_OPTION_TYPE option_type;
+ union {
+ T_SS_SUBSC_CLIR_OPTION clir_option;
+ T_SS_SUBSC_OVERRIDE_CATEGORY override_category;
+ };
+} T_SS_SUBSC_OPTION; // 2.1.1
+
+typedef struct {
+ T_SUBSC_INFO_SUPP_SERVICE_CODE ss_code;
+ T_SS_STATUS_FLAG ss_status;
+ T_SS_SUBSC_OPTION ss_subsc_option; // 2.1.1
+} T_SUBSC_IE_SS_INFO_DATA; // 2.0.5
+
+typedef enum {
+ SUBSC_IE_SS_INFO_FORW_TYPE = 1,
+ SUBSC_IE_SS_INFO_BARR_TYPE = 2,
+ SUBSC_IE_SS_INFO_DATA_TYPE = 3, // 2.0.5
+} T_SUBSC_IE_SS_INFO_TYPE;
+
+typedef struct {
+ T_SUBSC_IE_SS_INFO_TYPE info_type;
+ union {
+ T_SUBSC_IE_SS_INFO_FORW info_forw;
+ T_SUBSC_IE_SS_INFO_BAR info_bar;
+ T_SUBSC_IE_SS_INFO_DATA info_data; // 2.0.5
+ };
+} T_SUBSC_IE_SS_INFO;
+
+typedef struct {
+// T_SUBSC_INFO_IE_TYPE ie_type; // only in encoded message
+ short num_ss_info; // FORW_MAX + DATA_MAX + BAR_MAX
+ T_SUBSC_IE_SS_INFO_FORW ss_info_forw[SS_INFO_IND_FORW_MAX];
+ T_SUBSC_IE_SS_INFO_DATA ss_info_data[SS_INFO_IND_DATA_MAX];
+ T_SUBSC_IE_SS_INFO_BAR ss_info_bar [SS_INFO_IND_BAR_MAX];
+} T_SUBSC_IE_SS_INFO_LIST;
+
+#define MAX_NUM_USER_INFO 32
+typedef struct {
+// T_SUBSC_INFO_IE_TYPE ie_type; // only in encoded message
+ short len;
+ unsigned char name[MAX_NUM_USER_INFO];
+} T_SUBSC_IE_USER_INFO;
+
+typedef struct {
+ T_SUBSC_IE_MOBILE_ID_IMSI imsi;
+ T_SUBSC_IE_ISDN msisdn;
+ T_SUBSC_IE_PROVISION_BS prov_bs;
+ T_SUBSC_IE_PROVISION_TS prov_ts;
+ T_SUBSC_IE_PROVISION_SS prov_ss;
+ T_SUBSC_IE_SUBSC_STATUS status;
+ T_SUBSC_IE_ODB_DATA odb_data;
+ T_SUBSC_IE_SS_INFO_LIST ss_info_list;
+ T_SUBSC_IE_USER_INFO user;
+ T_SUBSC_IE_GPRS_DATA_INFO gprs_data; // 2.1.0
+ T_SUBSC_IE_IN_PROFILE in_profile; // 2.1.2
+} T_SUBSC_INFO;
+
+
+typedef enum {
+ SUBSC_INFO_NO_ERR = 0,
+ SUBSC_INFO_ERR_UNEXP_IE = 1,
+ SUBSC_INFO_ERR_ISDN_NUM_DIGIT = 2,
+ SUBSC_INFO_ERR_BS_NUM_SRV = 3,
+ SUBSC_INFO_ERR_TS_NUM_SRV = 4,
+ SUBSC_INFO_ERR_SS_NUM_SRV = 5,
+ SUBSC_INFO_ERR_UNKNOWN_BASIC = 6,
+ SUBSC_INFO_ERR_FORW_NUM_FEATURE = 7,
+ SUBSC_INFO_ERR_BAR_NUM_FEATURE = 8,
+ SUBSC_INFO_ERR_SS_INFO_TYPE = 9,
+ SUBSC_INFO_ERR_SS_NUM_INFO = 10,
+ SUBSC_INFO_ERR_USER_INFO = 11,
+ SUBSC_INFO_ERR_IMSI_NUM_DIGIT = 12,
+ SUBSC_INFO_ERR_VERSION = 13,
+ SUBSC_INFO_ERR_GPRS_DATA_LEN = 14,
+ SUBSC_INFO_ERR_APN_LEN = 15,
+
+ SUBSC_INFO_ERR_AUTH_NUM_LIST = 20,
+ SUBSC_INFO_ERR_SS_SUBSC_OPTION = 21, // 2.1.1
+} SUBSC_INFO_ERR;
+
+#define SEC_RAND_LEN 16
+#define SEC_SRES_LEN 4
+#define SEC_KC_LEN 8
+
+typedef struct {
+ unsigned char RAND[SEC_RAND_LEN];
+ unsigned char SRES[SEC_SRES_LEN];
+ unsigned char Kc[SEC_KC_LEN];
+} T_AUTH_TRIPLET;
+
+#define SEC_MAX_TRIPLET 5
+
+typedef struct {
+// T_SUBSC_INFO_IE_TYPE ie_type; // only in encoded message
+ short num_set;
+ T_AUTH_TRIPLET triplet[SEC_MAX_TRIPLET];
+} T_SEC_IE_AUTH_LIST;
+
+typedef struct {
+ T_SUBSC_IE_MOBILE_ID_IMSI imsi;
+ T_SEC_IE_AUTH_LIST auth_set;
+} T_SEC_INFO;
+
+
+// Function prototypes
+
+/* SubscInfo.cpp */
+
+char * getSubscInfoIETypeStr(T_SUBSC_INFO_IE_TYPE ie_type);
+char * getSubscInfoBSCodeStr(T_SUBSC_INFO_BEARER_SERVICE_CODE code);
+char * getSubscInfoTSCodeStr(T_SUBSC_INFO_TELE_SERVICE_CODE code);
+char * getSubscInfoSSCodeStr(T_SUBSC_INFO_SUPP_SERVICE_CODE code);
+short checkSubscInfoIEType(unsigned char ie_type, T_SUBSC_INFO_IE_TYPE exp);
+
+void printSubscMsg(unsigned char *msg, short size);
+
+/* SubscInfoMsgEncoder.cpp */
+
+// Encode SubscInfo to Message Buffer (Byte Stream) provided.
+// size - size of msg buffer, returned with actual used size
+short EncodeSubscInfo(unsigned char *msg,
+ short *size,
+ T_SUBSC_INFO *subsc);
+
+// Encode SecurityInfo to Message Buffer (Byte Stream) provided.
+// size - size of msg buffer, returned with actual used size
+short EncodeSecInfo(unsigned char *msg,
+ short *size,
+ T_SEC_INFO *sec);
+
+/* SubscInfoMsgDecoder.cpp */
+
+// Decode SubscInfo from Message Buffer to the structure.
+// size - size of message in msg buffer
+short DecodeSubscInfo(unsigned char *msg,
+ short size,
+ T_SUBSC_INFO *subsc);
+
+// Decode SecInfo from Message Buffer to the structure.
+// size - size of message in msg buffer
+short DecodeSecInfo(unsigned char *msg,
+ short size,
+ T_SEC_INFO *sec);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // SUBSC_INFO_TYPE_H
+
+
+
+
+
diff --git a/data/mnet/Common/include/subsc/SubscInfoUtil.h b/data/mnet/Common/include/subsc/SubscInfoUtil.h
new file mode 100644
index 0000000..5a24947
--- /dev/null
+++ b/data/mnet/Common/include/subsc/SubscInfoUtil.h
@@ -0,0 +1,254 @@
+
+// *******************************************************************
+//
+// (c) Copyright Cisco 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// Status : Under development
+// File : SubscInfoUtil.h
+// Author(s) : Kevin Lim
+// Create Date : 06-16-99
+// Description : message and ie interface among LUDB and other modules
+//
+// *******************************************************************
+
+#ifndef SUBSC_INFO_UTIL_H
+#define SUBSC_INFO_UTIL_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+T_SUBSC_IE_MOBILE_ID_IMSI* subscGetMobileIdPtr(T_SUBSC_INFO *info);
+T_SUBSC_IE_ISDN* subscGetMSISDNPtr(T_SUBSC_INFO *info);
+T_SUBSC_IE_PROVISION_BS* subscGetProvBSPtr(T_SUBSC_INFO *info);
+T_SUBSC_IE_PROVISION_TS* subscGetProvTSPtr(T_SUBSC_INFO *info);
+T_SUBSC_IE_PROVISION_SS* subscGetProvSSPtr(T_SUBSC_INFO *info);
+T_SUBSC_IE_SUBSC_STATUS* subscGetSubscStatusPtr(T_SUBSC_INFO *info);
+T_SUBSC_IE_ODB_DATA* subscGetODBDataPtr(T_SUBSC_INFO *info);
+T_SUBSC_IE_SS_INFO_LIST* subscGetSSInfoListPtr(T_SUBSC_INFO *info);
+T_SUBSC_IE_USER_INFO* subscGetUserInfoPtr(T_SUBSC_INFO *info);
+T_SUBSC_IE_GPRS_DATA_INFO* subscGetGPRSDataPtr(T_SUBSC_INFO *info);
+
+bool subscIsProvCLIP (T_SUBSC_INFO *info);
+bool subscIsProvCLIR (T_SUBSC_INFO *info);
+bool subscIsProvCOLP (T_SUBSC_INFO *info);
+bool subscIsProvCOLR (T_SUBSC_INFO *info);
+bool subscIsProvCFU (T_SUBSC_INFO *info);
+bool subscIsProvCFB (T_SUBSC_INFO *info);
+bool subscIsProvCFNRY (T_SUBSC_INFO *info);
+bool subscIsProvCFNRC (T_SUBSC_INFO *info);
+bool subscIsProvECT (T_SUBSC_INFO *info);
+bool subscIsProvCW (T_SUBSC_INFO *info);
+bool subscIsProvHOLD (T_SUBSC_INFO *info);
+bool subscIsProvMPTY (T_SUBSC_INFO *info);
+bool subscIsProvBAOC (T_SUBSC_INFO *info);
+bool subscIsProvBOIC (T_SUBSC_INFO *info);
+bool subscIsProvBOICE (T_SUBSC_INFO *info);
+bool subscIsProvBAIC (T_SUBSC_INFO *info);
+bool subscIsProvBICRoam(T_SUBSC_INFO *info);
+
+T_SUBSC_FORW_FEATURE* subscGetForwFeature(T_SUBSC_IE_SS_INFO_LIST *ss_info_list,
+ T_SUBSC_INFO_SUPP_SERVICE_CODE ss_code);
+bool subscIsActiveCF(T_SUBSC_IE_SS_INFO_LIST *ss_info_list,
+ T_SUBSC_INFO_SUPP_SERVICE_CODE ss_code);
+bool subscIsActiveCW(T_SUBSC_IE_SS_INFO_LIST *ss_info_list);
+int subscGetTimerCFNRY(T_SUBSC_IE_SS_INFO_LIST *ss_info_list);
+
+void subscPrintImsi(T_SUBSC_IE_MOBILE_ID_IMSI *imsi);
+void subscPrintIsdn(T_SUBSC_IE_ISDN *msisdn);
+void subscPrintProvBS(T_SUBSC_IE_PROVISION_BS *prov_bs);
+void subscPrintProvTS(T_SUBSC_IE_PROVISION_TS *prov_ts);
+void subscPrintProvSS(T_SUBSC_IE_PROVISION_SS *prov_ss);
+void subscPrintSubscStatus(T_SUBSC_IE_SUBSC_STATUS *status);
+void subscPrintODBData(T_SUBSC_IE_ODB_DATA *odb_data);
+void subscPrintSSInfoList(T_SUBSC_IE_SS_INFO_LIST *ss_info_list);
+void subscPrintUserInfo(T_SUBSC_IE_USER_INFO *user);
+void subscPrintGPRSDataPtr(T_SUBSC_IE_GPRS_DATA_INFO *gprs_data);
+
+void subscPrintInfo(T_SUBSC_INFO *info);
+void subscPrintGPRSInfo(T_SUBSC_INFO *info);
+char *subscGetStringImsi(T_SUBSC_IE_MOBILE_ID_IMSI *imsi);
+char *subscGetStringIsdn(T_SUBSC_IE_ISDN *isdn);
+char *subscGetStringUser(T_SUBSC_IE_USER_INFO *user);
+char *subscGetCFNum(T_SUBSC_IE_SS_INFO_LIST *ss_info_list,
+ T_SUBSC_INFO_SUPP_SERVICE_CODE ss_code);
+T_SUBSC_IE_ISDN* subscGetCFNumPtr(T_SUBSC_IE_SS_INFO_LIST *ss_info_list,
+ T_SUBSC_INFO_SUPP_SERVICE_CODE ss_code);
+
+void subscSetIMSI(T_SUBSC_INFO *subsc, char *buf);
+void subscSetMSISDN(T_SUBSC_INFO *subsc, char *buf);
+void subscSetUserInfo(T_SUBSC_INFO *subsc, char *buf);
+void subscSetACF(T_SUBSC_IE_SS_INFO_LIST *ss_info_list,
+ T_SUBSC_INFO_SUPP_SERVICE_CODE ss_code,
+ int active);
+void subscSetPCF(T_SUBSC_IE_SS_INFO_LIST *ss_info_list,
+ T_SUBSC_INFO_SUPP_SERVICE_CODE ss_code,
+ int prov); // use subscSetP instead
+void subscSetRCF(T_SUBSC_IE_SS_INFO_LIST *ss_info_list,
+ T_SUBSC_INFO_SUPP_SERVICE_CODE ss_code,
+ int reg);
+
+void subscSetCFNum(T_SUBSC_IE_SS_INFO_LIST *ss_info_list,
+ T_SUBSC_INFO_SUPP_SERVICE_CODE ss_code,
+ char *num);
+void subscSetTimerCFNRY(T_SUBSC_IE_SS_INFO_LIST *ss_info_list,
+ int sec);
+
+T_SS_STATUS_FLAG* subscGetStatusFlagPtr(T_SUBSC_IE_SS_INFO_LIST *ss_info_list,
+ T_SUBSC_INFO_SUPP_SERVICE_CODE ss_code);
+
+int subscGetP(T_SUBSC_IE_SS_INFO_LIST *ss_info_list,
+ T_SUBSC_INFO_SUPP_SERVICE_CODE ss_code);
+
+int subscGetA(T_SUBSC_IE_SS_INFO_LIST *ss_info_list,
+ T_SUBSC_INFO_SUPP_SERVICE_CODE ss_code);
+
+int subscGetR(T_SUBSC_IE_SS_INFO_LIST *ss_info_list,
+ T_SUBSC_INFO_SUPP_SERVICE_CODE ss_code);
+
+int subscGetQ(T_SUBSC_IE_SS_INFO_LIST *ss_info_list,
+ T_SUBSC_INFO_SUPP_SERVICE_CODE ss_code);
+
+void subscSetP(T_SUBSC_IE_SS_INFO_LIST *ss_info_list,
+ T_SUBSC_INFO_SUPP_SERVICE_CODE ss_code,
+ int prov);
+
+void subscSetA(T_SUBSC_IE_SS_INFO_LIST *ss_info_list,
+ T_SUBSC_INFO_SUPP_SERVICE_CODE ss_code,
+ int active);
+
+void subscSetR(T_SUBSC_IE_SS_INFO_LIST *ss_info_list,
+ T_SUBSC_INFO_SUPP_SERVICE_CODE ss_code,
+ int registered);
+
+void subscSetQ(T_SUBSC_IE_SS_INFO_LIST *ss_info_list,
+ T_SUBSC_INFO_SUPP_SERVICE_CODE ss_code,
+ int quiescent);
+
+int subscGetSSInfoInd(T_SUBSC_INFO_SUPP_SERVICE_CODE ss_code); // 2.0.6
+int subscGetSSInfoForwInd(T_SUBSC_INFO_SUPP_SERVICE_CODE ss_code); // 2.0.7
+int subscGetSSInfoDataInd(T_SUBSC_INFO_SUPP_SERVICE_CODE ss_code); // 2.0.7
+int subscGetSSInfoBarInd(T_SUBSC_INFO_SUPP_SERVICE_CODE ss_code); // 2.0.7
+void subscSSInfoListClear(T_SUBSC_IE_SS_INFO_LIST *info_list); // 2.0.6
+
+
+void subscInfoInitialize(T_SUBSC_INFO *info); // 2.0.6
+
+int subscIsODBarred (T_SUBSC_INFO *info);
+int subscIsODBAllOg (T_SUBSC_INFO *info);
+int subscIsODBIntrnOg (T_SUBSC_INFO *info);
+int subscIsODBIntrnOgNotHplmn (T_SUBSC_INFO *info);
+int subscIsODBPremiumInfoOg (T_SUBSC_INFO *info);
+int subscIsODBPremiumEnterOg (T_SUBSC_INFO *info);
+int subscIsODBSsAccess (T_SUBSC_INFO *info);
+int subscIsODBIntrzOg (T_SUBSC_INFO *info);
+int subscIsODBIntrzOgNotHplmn (T_SUBSC_INFO *info);
+int subscIsODBIntrzIntrnOgNotHplmn (T_SUBSC_INFO *info);
+int subscIsODBAllEct (T_SUBSC_INFO *info);
+int subscIsODBChargeableEct (T_SUBSC_INFO *info);
+int subscIsODBIntrnEct (T_SUBSC_INFO *info);
+int subscIsODBIntrzEct (T_SUBSC_INFO *info);
+int subscIsODBDoubleChargeableEct (T_SUBSC_INFO *info);
+int subscIsODBMultipleEct (T_SUBSC_INFO *info);
+
+void subscSetODB (T_SUBSC_INFO *info, int flag);
+void subscSetODBAllOg (T_SUBSC_INFO *info, int flag);
+void subscSetODBIntrnOg (T_SUBSC_INFO *info, int flag);
+void subscSetODBIntrnOgNotHplmn (T_SUBSC_INFO *info, int flag);
+void subscSetODBPremiumInfoOg (T_SUBSC_INFO *info, int flag);
+void subscSetODBPremiumEnterOg (T_SUBSC_INFO *info, int flag);
+void subscSetODBSsAccess (T_SUBSC_INFO *info, int flag);
+void subscSetODBIntrzOg (T_SUBSC_INFO *info, int flag);
+void subscSetODBIntrzOgNotHplmn (T_SUBSC_INFO *info, int flag);
+void subscSetODBIntrzIntrnOgNotHplmn (T_SUBSC_INFO *info, int flag);
+void subscSetODBAllEct (T_SUBSC_INFO *info, int flag);
+void subscSetODBChargeableEct (T_SUBSC_INFO *info, int flag);
+void subscSetODBIntrnEct (T_SUBSC_INFO *info, int flag);
+void subscSetODBIntrzEct (T_SUBSC_INFO *info, int flag);
+void subscSetODBDoubleChargeableEct (T_SUBSC_INFO *info, int flag);
+void subscSetODBMultipleEct (T_SUBSC_INFO *info, int flag);
+
+int subscIsSSBaoc (T_SUBSC_INFO *info);
+int subscIsSSBoic (T_SUBSC_INFO *info);
+int subscIsSSBoicExHC (T_SUBSC_INFO *info);
+int subscIsSSBaic (T_SUBSC_INFO *info);
+int subscIsSSBicRoam (T_SUBSC_INFO *info);
+
+void subscSetSSBaoc (T_SUBSC_INFO *info, int flag);
+void subscSetSSBoic (T_SUBSC_INFO *info, int flag);
+void subscSetSSBoicExHC (T_SUBSC_INFO *info, int flag);
+void subscSetSSBaic (T_SUBSC_INFO *info, int flag);
+void subscSetSSBicRoam (T_SUBSC_INFO *info, int flag);
+
+int subscGetTSIndex(T_SUBSC_IE_PROVISION_TS *ts_list,
+ T_SUBSC_INFO_TELE_SERVICE_CODE code);
+int subscExistTS(T_SUBSC_INFO *info, T_SUBSC_INFO_TELE_SERVICE_CODE code);
+int subscAddTS(T_SUBSC_INFO *info, T_SUBSC_INFO_TELE_SERVICE_CODE code);
+int subscDelTS(T_SUBSC_INFO *info, T_SUBSC_INFO_TELE_SERVICE_CODE code);
+
+int subscProvSMS_MO_PP(T_SUBSC_INFO *info);
+int subscProvSMS_MT_PP(T_SUBSC_INFO *info);
+
+void subscProvSSCode(T_SUBSC_INFO *info, T_SUBSC_INFO_SUPP_SERVICE_CODE code, int add);
+
+int subscGetCLIROption(T_SUBSC_INFO *info, T_SS_SUBSC_CLIR_OPTION *option); // 2.1.1
+int subscSetCLIROption(T_SUBSC_INFO *info, T_SS_SUBSC_CLIR_OPTION option); // 2.1.1
+
+/* GPRS */
+T_SUBSC_GPRS_DATA *subscGetGprsPdpDataPtr(T_SUBSC_INFO *info, int index);
+
+/* find entry by pdpContextId */
+/* return 0 and index value -1 if not found */
+/* return pointer to T_SUBSC_GPRS_DATA and index of T_SUBSC_IE_GPRS_DATA_INFO's data array */
+
+T_SUBSC_GPRS_DATA *subscFindGprsPdpData(T_SUBSC_INFO *info, unsigned char pdpContextId, int *index);
+
+/* copy data to the new entry after the last entry and increase num_data of the list */
+/* return 0 on success */
+/* return -1 if can't get pointer to T_SUBSC_IE_GPRS_DATA_INFO */
+/* return 1 if T_SUBSC_GPRS_DATA already exists with pdpContextId same data->pdpContextId */
+/* return 2 internal error */
+/* return 3 T_SUBSC_IE_GPRS_DATA_INFO's data array is full */
+
+int subscAddGprsPdpData(T_SUBSC_INFO *info, T_SUBSC_GPRS_DATA *data);
+
+/* copy the last entry data to the delete target entry and decrease num_data of the list */
+/* return 0 on success */
+/* return -1 if can't get pointer to T_SUBSC_IE_GPRS_DATA_INFO */
+/* return 1 if T_SUBSC_GPRS_DATA not found with pdpContextId */
+/* return 2 internal error */
+/* return 3 internal error, T_SUBSC_IE_GPRS_DATA_INFO's data array is empty */
+
+int subscDelGprsPdpData(T_SUBSC_INFO *info, unsigned char pdpContextId);
+
+/* find and modify the passed data in the list */
+/* return 0 on success */
+/* return -1 if can't get pointer to T_SUBSC_IE_GPRS_DATA_INFO */
+/* return 1 if T_SUBSC_GPRS_DATA not found with pdpContextId */
+/* return 2 internal error */
+/* return 3 internal error, T_SUBSC_IE_GPRS_DATA_INFO's data array is empty */
+
+int subscModifyGprsPdpData(T_SUBSC_INFO *info, T_SUBSC_GPRS_DATA *data);
+
+/* IN PROFILE */
+
+int subscGetClassInfo(T_SUBSC_INFO *info, unsigned char* classId); // 2.1.2
+int subscGetPrepaidIndicator(T_SUBSC_INFO *info, bool* isPrepaid); // 2.1.2
+int subscSetInProfile(T_SUBSC_INFO *info, T_SUBSC_IE_IN_PROFILE *inProf); // 2.1.2
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // SUBSC_INFO_UTIL_H
+
+
+
+
+
diff --git a/data/mnet/Common/include/table.h b/data/mnet/Common/include/table.h
new file mode 100644
index 0000000..058cbdd
--- /dev/null
+++ b/data/mnet/Common/include/table.h
@@ -0,0 +1,121 @@
+/*-------------------------------------------------------------------------
+ *
+ * table.h Table processing routines
+ *
+ * These routines are used to manipulate tables. They comprise a simple
+ * alternative data structure to static arrays or linked lists for
+ * handling data records. It allows the program to easily reference the
+ * table and step through its entries.
+ *
+ ***************************************************************************
+ * Modification history
+ * ----------------------------
+ * 03/04/00 Bhawani Change _DEBUG from DEBUG
+ *
+ *--------------------------------------------------------------------------
+ */
+
+#ifndef TABLE_H_DEFINED
+#define TABLE_H_DEFINED
+
+
+typedef int Int;
+typedef char Int8;
+typedef short Int16;
+typedef long Int32;
+typedef double Int64;
+
+typedef unsigned int uInt;
+typedef unsigned char uInt8;
+typedef unsigned short uInt16;
+typedef unsigned long uInt32;
+typedef double uInt64;
+
+typedef int Status; /* Status codes returned: */
+#define True 1
+#define False 0
+#define Success True
+#define Failure False
+#ifndef Null
+#define Null 0
+#endif
+
+typedef struct Table_t {
+ Int16 magic; /* Magic Marker. */
+ Int16 size; /* Size of a row. */
+ Int16 end; /* End of the table. */
+ Int16 last; /* Last row allocated. */
+ Int16 index; /* current index. */
+ Int16 status; /* Last status of table. */
+ Int16 limit; /* Limit to the table growth. */
+ Int16 insert; /* Buffer insert pointer. */
+ char *data; /* Pointer to actual data. */
+ int (*sort)(const void *, const void *); /* Qsort process if any. */
+} Table;
+
+#define VALID_TABLE(tbl) (tbl&&((tbl->magic == TABLE_VALID)||(tbl->magic == TABLE_SORT)||(tbl->magic == TABLE_BUFFER)))
+#define FREE_TABLE(tbl) (tbl&&(tbl->magic == TABLE_FREE))
+#define TABLE_VALID (Int16) 0xAAAA
+#define TABLE_SORT (Int16) 0xBBBB
+#define TABLE_BUFFER (Int16) 0xCCCC
+#define TABLE_FREE (Int16) 0xF3EE
+#define TABLE_CHUNK 10 /* # of entries per realloc() */
+#define CHUNK(siz) (((siz/TABLE_CHUNK)+1)*TABLE_CHUNK)
+
+/* ANSI Function prototypes. */
+
+extern Table *table_create(int);
+extern Status table_free(Table *);
+extern void *table_getRow(Table *, int);
+extern void *table_getValue(Table *, int);
+extern void *table_getFirst(Table *);
+extern void *table_getLast(Table *);
+extern void *table_getPrev(Table *);
+extern void *table_getNext(Table *);
+extern Status table_getEntry(Table *, int, void *, int);
+extern Status table_setEntry(Table *, int, void *, int);
+extern Status table_addEntry(Table *, char *, int);
+extern Status table_removeEntry(Table *, int);
+extern Status table_setValue(Table *, int, int);
+extern Status table_addValue(Table *, int);
+extern Status table_extend(Table *, int);
+extern Status table_limit(Table *, int);
+extern Status table_buffer(Table *, int);
+extern Status table_status(Table *);
+extern int table_size(Table *);
+extern int table_end(Table *);
+extern void *table_find(Table *, int (*)(const void *, const void *), void *);
+extern void *table_find_next(Table *, int (*)(const void *, const void *), void *);
+extern Status table_sort(Table *, int (*)(const void *, const void *));
+
+
+#endif /* TABLE_H_DEFINED */
+
+#ifndef DEBUG_H_DEFINED
+#define DEBUG_H_DEFINED
+
+extern void debug_msg(char *);
+extern void debug_stop(char *);
+extern int debug_print();
+extern int debug_test(char *, char *, int);
+extern void debug_index();
+extern void debug_catalog(char *, char *, int);
+extern int debug_catalogFind(const void *, const void *);
+extern int strncasecmp(char *, char *, int);
+extern int strcasecmp(char *, char *);
+extern char *strdup(char *);
+
+#ifdef _DEBUG
+#define DBG(a) (debug_test(a, __FILE__, __LINE__))
+#define DMSG(a, b) (debug_test(a, __FILE__, __LINE__) ? (b) : 0)
+#else
+#define DBG(a)
+#define DMSG(a, b)
+#endif
+
+#endif
+
+
+
+
+
diff --git a/data/mnet/Common/include/vxTemplate/vxTemplateIF.h b/data/mnet/Common/include/vxTemplate/vxTemplateIF.h
new file mode 100644
index 0000000..c1540ec
--- /dev/null
+++ b/data/mnet/Common/include/vxTemplate/vxTemplateIF.h
@@ -0,0 +1,33 @@
+/********************************************************************
+ *
+ * (c) Copyright Cisco 2000
+ * All Rights Reserved
+ *
+ ********************************************************************/
+
+/********************************************************************
+ *
+ * Version : 1.0
+ * Status : Under development
+ * File : vxTemplateIF.h
+ * Author(s) : Lou Travaglione
+ * Create Date : 8/29/00
+ * Description : Demo I/F header code for vxTemplate directory.
+ *
+ ********************************************************************/
+
+#ifndef _VXTEMPLATEIF_H_
+#define _VXTEMPLATEIF_H_
+
+/*************************************************************
+ *
+ * Module Name: Hello_World
+ *
+ * Function: Demo function for template directory.
+ *
+ *************************************************************/
+
+void Hello_World(void);
+
+
+#endif /* _VXTEMPLATEIF_H_ */ \ No newline at end of file
diff --git a/data/mnet/Common/logging/Makefile b/data/mnet/Common/logging/Makefile
new file mode 100644
index 0000000..bd4611d
--- /dev/null
+++ b/data/mnet/Common/logging/Makefile
@@ -0,0 +1,47 @@
+##########################################################
+#
+# (c) Copyright Cisco 2000
+# All Rights Reserved
+#
+# Use Examples:
+#
+# Case 1:
+# make all VOB=GP10 -
+# Places .out in VOB/bin directory
+#
+# Case 2:
+# make all VOB=GP10 APPDIR=Host\<Application Name>\<Source Directory> -
+# Places .o file(s) in VOB\$(APPDIR)\bin directory.
+#
+# <Application Name> = Name of Application directory
+# <Source Directory> = application sub directory where the calling
+# Makefile resides.
+#
+# Example: make all VOB=GP10 APPDIR=Host\vxTemplate\src
+#
+# (OPTIONAL) Append REPLACE - Replaces the List of directories
+# to be used in the SUBDIRS variable
+#
+# Example: make all VOB=GP10 APPDIR=Host\vxTemplate\src REPLACE=src
+#
+# Note: This make file must reference a VOB that
+# has a defs.mk in the top level directory.
+#
+##########################################################
+
+SUBDIRS = src
+
+# TOP_OF_VOB must be defined before including l3defs.mk
+TOP_OF_VOB = ..\..
+
+VOBDIR = $(TOP_OF_VOB)\$(VOB)
+
+# Allows a sub-set of the source code directories to be used
+
+ifneq ($(REPLACE),)
+ SUBDIRS = $(REPLACE)
+endif
+
+include $(VOBDIR)\l3defs.mk
+
+
diff --git a/data/mnet/Common/logging/src/Makefile b/data/mnet/Common/logging/src/Makefile
new file mode 100644
index 0000000..199c21a
--- /dev/null
+++ b/data/mnet/Common/logging/src/Makefile
@@ -0,0 +1,61 @@
+##########################################################
+#
+# (c) Copyright Cisco 2000
+# All Rights Reserved
+#
+# Use Examples:
+#
+# Case 1:
+# make all VOB=GP10 -
+# Places .out in VOB/bin directory
+#
+# Case 2:
+# make all VOB=GP10 APPDIR=Host\<Application Name>\<Source Directory> -
+# Places .o file(s) in VOB\$(APPDIR)\bin directory.
+#
+# <Application Name> = Name of Application directory
+# <Source Directory> = application sub directory where the calling
+# Makefile resides.
+#
+# Example: make all VOB=GP10 APPDIR=Host\vxTemplate\src
+#
+#
+# Note: This make file must reference a VOB that
+# has a defs.mk in the top level directory.
+#
+##########################################################
+
+# TOP_OF_VOB must be defined before including l3defs.mk
+TOP_OF_VOB = ..\..\..
+
+# Name of this App's Directory
+THIS_APP_DIR = logging
+
+VOB2DIR = $(TOP_OF_VOB)\$(VOB)
+BINDIR = ..\bin
+
+ifeq ($(APPDIR),)
+ MY_OUTPUT = $(VOB2DIR)\bin\$(THIS_APP_DIR).out
+else
+ MY_OUTPUT = $(OBJDIR)\$(THIS_APP_DIR).out
+endif
+
+include $(VOB2DIR)\l3defs.mk
+
+
+all: $(MY_OUTPUT)
+
+$(MY_OUTPUT): $(MODULE_OBJS)
+ $(LD) -r -o $@.tmp $(MODULE_OBJS)
+ $(NM) $@.tmp | munch > _ctdt.c
+ $(CC) -traditional $(CC_ARCH_SPEC) -c _ctdt.c
+ $(LD) -r -o $@ _ctdt.o $@.tmp
+ $(RM)$(subst /,$(DIRCHAR), _ctdt.c _ctdt.o $@.tmp)
+
+cleanall:
+ @for %f in ($(notdir $(MODULE_OBJS))) do \
+ $(RM) ..\bin\%f
+
+ $(RM) $(MY_OUTPUT)
+
+
diff --git a/data/mnet/Common/logging/src/debug.cpp b/data/mnet/Common/logging/src/debug.cpp
new file mode 100644
index 0000000..7f3aa1a
--- /dev/null
+++ b/data/mnet/Common/logging/src/debug.cpp
@@ -0,0 +1,140 @@
+// *******************************************************************
+//
+// (c) Copyright CISCO Systems, Inc 2001
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// Status : Under development
+// File : debug.cpp
+// Author(s) : Igal Gutkin
+// Create Date : 8/10/01
+// Description :
+//
+// *******************************************************************
+
+#include <stdio.h>
+#include <stdarg.h>
+#include <ctype.h>
+
+#include "dbgfunc.h"
+
+
+/* print debug messages directly to the stdio */
+void dbg_print (char *format, ...)
+{
+ va_list marker;
+ va_start(marker, format); /* Initialize variable arguments. */
+ vprintf (format, marker);
+ fflush (stdout);
+ va_end (marker); /* Reset variable arguments. */
+}
+
+
+/* Put the inbound data in a hex dump format into stdio
+ Arguments:
+ pSrc - input data
+ length - specifies the number of bytes to dump
+ pDest - output buffer */
+void HexDump (unsigned char *buffer, int length)
+{
+ FormatHexDump (buffer, length, NULL);
+}
+
+
+/* Put the inbound data in a hex dump format into the buffer
+ Arguments:
+ pSrc - input data
+ length - specifies the number of bytes to dump
+ pDest - output buffer, if NULL print to stdio */
+void FormatHexDump (unsigned char *pSrc, int length, char *pDest)
+{
+ int size ;
+ int idx ;
+ int dwPos = 0;
+ int offset = 0;
+
+ while (length > 0)
+ {
+ // Take min of 16 or length
+ size = min (16, length);
+
+ // Build text line
+ if (pDest)
+ offset += sprintf (pDest+offset, " %04X ", dwPos);
+ else
+ printf (" %04X ", dwPos);
+
+ for (idx = 0; idx < size; idx++)
+ {
+ if (pDest)
+ offset += sprintf (pDest+offset, "%02X ", pSrc[idx]);
+ else
+ printf ("%02X ", pSrc[idx]);
+ }
+
+ // Add spaces for short lines
+ while (idx < 16)
+ {
+ if (pDest)
+ offset += sprintf (pDest+offset, " ");
+ else
+ printf (" ");
+ idx++;
+ }
+
+ // Add ASCII chars
+ for (idx = 0; idx < size; idx++)
+ {
+ if (pDest)
+ offset += sprintf (pDest+offset, "%c", (isprint(pSrc[idx])) ? pSrc[idx] : '.');
+ else
+ printf ("%c", (isprint(pSrc[idx])) ? pSrc[idx] : '.');
+ }
+
+ if (pDest)
+ offset += sprintf (pDest+offset, "\n");
+ else
+ printf ("\n");
+
+ // Advance positions
+ length -= size;
+ dwPos += size;
+ pSrc += size;
+ }
+}
+
+
+/* Put the inbound data in a plain hex format into the buffer
+ Arguments:
+ pSrc - input data
+ length - specifies the number of bytes to dump
+ pDest - output buffer */
+void PlainHexDump (unsigned char *pSrc, int length, char *pDest)
+{
+ int offset = 0;
+
+ for (int count = 0; count < length; count++)
+ {
+ if (pDest)
+ offset += sprintf (pDest+offset, "%02x ", *(pSrc+count));
+ else
+ printf ("%02x ", *(pSrc+count));
+ }
+
+ if (pDest)
+ offset += sprintf (pDest+offset, "\n");
+ else
+ printf ("\n");
+}
+
+
+void DbgCheckPoint (char * pFile, int line)
+{
+ static unsigned count = 0;
+
+ printf ("Checkpoint num. %u at %s, line %u\n", ++count, pFile, line);
+}
diff --git a/data/mnet/Common/logging/src/logging.cpp b/data/mnet/Common/logging/src/logging.cpp
new file mode 100644
index 0000000..e931ace
--- /dev/null
+++ b/data/mnet/Common/logging/src/logging.cpp
@@ -0,0 +1,901 @@
+/*
+ ****************************************************************************************
+ * *
+ * Copyright Cisco Systems, Inc 2000 All rights reserved *
+ * *
+ *--------------------------------------------------------------------------------------*
+ * *
+ * File : Logging.cpp *
+ * *
+ * Description : Utility functions which can be used by modules in the *
+ * MNET systems for logging and resource tracking *
+ * *
+ * Author : Dinesh Nambisan *
+ * *
+ *----------------------- Revision history ---------------------------------------------*
+ * Time | Date | Name | Description *
+ *--------------------------------------------------------------------------------------*
+ * 00:00 |03/18/99 | DSN | Initial version created *
+ * |08/14/01 | Igal | Addded binary hex dump support *
+ * | | | *
+ ****************************************************************************************
+ */
+/*
+ * VxWorks and ANSI C Headers
+ */
+
+#include <assert.h>
+#include <vxworks.h>
+#include <msgqlib.h>
+#include <sockLib.h>
+#include <inetLib.h>
+#include <stdioLib.h>
+#include <strLib.h>
+#include <hostLib.h>
+#include <ioLib.h>
+#include <tasklib.h>
+#include <time.h>
+#include <tickLib.h>
+#include <string.h>
+#include <drv\timer\timerdev.h>
+
+/*
+ * Application Headers
+ */
+#include "logmodules.h"
+#include "dbgfunc.h"
+#include "vclogging.h"
+
+
+/* Length of the formatted */
+#define LOG_FORMATTED_LINE_LENGTH 72
+#define LOG_MAX_OVERHEAD_LENGTH 200
+#define LOG_BUFFER_LENGTH ((VIPERLOG_MAX_OUT_BUFF_LENGTH/16+1)*LOG_FORMATTED_LINE_LENGTH+LOG_MAX_OVERHEAD_LENGTH)
+
+static VIPERLOG_CONFIGURATION *viperlog = NULL;
+
+static char logOutputBuff [LOG_BUFFER_LENGTH];
+
+
+/*
+ * init_log_task
+ */
+void
+init_log_task (void)
+{
+ struct sockaddr_in local_addr;
+
+ if(viperlog != NULL) {
+ printf("ViperLog already initialized!\n");
+ return;
+ }
+
+ sysTimestampEnable();
+
+ viperlog = (VIPERLOG_CONFIGURATION*)malloc(sizeof(VIPERLOG_CONFIGURATION));
+ if (viperlog == NULL) {
+ printf("Unable to allocate memory for ViperLog, aborting!\n");
+ viperlog = NULL;
+ return;
+ }
+
+ memset(viperlog,0,sizeof(VIPERLOG_CONFIGURATION));
+
+ viperlog->log_file_opened = FALSE;
+
+
+ viperlog->log_file = fopen("viperlog.txt","wb");
+
+ if (viperlog->log_file ==NULL) {
+ printf("Unable to open log file for writing!!!\n");
+ viperlog->log_file_opened = FALSE;
+ }
+ else {
+ viperlog->log_file_opened = TRUE;
+ }
+
+ viperlog->log_record_counter = 0;
+
+ if ((viperlog->log_socket = socket (AF_INET, SOCK_DGRAM, 0)) == ERROR) {
+ perror ("socket");
+ printf("Could not create UDP socket for logging!!\n");
+ viperlog->log_socket_opened = FALSE;
+ }
+ else {
+ int optval;
+ char dest_addr_str[128];
+
+ viperlog->log_socket_opened = TRUE;
+
+ setsockopt (viperlog->log_socket, SOL_SOCKET, SO_BROADCAST, (char *)&optval, sizeof (optval));
+ optval = 32768;
+ setsockopt (viperlog->log_socket, SOL_SOCKET, SO_SNDBUF, (char *)&optval, sizeof (optval));
+
+
+ memset((char *)&viperlog->dest_address, 0,sizeof(struct sockaddr_in));
+ viperlog->dest_address.sin_family = AF_INET;
+ viperlog->dest_address.sin_port = htons(VIPERLOG_PORT_NUM);
+ memset(dest_addr_str,0,128);
+ strcpy(dest_addr_str,viperlog_get_network_broadcast_addr());
+ printf("Setting destination address to %s\n",dest_addr_str);
+
+
+ viperlog->dest_address.sin_addr.s_addr = inet_addr(dest_addr_str);
+
+ viperlog->msg_q_id = msgQCreate(VIPERLOG_MAX_MSGS_IN_Q,sizeof(VIPERLOG_PACKET),MSG_Q_FIFO);
+ if (viperlog->msg_q_id == NULL)
+ {
+ printf("Unable to create logging message queue; aborting !!\n");
+ close(viperlog->log_socket);
+ if (viperlog->log_file_opened) fclose(viperlog->log_file);
+ free(viperlog);
+ viperlog = NULL;
+ return;
+ }
+ printf("Logging initialized successfully\n");
+ viperlog->shutdown_message_received = FALSE;
+ }
+}
+
+
+/*
+ * shutdown_log_task
+ */
+void
+shutdown_log_task()
+{
+ viperlog->shutdown_message_received = TRUE;
+}
+
+
+/*
+ * viper_log
+ */
+VOID
+viper_log ()
+{
+ VIPERLOG_PACKET packet;
+ int status;
+ int offset = 0;
+ BOOL output_file, output_console, output_network;
+
+ memset (&packet, 0, sizeof(VIPERLOG_PACKET));
+
+ while (!viperlog->shutdown_message_received)
+ {
+ if (msgQReceive (viperlog->msg_q_id,(char *)&packet,sizeof(VIPERLOG_PACKET),WAIT_FOREVER) != ERROR)
+ {
+ if (packet.magic != VIPERLOG_MSG_MAGIC_NO)
+ {
+ printf ("Invalid debug msg packet received!!\n");
+ }
+ else
+ {
+ // prepare header based on logging parameters
+ output_file = output_console = output_network = FALSE;
+
+ viperlog_get_output_device (packet.module_id, &output_file ,
+ &output_console , &output_network);
+
+ if (output_console | output_network | output_file)
+ {
+ if (packet.data_type == LOG_PLAIN_BINARY)
+ { // processing binary data to the buffer
+ PlainHexDump ((unsigned char *)packet.message, packet.binary_length, logOutputBuff);
+ }
+ else if (packet.data_type == LOG_FORMAT_BINARY)
+ { // processing binary data to the buffer
+ FormatHexDump ((unsigned char *)packet.message, packet.binary_length, logOutputBuff);
+ }
+ else if (packet.data_type == LOG_ASCII)
+ {
+ if (viperlog->console_output_detailed == TRUE)
+ { // prepare detailed log
+ sprintf (logOutputBuff, "%s : %s : %ld-%ld : %015.6f : %s : %s\n",
+ viperlog_get_severity_name((VIPERLOG_SEVERITY)packet.severity_level),
+ viperlog_get_module_name ((LOGGING_MODULE_ID)packet.module_id ),
+ packet.call_id ,
+ packet.tick_count ,
+ packet.timestamp ,
+ packet.function_name,
+ packet.message );
+ }
+ else
+ sprintf (logOutputBuff, "%s\n", packet.message);
+ }
+ else
+ {
+ sprintf (logOutputBuff, "\n");
+ }
+
+ /*
+ * Logging to console
+ */
+ if (output_console)
+ {
+ printf ("%s", logOutputBuff);
+ }
+
+ /*
+ * Logging to file
+ */
+ if (output_file)
+ {
+ if (viperlog->log_file_opened)
+ {
+ fprintf (viperlog->log_file,"%s", logOutputBuff);
+ fflush (viperlog->log_file);
+ viperlog->log_record_counter++;
+
+ if (viperlog->log_record_counter >= VIPERLOG_MAX_RECORDS_IN_FILE)
+ {
+ viperlog->log_record_counter = 0;
+ status = fseek (viperlog->log_file, 0, 0);
+
+ if (status != 0)
+ {
+ printf ("Unable to reset log file pointer to beginning of stream\n");
+ fclose (viperlog->log_file);
+ viperlog->log_file_opened = FALSE;
+ }
+ }
+ }
+ } /* End of if output_file */
+
+ /*
+ * Log to network
+ */
+ if (output_network)
+ {
+ viperlog_send_net_msg (logOutputBuff);
+ }
+ }
+ } /* end of log processing */
+ } /* End of if msgQReceive */
+ } /* End of while loop */
+
+ msgQDelete(viperlog->msg_q_id);
+ close(viperlog->log_socket);
+ fclose(viperlog->log_file);
+ viperlog->log_file = NULL;
+ free(viperlog);
+ viperlog = NULL;
+ return ;
+}
+
+
+/*
+ * viperlog_check_module_filter
+ */
+BOOL
+viperlog_check_module_filter(int module_id, short severity_level)
+{
+ if (module_id >= LOGGING_MAX_MODULES) {
+ printf("Invalid VIPERCELL MODULE specified\n");
+ return(FALSE);
+ }
+ if (viperlog->module_filters[module_id] & severity_level) {
+ return(TRUE);
+ }
+ else {
+ return(FALSE);
+ }
+}
+
+
+/*
+ * viperlog_display_filter_info
+ */
+void
+viperlog_display_filter_info(short filter_value)
+{
+ char display_enabled_buffer[2048],
+ display_disabled_buffer[2048];
+
+ memset(display_enabled_buffer,0,2048);
+ memset(display_disabled_buffer,0,2048);
+
+ strcpy(display_enabled_buffer ,"ENABLED :-");
+ strcpy(display_disabled_buffer,"DISABLED :-");
+
+ if (filter_value & LOG_TO_CONSOLE_MASK) {
+ strcat(display_enabled_buffer,"Console Logging ");
+ }
+ else strcat(display_disabled_buffer,"Console Logging ");
+
+ if (filter_value & LOG_TO_NETWORK_MASK) {
+ strcat(display_enabled_buffer,"Network Logging ");
+ }
+ else strcat(display_disabled_buffer,"Network Logging ");
+
+ if (filter_value & LOG_TO_FILE_MASK) {
+ strcat(display_enabled_buffer,"File Logging ");
+ }
+ else strcat(display_disabled_buffer,"File Logging ");
+
+ if (filter_value & LOG_CONTROL_TRACE_MASK) {
+ strcat(display_enabled_buffer,"Function Tracing ");
+ }
+ else strcat(display_disabled_buffer,"Function Tracing ");
+
+ if (filter_value & LOG_CALL_TRACE_MASK) {
+ strcat(display_enabled_buffer,"Call Traces ");
+ }
+ else strcat(display_disabled_buffer,"Call Traces ");
+
+ if (filter_value & LOG_INFORMATIONAL_MASK) {
+ strcat(display_enabled_buffer,"Traces ");
+ }
+ else strcat(display_disabled_buffer,"Traces ");
+
+ if (filter_value & LOG_WARNINGS_MASK) {
+ strcat(display_enabled_buffer,"Warnings ");
+ }
+ else strcat(display_disabled_buffer,"Warnings ");
+
+ if (filter_value & LOG_ERRORS_MASK) {
+ strcat(display_enabled_buffer,"Errors ");
+ }
+ else strcat(display_disabled_buffer,"Errors ");
+
+ if (filter_value & LOG_TIMESTAMPS) {
+ strcat(display_enabled_buffer,"Timestamps ");
+ }
+ else strcat(display_disabled_buffer,"Timestamps ");
+
+ if (strlen(display_enabled_buffer) == strlen("ENABLED :-")){
+ strcat(display_enabled_buffer," None ");
+ }
+
+ if (strlen(display_disabled_buffer) == strlen("DISABLED :-")) {
+ strcat(display_disabled_buffer," None ");
+ }
+ printf("%s\n",display_enabled_buffer);
+ printf("%s\n",display_disabled_buffer);
+}
+
+
+/*
+ * viperlog_get_output_device
+ */
+void
+viperlog_get_output_device(int module_id,BOOL *output_file,BOOL *output_console,BOOL *output_network)
+{
+ if (module_id >= LOGGING_MAX_MODULES) {
+ printf("Invalid VIPERCELL MODULE specified\n");
+ return;
+ }
+ if (viperlog->module_filters[module_id] & LOG_TO_CONSOLE_MASK) {
+ *output_console = TRUE;
+ }
+
+ if (viperlog->module_filters[module_id] & LOG_TO_NETWORK_MASK) {
+ *output_network = TRUE;
+ }
+ if (viperlog->module_filters[module_id] & LOG_TO_FILE_MASK) {
+ *output_file = TRUE;
+ }
+ return;
+}
+
+
+
+/*
+ * viperlog_get_network_broadcast_addr
+ */
+char *
+viperlog_get_network_broadcast_addr()
+{
+ static char addr_buff[128],interface_name[128];
+ int status;
+
+ memset(addr_buff,0,128);
+ memset(interface_name,0,128);
+
+ strcpy(interface_name,VIPERLOG_HOST_ETHERNET_INTERFACE);
+ status = ifBroadcastGet(interface_name,addr_buff);
+ if (status == ERROR)
+ {
+ printf("Error retrieving interface %s's broadcast address!\n",interface_name);
+ return ("");
+ }
+
+ return(addr_buff);
+}
+
+
+/*
+ * viperlog_get_severity_name
+ */
+char *
+viperlog_get_severity_name(VIPERLOG_SEVERITY severity)
+{
+ static char severity_str[64];
+
+ switch(severity){
+ case LOG_SEVERITY_FUNCTION_TRACE:strcpy(severity_str,"Function Trace" );break;
+ case LOG_SEVERITY_TRACE :strcpy(severity_str,"Trace" );break;
+ case LOG_SEVERITY_CALL_TRACE :strcpy(severity_str,"Call Trace" );break;
+ case LOG_SEVERITY_WARNING :strcpy(severity_str,"Warning" );break;
+ case LOG_SEVERITY_ERROR :strcpy(severity_str,"Error" );break;
+ default :strcpy(severity_str,"Unknown severity");break;
+ }
+
+ return (severity_str);
+}
+
+
+/*
+ * viperlog_get_module_name
+ */
+char *
+viperlog_get_module_name(LOGGING_MODULE_ID id)
+{
+ return(GetLogModuleName(id));
+}
+
+
+/*
+ * viperlog_send_net_msg
+ */
+void
+viperlog_send_net_msg(char *msg_buff)
+{
+ if (!viperlog->log_socket_opened) {
+ return;
+ }
+
+ int msg_size,gap;
+
+ msg_size = strlen(msg_buff);
+
+ msg_size = (msg_size <= VIPERLOG_MAX_NET_PKT_SIZE) ? msg_size : VIPERLOG_MAX_NET_PKT_SIZE;
+
+ /*
+ * We just accumulate as much log data as we can squeeze
+ * into the single largest packet on ethernet, then out it
+ * goes....simple state info retained in the config struct
+ * allows us to keep accumulating data
+ */
+
+ if (viperlog->net_buff_index == 0)
+ {
+ strcpy(viperlog->net_packet,msg_buff);
+ viperlog->net_buff_index = strlen(msg_buff);
+ }
+ else
+ {
+ gap = VIPERLOG_MAX_NET_PKT_SIZE - viperlog->net_buff_index;
+
+ if (gap > msg_size)
+ {
+ strcat(viperlog->net_packet,msg_buff);
+ viperlog->net_buff_index += msg_size;
+ }
+ else
+ {
+ /* We have to flush data to copy the latest arrival */
+ if (sendto(viperlog->log_socket, (char *)viperlog->net_packet,
+ viperlog->net_buff_index, 0,
+ (struct sockaddr *) &viperlog->dest_address,sizeof(struct sockaddr_in)) == ERROR){
+ perror ("sendto");
+ }
+ strcpy(viperlog->net_packet,msg_buff);
+ viperlog->net_buff_index = strlen(msg_buff);
+ }
+ }
+
+ return;
+}
+
+
+/*
+ **************************************************************************
+ * Functions which are externally called (from Shell,etc)
+ **************************************************************************
+ */
+
+/*
+ * ViperLogHelp
+ */
+extern "C" void
+ViperLogHelp()
+{
+ printf("\n******************************************************************************************");
+ printf("\n VIPERLOG HELP");
+ printf("\n******************************************************************************************");
+ printf("\nViperLogSetModuleFilters(moduleId,severityMask): Sets the specified severityMask filter");
+ printf("\n for the specified moduleId");
+ printf("\nViperLogShowModuleFilters(moduleId) : Displays the log filters for moduleId");
+ printf("\nViperLogShowAllFilters() : Displays the log filters for all modules");
+ printf("\nViperLogSetDestAddress(ipAddrStr) : Sets the destination address for logging");
+ printf("\nViperLogSetDestPort(portNo) : Sets the destination port for logging");
+ printf("\nViperLogShowLogModules() : Displays all the log modules & their ids");
+ printf("\nViperLogShowCount() : Displays no of log packets sent so far");
+ printf("\nViperLogSetConsolePrintOptions(BOOL On) : If on displays all information; otherwise");
+ printf("\n displays only message (default)");
+ printf("\nViperLogShowSeverityMask() : Shows the bitmap for severity values");
+ printf("\n******************************************************************************************");
+}
+
+
+/*
+ * ViperLogSetModuleFilters
+ */
+extern "C" void
+ViperLogSetModuleFilters(int module_id,short severity_level)
+{
+ int count;
+ if (module_id == VIPERLOG_ALL_MODULES) {
+ for(count=0;count<LOGGING_MAX_MODULES;count++) {
+ viperlog->module_filters[count] = severity_level;
+ }
+ printf("For ALL MODULES:\n");
+ viperlog_display_filter_info(severity_level);
+ }
+ else {
+ if (module_id >= LOGGING_MAX_MODULES) {
+ printf("Invalid module id specified!\n");
+ return;
+ }
+ viperlog->module_filters[module_id] = severity_level;
+ printf("For MODULE ID %s:\n",viperlog_get_module_name((LOGGING_MODULE_ID)module_id));
+ viperlog_display_filter_info(severity_level);
+ }
+}
+
+
+/*
+ * ViperLogSetGroupFilters
+ */
+extern "C" void
+ViperLogSetGroupFilters(int module_id_begin,int module_id_end,short severity_level)
+{
+ int count;
+ if (module_id_end == VIPERLOG_ALL_MODULES) {
+ for(count=0;count<LOGGING_MAX_MODULES;count++) {
+ viperlog->module_filters[count] = severity_level;
+ }
+ printf("For ALL MODULES:\n");
+ viperlog_display_filter_info(severity_level);
+ }
+ else {
+ if (module_id_begin >= LOGGING_MAX_MODULES) {
+ printf("Invalid module id specified!\n");
+ return;
+ }
+ printf("For MODULE IDs :-\n");
+ for(count=module_id_begin;count<module_id_end;count++) {
+ viperlog->module_filters[count] = severity_level;
+ printf(" %s ",viperlog_get_module_name((LOGGING_MODULE_ID)count));
+ }
+ printf("Logging Filters are set as \n ");
+ viperlog_display_filter_info(severity_level);
+ }
+}
+
+
+/*
+ * ViperLogSetConsolePrintOptions
+ */
+extern "C" void
+ViperLogSetConsolePrintOptions(BOOL ConsolePrintFormatted)
+{
+ if (ConsolePrintFormatted) {
+ printf("Turned ON formatting+additional info for console output of logging\n");
+ viperlog->console_output_detailed = TRUE;
+ }
+ else {
+ printf("Turned OFF formatting+additional info for console output of logging\n");
+ viperlog->console_output_detailed = FALSE;
+ }
+}
+
+
+
+
+/*
+ * ViperLogShowModuleFilters
+ */
+extern "C" void
+ViperLogShowModuleFilters(int module_id)
+{
+ int filter_value = 0;
+ filter_value = viperlog->module_filters[module_id];
+ printf("For MODULE ID %s:\n",viperlog_get_module_name((LOGGING_MODULE_ID)module_id));
+ viperlog_display_filter_info(filter_value);
+}
+
+
+/*
+ * ViperLogSetDestPort
+ */
+void
+ViperLogSetDestPort(int port_no)
+{
+ char ip_addr_str[25];
+ memset(ip_addr_str,0,25);
+ viperlog->dest_address.sin_port = htons(port_no);
+ inet_ntoa_b(viperlog->dest_address.sin_addr,ip_addr_str);
+ printf("Log address now set to %s, port %d\n",ip_addr_str,port_no);
+}
+
+
+/*
+ * ViperLogSetDestAddress
+ */
+void
+ViperLogSetDestAddress(char *ip_address)
+{
+ char ip_addr_str[25];
+ memset(ip_addr_str,0,25);
+ viperlog->dest_address.sin_addr.s_addr = inet_addr(ip_address);
+ inet_ntoa_b(viperlog->dest_address.sin_addr,ip_addr_str);
+ printf("Log address now set to %s, port %d\n",ip_addr_str,
+ ntohs(viperlog->dest_address.sin_port));
+}
+
+
+/*
+ * ViperLogShowSeverityMask
+ */
+extern "C" void
+ViperLogShowSeverityMask()
+{
+ printf("\n***************************************************************************************\n");
+ printf(" Bit mask for log options values\n");
+ printf(" |----|----|----|----|----|----|---|---|---|---|---|---|---|---|---|---|\n");
+ printf(" | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |\n");
+ printf(" |----|----|----|----|----|----|---|---|---|---|---|---|---|---|---|---|\n");
+ printf("\n");
+ printf(" ------------------------------\n");
+ printf(" Bit no | Meaning\n");
+ printf(" -----------------------------\n");
+ printf(" 0 : If set, indicates log to console enabled\n");
+ printf(" 1 : If set, indicates log to network enabled\n");
+ printf(" 2 : If set, indicates log to file enabled\n");
+ printf(" 3 : If set, indicates function tracing required\n");
+ printf(" 4 : If set, indicates call tracing required\n");
+ printf(" 5 : If set, indicates logging of informational messages required\n");
+ printf(" 6 : If set, indicates logging of warnings required\n");
+ printf(" 7 : if set, indicates logging of errors required\n");
+ printf(" 8 : if set, indicates use of timestamps\n");
+ printf(" 9-15 : reserved; unused for now\n");
+ printf("***************************************************************************************\n");
+
+}
+
+
+#define DISPLAY_MODULE_NAME_OFFSET 2
+#define DISPLAY_MODULE_ID_OFFSET 27
+#define DISPLAY_MODULE_INFO_LENGTH 40
+
+/*
+ * ViperLogShowLogModules
+ */
+extern "C" void
+ViperLogShowLogModules()
+{
+ int count,index;
+ char moduleName[128];
+ char displayBuffer[256];
+
+ printf("\nThe following modules are using ViperLog");
+ printf("\n************************************************");
+
+ memset(displayBuffer,0,256);
+ strcpy(&displayBuffer[DISPLAY_MODULE_NAME_OFFSET],"MODULE NAME");
+ strcpy(&displayBuffer[DISPLAY_MODULE_ID_OFFSET],"MODULE ID");
+ for(index=0;index<DISPLAY_MODULE_INFO_LENGTH;index++)
+ if (displayBuffer[index] == 0) displayBuffer[index]= 32;
+ displayBuffer[DISPLAY_MODULE_INFO_LENGTH-1] = 0;
+ printf("\n%s",displayBuffer);
+
+
+ printf("\n************************************************");
+ for(count=0;count<LOGGING_MAX_MODULES;count++) {
+ memset(moduleName,0,128);
+ strcpy(moduleName,viperlog_get_module_name((LOGGING_MODULE_ID)count));
+ if (strstr(moduleName,"UNKNOWN") != NULL) continue;
+ else {
+ memset(displayBuffer,0,256);
+ sprintf(&displayBuffer[DISPLAY_MODULE_NAME_OFFSET],"%s",moduleName);
+ sprintf(&displayBuffer[DISPLAY_MODULE_ID_OFFSET],"%d",count);
+ for(index=0;index<DISPLAY_MODULE_INFO_LENGTH;index++)
+ if (displayBuffer[index] == 0) displayBuffer[index]= 32;
+ displayBuffer[DISPLAY_MODULE_INFO_LENGTH-1] = 0;
+ printf("\n%s",displayBuffer);
+ }
+ }
+ printf("\n************************************************\n");
+}
+
+
+/*
+ * ViperLogShowAllFilters
+ */
+void
+ViperLogShowAllFilters()
+{
+ int count;
+ char moduleName[128];
+ printf("\n************************************************");
+ for(count=0;count<LOGGING_MAX_MODULES;count++) {
+ memset(moduleName,0,128);
+ strcpy(moduleName,viperlog_get_module_name((LOGGING_MODULE_ID)count));
+ if (strcmp(moduleName,"UNKNOWN_LAYER") == 0) continue;
+ else {
+ ViperLogShowModuleFilters((LOGGING_MODULE_ID)count);
+ printf("\n************************************************");
+ }
+ }
+}
+
+
+/*
+ **************************************************************************
+ * DbgOutput class member functions
+ **************************************************************************
+ */
+
+
+/*
+ * DbgOutput::Enter
+ */
+void
+DbgOutput::Enter()
+{
+ if (viperlog==NULL) return;
+ if (viperlog_check_module_filter(m_log_packet.module_id,LOG_SEVERITY_FUNCTION_TRACE) == TRUE) {
+ PreparePacket(LOG_SEVERITY_FUNCTION_TRACE);
+ sprintf(m_log_packet.message,"Entering function %s",m_log_packet.function_name);
+ msgQSend(viperlog->msg_q_id,(char *)&m_log_packet,sizeof(m_log_packet),NO_WAIT,MSG_PRI_NORMAL);
+ }
+}
+
+
+/*
+ * DbgOutput::Leave
+ */
+void
+DbgOutput::Leave()
+{
+ if (viperlog==NULL) return;
+ if (viperlog_check_module_filter(m_log_packet.module_id,LOG_SEVERITY_FUNCTION_TRACE) == TRUE) {
+ PreparePacket(LOG_SEVERITY_FUNCTION_TRACE);
+ sprintf(m_log_packet.message,"Leaving function %s",m_log_packet.function_name);
+ msgQSend(viperlog->msg_q_id,(char *)&m_log_packet,sizeof(m_log_packet),NO_WAIT,MSG_PRI_NORMAL);
+ }
+}
+
+
+/*
+ * DbgOutput::Trace
+ */
+void
+DbgOutput::Trace(char *format,...)
+{
+ if (viperlog==NULL) return;
+
+ if (viperlog_check_module_filter(m_log_packet.module_id,LOG_SEVERITY_TRACE) == TRUE) {
+ PreparePacket(LOG_SEVERITY_TRACE);
+ va_list argument_list;
+ va_start(argument_list,format);
+ vsprintf(m_log_packet.message,format,argument_list);
+ va_end(argument_list);
+ msgQSend(viperlog->msg_q_id,(char *)&m_log_packet,sizeof(m_log_packet),NO_WAIT,MSG_PRI_NORMAL);
+ }
+}
+
+
+/*
+ * DbgOutput::Warning
+ */
+void
+DbgOutput::Warning(char *format,...)
+{
+ if (viperlog==NULL) return;
+
+ if (viperlog_check_module_filter(m_log_packet.module_id,LOG_SEVERITY_WARNING) == TRUE) {
+ PreparePacket(LOG_SEVERITY_WARNING);
+ va_list argument_list;
+ va_start(argument_list,format);
+ vsprintf(m_log_packet.message,format,argument_list);
+ va_end(argument_list);
+ msgQSend(viperlog->msg_q_id,(char *)&m_log_packet,sizeof(m_log_packet),NO_WAIT,MSG_PRI_NORMAL);
+ }
+}
+
+
+/*
+ * DbgOutput::Error
+ */
+void
+DbgOutput::Error(char *format,...)
+{
+ if (viperlog==NULL) return;
+
+ if (viperlog_check_module_filter(m_log_packet.module_id,LOG_SEVERITY_ERROR) == TRUE)
+ {
+ PreparePacket(LOG_SEVERITY_ERROR);
+ va_list argument_list;
+ va_start(argument_list,format);
+ vsprintf(m_log_packet.message,format,argument_list);
+ va_end(argument_list);
+ msgQSend(viperlog->msg_q_id,(char *)&m_log_packet,sizeof(m_log_packet),NO_WAIT,MSG_PRI_NORMAL);
+ }
+}
+
+
+/*
+ * DbgOutput::CallTrace
+ */
+void
+DbgOutput::CallTrace(unsigned long call_id,char *format,...)
+{
+ if (viperlog==NULL) return;
+
+ if (viperlog_check_module_filter(m_log_packet.module_id,LOG_SEVERITY_CALL_TRACE) == TRUE)
+ {
+ PreparePacket (LOG_SEVERITY_CALL_TRACE);
+ va_list argument_list;
+ va_start (argument_list, format);
+ vsprintf (m_log_packet.message , format,argument_list);
+ va_end (argument_list);
+ m_log_packet.call_id = call_id;
+ msgQSend (viperlog->msg_q_id,(char *)&m_log_packet,sizeof(m_log_packet),NO_WAIT,MSG_PRI_NORMAL);
+ }
+}
+
+
+/*
+ * DbgOutput::HexDump
+ */
+void
+DbgOutput::HexDump (unsigned char *pSrc, int byteCount, bool bFormat)
+{
+ if (viperlog == NULL || byteCount <= 0) return;
+
+ if (viperlog_check_module_filter (m_log_packet.module_id, LOG_SEVERITY_TRACE) == TRUE)
+ {
+ int tmpCount = byteCount;
+ unsigned char *pData = pSrc ;
+
+ PreparePacket (LOG_SEVERITY_TRACE, byteCount, bFormat);
+
+ while (tmpCount > 0)
+ { // take care of overflow
+ m_log_packet.binary_length = (tmpCount < VIPERLOG_MAX_DEBUG_MSG_LEN)
+ ? tmpCount : VIPERLOG_MAX_DEBUG_MSG_LEN;
+
+ memcpy (m_log_packet.message, pData, m_log_packet.binary_length);
+
+ msgQSend (viperlog->msg_q_id ,
+ (char *)&m_log_packet ,
+ sizeof(m_log_packet) ,
+ NO_WAIT, MSG_PRI_NORMAL);
+
+ tmpCount -= VIPERLOG_MAX_DEBUG_MSG_LEN;
+ pData += VIPERLOG_MAX_DEBUG_MSG_LEN;
+ }
+ }
+}
+
+
+/*
+ * DbgOutput::PreparePacket
+ */
+void
+DbgOutput::PreparePacket (short severity_level, int binLength, bool bFormat)
+{
+ m_log_packet.severity_level = severity_level ;
+ m_log_packet.magic = VIPERLOG_MSG_MAGIC_NO ;
+ m_log_packet.timestamp = sysTimestamp () ;
+ m_log_packet.tick_count = tickGet () ;
+ m_log_packet.call_id = VIPERLOG_NULL_CALL_ID ;
+ m_log_packet.binary_length = binLength ;
+ m_log_packet.data_type = (!binLength) ? LOG_ASCII // ASCII
+ : (bFormat ) ? LOG_FORMAT_BINARY // Formatted HEX
+ : LOG_PLAIN_BINARY ; // Plain HEX
+}
+
diff --git a/data/mnet/Common/netBuffer/Makefile b/data/mnet/Common/netBuffer/Makefile
new file mode 100644
index 0000000..085621b
--- /dev/null
+++ b/data/mnet/Common/netBuffer/Makefile
@@ -0,0 +1,34 @@
+##########################################################
+#
+# (c) Copyright Cisco 2000
+# All Rights Reserved
+#
+# Use Examples:
+#
+# Case 1: make all VOB=GS -
+# Places .out in VOB/bin directory
+#
+# Case 2: make all VOB=GS APPDIR=Host\netBuffer\bin -
+# Places .o file(s) in VOB/$(APPDIR) directory.
+#
+# Note: This make file must reference a VOB that
+# has a defs.mk in the top level directory.
+#
+##########################################################
+
+SUBDIRS = src
+
+# TOP_OF_VOB must be defined before including l3defs.mk
+TOP_OF_VOB = ..
+
+VOBDIR = $(TOP_OF_VOB)/../$(VOB)
+
+# Allows a sub-set of the source code directories to be used
+
+ifneq ($(REPLACE),)
+ SUBDIRS = $(REPLACE)
+endif
+
+include $(VOBDIR)\l3defs.mk
+
+
diff --git a/data/mnet/Common/netBuffer/src/Makefile b/data/mnet/Common/netBuffer/src/Makefile
new file mode 100644
index 0000000..1c1a8f7
--- /dev/null
+++ b/data/mnet/Common/netBuffer/src/Makefile
@@ -0,0 +1,61 @@
+##########################################################
+#
+# (c) Copyright Cisco 2000
+# All Rights Reserved
+#
+# Use Examples:
+#
+# Case 1:
+# make all VOB=GS -
+# Places .out in VOB/bin directory
+#
+# Case 2:
+# make all VOB=GS APPDIR=Host\<Application Name>\<Source Directory> -
+# Places .o file(s) in VOB\$(APPDIR)\bin directory.
+#
+# <Application Name> = Name of Application directory
+# <Source Directory> = application sub directory where the calling
+# Makefile resides.
+#
+# Example: make all VOB=GS APPDIR=Host\netBuffer\src
+#
+#
+# Note: This make file must reference a VOB that
+# has a defs.mk in the top level directory.
+#
+##########################################################
+
+# TOP_OF_VOB must be defined before including l3defs.mk
+TOP_OF_VOB = ..\..
+
+# Name of this App's Directory
+THIS_APP_DIR = netBuffer
+
+VOB2DIR = $(TOP_OF_VOB)\..\$(VOB)
+BINDIR = ..\bin
+
+ifeq ($(APPDIR),)
+ MY_OUTPUT = $(VOB2DIR)\bin\(THIS_APP_DIR)_com.out
+else
+ MY_OUTPUT = $(OBJDIR)\$(THIS_APP_DIR)_com.out
+endif
+
+include $(VOB2DIR)\l3defs.mk
+
+
+all: $(MY_OUTPUT)
+
+$(MY_OUTPUT): $(MODULE_OBJS)
+ $(LD) -r -o $@.tmp $(MODULE_OBJS)
+ $(NM) $@.tmp | munch > _ctdt.c
+ $(CC) -traditional $(CC_ARCH_SPEC) -c _ctdt.c
+ $(LD) -r -o $@ _ctdt.o $@.tmp
+ $(RM)$(subst /,$(DIRCHAR), _ctdt.c _ctdt.o $@.tmp)
+
+cleanall:
+ @for %f in ($(notdir $(MODULE_OBJS))) do \
+ $(RM) ..\bin\%f
+
+ $(RM) $(MY_OUTPUT)
+
+
diff --git a/data/mnet/Common/netBuffer/src/NetBuffer.cpp b/data/mnet/Common/netBuffer/src/NetBuffer.cpp
new file mode 100644
index 0000000..2cbd45f
--- /dev/null
+++ b/data/mnet/Common/netBuffer/src/NetBuffer.cpp
@@ -0,0 +1,407 @@
+// *******************************************************************
+//
+// (c) Copyright CISCO Systems, 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// Status : Under development
+// File : NetBuffer.cpp
+// Author(s) : Igal Gutkin
+// Create Date : 12/29/00
+// Description : NetBuffer class implementation. Utilisation of the
+// buffering using m-Block concept.
+//
+// *******************************************************************
+
+
+#include "NetBuffer.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <usrLib.h>
+
+extern "C" void netPoolShow (NET_POOL_ID pNetPool);
+
+#include "bufConfig.h"
+
+
+//===================================================================
+// Static Data members definition
+//===================================================================
+
+NetBuffer *NetBuffer::pNetBuff_ = NULL;
+unsigned NetBuffer::poolNum_ = 0 ;
+
+
+M_CL_CONFIG NetBuffer::mClBlkConfig_ =
+{
+/* mBlkNum clBlkNum memArea memsize */
+/* ------- ---------- ---------- ---------- */
+ CALC_VALUE, CALC_VALUE, CALC_VALUE, CALC_VALUE
+};
+
+
+
+//===================================================================
+// Constructors & Destractor
+//===================================================================
+
+NetBuffer::NetBuffer ()
+ :pNetPool_ (NULL),
+ mutex ()
+{
+ int index = 0;
+ int clDescTblNumEnt ;
+
+ mutex.take ();
+
+ // allocate memory for mBlk and clBlk pools
+ if ((mClBlkConfig_.memArea=(char *)malloc(mClBlkConfig_.memSize)) == NULL)
+ {
+ printf ("FATAL ERROR (netPoolInit):Unable to allocate memory for block pools\n");
+ printErrno (0);
+ return;
+ }
+
+ // allocate memory for cluster pools
+ for (index = 0; index < poolNum_; ++index)
+ {
+ if ((clDescTbl_[index].memArea=(char *)malloc(clDescTbl_[index].memSize)) == NULL)
+ {
+ printf ("FATAL ERROR (netPoolInit):Unable to allocate memory for memory cluster pools\n");
+ printErrno (0);
+ return;
+ }
+ }
+
+ clDescTblNumEnt = NELEMENTS(clDescTbl_);
+
+ pNetPool_ = &netPool_;
+
+ if (netPoolInit (pNetPool_, &mClBlkConfig_, &clDescTbl_[0], clDescTblNumEnt, NULL) != OK)
+ {
+ printf ("FATAL ERROR (netPoolInit): Unable to initialize buffer pool.\n");
+ printErrno (0);
+ }
+
+ mutex.give();
+}
+
+
+NetBuffer::~NetBuffer ()
+{
+ int index ;
+
+ /* delete network pool */
+ if (netPoolDelete (pNetPool_) != OK)
+ {
+ printErrno (0);
+ }
+
+ /* release allocated memory */
+
+ // mBlk and clBlk pools
+ if (mClBlkConfig_.memArea)
+ {
+ free (mClBlkConfig_.memArea);
+ }
+
+ // cluster pools
+ for (index = 0; index < poolNum_; ++index)
+ {
+ if (clDescTbl_[index].memArea)
+ free (clDescTbl_[index].memArea);
+ }
+}
+
+
+//===================================================================
+// primary behavioural methods
+//===================================================================
+
+NetBuffer *NetBuffer::getInstance()
+{
+ return ((pNetBuff_) ? pNetBuff_ : init());
+}
+
+
+void NetBuffer::release ()
+{
+ if (pNetBuff_)
+ {
+ delete pNetBuff_;
+ pNetBuff_ = NULL;
+ poolNum_ = 0 ;
+ }
+}
+
+
+// allocate mBlk->clBlk->cluster from the pool
+// returns zero on error
+unsigned NetBuffer::getBuffer (unsigned bufSize, BUFFER_ID& pMBlk)
+{
+ unsigned retVal = 0;
+
+ if (isInit ())
+ {
+ // M_BLK_ID netTupleGet (
+ // NET_POOL_ID pNetPool, /* pointer to the net pool */
+ // int bufSize , /* size of the buffer to get */
+ // int canWait , /* wait or dontwait */
+ // UCHAR type, , /* type of data */
+ // BOOL bestFit ) /* TRUE/FALSE */
+
+ mutex.take ();
+ retVal = ((pMBlk=netTupleGet(pNetPool_,bufSize,M_DONTWAIT,MT_DATA,FALSE)) != NULL)
+ ? pMBlk->pClBlk->clSize
+ : 0 ;
+ mutex.give ();
+
+#ifdef __STDIOUT
+ if (retVal)
+ printf ("Buffers: allocated new block: ID %p, Pool ID %p, Ref.Count %u\n",
+ pMBlk, pMBlk->pClBlk->pNetPool, pMBlk->pClBlk->clRefCnt);
+#endif //__STDIOUT
+ }
+ else
+ pMBlk = NULL;
+
+ return (retVal);
+}
+
+
+unsigned NetBuffer::getBufferSize (BUFFER_ID pSrc)
+{
+ unsigned retVal = 0;
+
+ if (isValidBuffer(pSrc))
+ retVal = pSrc->pClBlk->clSize;
+
+ return (retVal);
+}
+
+
+bool NetBuffer::duplicateBuffer (BUFFER_ID pSrc, BUFFER_ID& pDest)
+{
+ bool retVal = false;
+
+ if (isValidBuffer (pSrc))
+ {
+ pDest = netMblkGet(pNetPool_,M_WAIT,pDest->mBlkHdr.mType);
+
+ // allocate new mBlock
+ if (pDest != NULL)
+ {
+ mutex.take ();
+ retVal = ((pDest=netMblkDup(pSrc, pDest)) != NULL);
+ mutex.give ();
+
+#ifdef __STDIOUT
+ if (retVal)
+ printf ("Buffers: allocated duplicated block: ID %p, Pool ID %p, Ref.Count %u\n",
+ pDest, pDest->pClBlk->pNetPool, pDest->pClBlk->clRefCnt);
+#endif // __STDIOUT
+ }
+ }
+ else
+ pDest = NULL;
+
+ return (retVal);
+}
+
+
+bool NetBuffer::freeBuffer (BUFFER_ID pMblk)
+{
+ bool retVal = false;
+
+ if (isValidBuffer(pMblk))
+ {
+#ifdef __STDIOUT
+ printf ("Buffers: releasing buffer ID %p, Pool ID %p, Ref.Count %u\n",
+ pMblk, pMblk->pClBlk->pNetPool, pMblk->pClBlk->clRefCnt);
+#endif // __STDIOUT
+
+ mutex.take ();
+ netMblkClFree (pMblk);
+ mutex.give ();
+ retVal = true;
+ }
+
+ return (retVal);
+}
+
+
+// Return pointer to the data and the data length
+// Returns NULL on error
+char *NetBuffer::getDataPtr (BUFFER_ID pMblk, unsigned& dataLen)
+{
+ char * pRetVal = NULL;
+
+ if (isValidBuffer (pMblk))
+ {
+ dataLen = pMblk->mBlkHdr.mLen ;
+ pRetVal = pMblk->mBlkHdr.mData;
+ }
+ else
+ dataLen = 0;
+
+ return (pRetVal);
+}
+
+
+bool NetBuffer::getDataSize (BUFFER_ID pMblk, unsigned& dataLen)
+{
+ bool retVal = false;
+
+ if (isValidBuffer (pMblk))
+ {
+ dataLen = pMblk->mBlkHdr.mLen ;
+ retVal = true;
+ }
+ else
+ dataLen = 0;
+
+ return (retVal);
+}
+
+
+bool NetBuffer::setDataSize (BUFFER_ID pMblk, unsigned dataLen)
+{
+ bool retVal = false;
+
+ if (isValidBuffer(pMblk))
+ {
+#ifdef __STDIOUT
+ printf ("Buffers: set size: Block ID %p, Pool ID %p, Cluster size %u, Data size %u\n",
+ pMblk, pMblk->pClBlk->pNetPool, pMblk->pClBlk->clSize, dataLen);
+#endif //__STDIOUT
+
+ pMblk->mBlkHdr.mLen = dataLen;
+ retVal = true;
+ }
+
+ return (retVal);
+}
+
+
+// Copy data from the user buffer to the memory cluster
+// If the data length > than the cluster size, returns false. Data is not copied
+bool NetBuffer::setData (BUFFER_ID pMblk, unsigned dataLen, char *pBuff)
+{
+ bool retVal = false;
+
+ if (isValidBuffer (pMblk) &&
+ dataLen <= pMblk->pClBlk->clSize )
+ {
+#ifdef __STDIOUT
+ printf ("Buffers: set size: Block ID %p, Pool ID %p, Cluster size %u Data size %u\n",
+ pMblk, pMblk->pClBlk->pNetPool, pMblk->pClBlk->clSize, dataLen);
+#endif //__STDIOUT
+
+ memcpy (pMblk->mBlkHdr.mData, pBuff, dataLen);
+ pMblk->mBlkHdr.mLen = dataLen ;
+ retVal = true ;
+ }
+
+ return (retVal);
+}
+
+
+// Copy data from the memory cluster to the user buffer
+// If the user buffer is smaller than the actual size of the received data,
+// only part of the data is copied, the actual size of the data is returned using dataLen
+// and returns false.
+bool NetBuffer::getData (BUFFER_ID pMblk, unsigned& dataLen, char *pBuff, unsigned maxLen)
+{
+ bool retVal = false;
+ unsigned tmpLen ;
+
+ if (isValidBuffer (pMblk))
+ {
+ if (retVal = (pMblk->mBlkHdr.mLen <= maxLen))
+ {
+ dataLen = netMblkToBufCopy (pMblk, pBuff, NULL);
+ }
+ else
+ {
+ memcpy (pBuff, pMblk->mBlkHdr.mData, maxLen);
+ dataLen = pMblk->mBlkHdr.mLen ;
+ }
+ }
+
+ return (retVal);
+}
+
+
+void NetBuffer::printInfo ()
+{
+ if (isInit ())
+ {
+ netPoolShow (getInstance()->pNetPool_);
+ }
+ else
+ printf ("NetBuffer subsystem is not initialized\n");
+}
+
+//===================================================================
+// private methods
+//===================================================================
+
+NetBuffer *NetBuffer::init ()
+{
+ int index = 0;
+ unsigned uNum = 0;
+
+ if (!pNetBuff_)
+ {
+ poolNum_ = NELEMENTS(clDescTbl_);
+
+ // Calculate the total number of required clBlks
+ for (index = 0; index < poolNum_; ++index)
+ {
+ uNum += clDescTbl_[index].clNum;
+ }
+
+ mClBlkConfig_.clBlkNum = uNum;
+
+ uNum = NETBUFF_M_BLK_NUM;
+
+ // allocated number of mBlks >= number of clBlks
+ mClBlkConfig_.mBlkNum = (uNum >= mClBlkConfig_.clBlkNum) ? uNum : mClBlkConfig_.clBlkNum;
+
+ // calculate pool size according to the required number of mBlks and clBlks
+ mClBlkConfig_.memSize = (mClBlkConfig_.mBlkNum * (M_BLK_SZ + sizeof(long)))
+ + mClBlkConfig_.clBlkNum * CL_BLK_SZ;
+
+#ifdef __STDIOUT
+ printf ("Buffers: allocate %u mBlocks, %u Cluster Blocks (ratio %.2f), %u pools\n",
+ mClBlkConfig_.mBlkNum, mClBlkConfig_.clBlkNum,
+ ((double)(mClBlkConfig_.mBlkNum))/mClBlkConfig_.clBlkNum, poolNum_);
+#endif //__STDIOUT
+
+ // calculate memory size for the pool of clusters
+ for (index = 0; index < poolNum_; ++index)
+ {
+ clDescTbl_[index].memSize = (clDescTbl_[index].clNum * (clDescTbl_[index].clSize + sizeof(long)));
+ }
+
+ pNetBuff_ = new NetBuffer;
+ }
+
+ return (pNetBuff_);
+}
+
+
+//===================================================================
+// Shell accessible methods
+//===================================================================
+
+void netBufPrintInfo (void)
+{
+ NetBuffer::printInfo ();
+}
+
diff --git a/data/mnet/Common/rsa/src_stub/makefile b/data/mnet/Common/rsa/src_stub/makefile
new file mode 100644
index 0000000..f100ec5
--- /dev/null
+++ b/data/mnet/Common/rsa/src_stub/makefile
@@ -0,0 +1,61 @@
+##########################################################
+#
+# (c) Copyright Cisco 2000
+# All Rights Reserved
+#
+# Use Examples:
+#
+# Case 1:
+# make all VOB=GP10 -
+# Places .out in VOB/bin directory
+#
+# Case 2:
+# make all VOB=GP10 APPDIR=Host\<Application Name>\<Source Directory> -
+# Places .o file(s) in VOB\$(APPDIR)\bin directory.
+#
+# <Application Name> = Name of Application directory
+# <Source Directory> = application sub directory where the calling
+# Makefile resides.
+#
+# Example: make all VOB=GP10 APPDIR=Host\vxTemplate\src
+#
+#
+# Note: This make file must reference a VOB that
+# has a defs.mk in the top level directory.
+#
+##########################################################
+
+# TOP_OF_VOB must be defined before including l3defs.mk
+TOP_OF_VOB = ..\..
+
+# Name of this App's Directory
+THIS_APP_DIR = rsa
+
+VOB2DIR = $(TOP_OF_VOB)\..\$(VOB)
+BINDIR = ..
+
+ifeq ($(APPDIR),)
+ MY_OUTPUT = $(VOB2DIR)\bin\sslc.out
+else
+ MY_OUTPUT = $(OBJDIR)\ssl_stub.out
+endif
+
+include $(VOB2DIR)\l3defs.mk
+
+
+all: $(MY_OUTPUT)
+
+$(MY_OUTPUT): $(MODULE_OBJS)
+ $(LD) -r -o $@.tmp $(MODULE_OBJS)
+ $(NM) $@.tmp | munch > _ctdt.c
+ $(CC) -traditional $(CC_ARCH_SPEC) -c _ctdt.c
+ $(LD) -r -o $@ _ctdt.o $@.tmp
+ $(RM)$(subst /,$(DIRCHAR), _ctdt.c _ctdt.o $@.tmp)
+
+cleanall:
+ @for %f in ($(notdir $(MODULE_OBJS))) do \
+ $(RM) ..\bin\%f
+
+ $(RM) $(MY_OUTPUT)
+
+
diff --git a/data/mnet/Common/rsa/src_stub/ssl_stub.c b/data/mnet/Common/rsa/src_stub/ssl_stub.c
new file mode 100644
index 0000000..d230440
--- /dev/null
+++ b/data/mnet/Common/rsa/src_stub/ssl_stub.c
@@ -0,0 +1,257 @@
+/* *******************************************************************
+//
+// (c) Copyright Cisco Systems, Inc 2001
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 2.0
+// Status : Under development
+// File : ssl_stub.cpp
+
+// Description : Implementation stub functions SSL
+//
+// *******************************************************************/
+#define FLAT_INC
+#define OPT_32_BIT
+#include "rsa\ssl.h"
+#include "rsa\des.h"
+#include "rsa\x509.h"
+
+int isSSL (void)
+{
+ return (0);
+}
+
+int SSL_library_init (void)
+{
+ return 0;
+}
+
+
+SSL_METHOD *SSLv3_method (void)
+{
+ return (SSL_METHOD *)NULL;
+}
+
+SSL_CTX *SSL_CTX_new (SSL_METHOD *meth)
+{
+ return (SSL_CTX *)NULL;
+}
+
+int SSL_CTX_use_certificate_file (SSL_CTX *ctx, char *file, int type)
+{
+ return 0;
+}
+
+void SSL_CTX_set_default_passwd_cb (SSL_CTX *ctx,int (*cb)())
+{
+}
+
+int SSL_CTX_use_PrivateKey_file (SSL_CTX *ctx, char *file, int type)
+{
+ return 0;
+}
+
+int SSL_CTX_load_verify_locations (SSL_CTX *ctx,char *CAfile,char *CApath)
+{
+ return 0;
+}
+
+void SSL_set_verify_depth (SSL *ssl, int depth)
+{
+ return;
+}
+
+void RAND_seed ( unsigned char *buf,int num)
+{
+ return;
+}
+
+int SSL_CTX_set_cipher_list (SSL_CTX *ctx, char *str)
+{
+ return 0;
+}
+
+int SSL_CTX_set_session_id_context (SSL_CTX *ctx,const unsigned char *sid_ctx,
+ unsigned int sid_ctx_len)
+{
+ return 0;
+}
+
+RSA * RSA_generate_key (int bits, unsigned long e,
+ void (*callback)(int,int,char *),char *cb_arg)
+{
+ return (RSA *)NULL;
+}
+
+long SSL_CTX_ctrl(SSL_CTX *ctx,int cmd, long larg, char *parg)
+{
+ return 0;
+}
+
+
+void RSA_free(RSA *rsa)
+{
+ return;
+}
+
+
+void SSL_CTX_free (SSL_CTX *ctx)
+{
+ return;
+}
+
+
+SSL * SSL_new(SSL_CTX *ctx)
+{
+ return (SSL *) NULL;
+}
+
+int SSL_set_session(SSL *ssl, SSL_SESSION *sess)
+{
+ return 0;
+}
+
+BIO *BIO_new_socket(SIO_SOCK sock, int close_flag)
+{
+ return (BIO *)NULL;
+}
+
+void SSL_set_bio(SSL *ssl, BIO *rbio,BIO *wbio)
+{
+ return;
+}
+
+
+int SSL_shutdown(SSL *ssl)
+{
+ return 0;
+}
+
+int SSL_clear(SSL *s)
+{
+ return 0;
+}
+
+void SSL_free(SSL *ssl)
+{
+ return;
+}
+
+void SSL_set_connect_state(SSL *ssl)
+{
+}
+
+void SSL_set_accept_state(SSL *ssl)
+{
+}
+
+int SSL_set_cipher_list(SSL *ssl, char *str)
+{
+ return 0;
+}
+
+long SSL_get_verify_result(SSL *ssl)
+{
+ return 0;
+}
+
+void SSL_CTX_set_verify(SSL_CTX *ctx,int mode,int (*callback)())
+{
+}
+
+int SSL_connect(SSL *ssl)
+{
+ return 0;
+}
+
+int SSL_get_error(SSL *ssl,int ret_code)
+{
+ return 0;
+}
+
+char * SSL_CIPHER_get_name(SSL_CIPHER *cipher)
+{
+ return (char *)0;
+}
+
+
+int SSL_accept(SSL *ssl)
+{
+ return 0;
+}
+
+int SSL_read(SSL *ssl,char *buffer,int num)
+{
+ return 0;
+}
+
+int SSL_write(SSL *ssl,char *buffer,int num)
+{
+ return 0;
+}
+
+SSL_CIPHER *SSL_get_current_cipher(SSL *ssl)
+{
+ return (SSL_CIPHER *)0;
+}
+
+int des_key_sched(des_cblock *key,des_key_schedule schedule)
+{
+ return 0;
+}
+
+void des_ecb_encrypt (des_cblock *input,des_cblock *output,
+ des_key_schedule ks,int enc)
+{
+ return;
+}
+
+void ERR_print_errors_fp(FILE *fp)
+{
+ return;
+}
+
+X509_NAME * X509_get_subject_name(X509 *x509)
+{
+ return (X509_NAME *) 0;
+}
+
+char *X509_NAME_oneline(X509_NAME *xn,char *buf,int size)
+{
+ return (char *) 0;
+}
+
+int SSL_SESSION_print_fp(FILE *fp, SSL_SESSION *sess)
+{
+ return (0);
+}
+
+SSL_SESSION *SSL_get_session(SSL *ssl)
+{
+ return (NULL);
+}
+
+void SSL_CTX_set_verify_depth (SSL_CTX *ctx, int depth)
+{
+ return;
+}
+
+int SSL_CTX_check_private_key(SSL_CTX *ctx)
+{
+ return (0);
+}
+
+
+void BIO_free_all(BIO *bio)
+{
+ return;
+}
+
+int BIO_free(BIO *bio)
+{
+ return (0);
+}
diff --git a/data/mnet/Common/snmp/Asn1/mnet-traps.mib b/data/mnet/Common/snmp/Asn1/mnet-traps.mib
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/data/mnet/Common/snmp/Asn1/mnet-traps.mib
diff --git a/data/mnet/Common/snmp/Makefile b/data/mnet/Common/snmp/Makefile
new file mode 100644
index 0000000..45ecbc7
--- /dev/null
+++ b/data/mnet/Common/snmp/Makefile
@@ -0,0 +1,47 @@
+##########################################################
+#
+# (c) Copyright Cisco 2000
+# All Rights Reserved
+#
+# Use Examples:
+#
+# Case 1:
+# make all VOB=GP10 -
+# Places .out in VOB/bin directory
+#
+# Case 2:
+# make all VOB=GP10 APPDIR=Host\<Application Name>\<Source Directory> -
+# Places .o file(s) in VOB\$(APPDIR)\bin directory.
+#
+# <Application Name> = Name of Application directory
+# <Source Directory> = application sub directory where the calling
+# Makefile resides.
+#
+# Example: make all VOB=GP10 APPDIR=Host\vxTemplate\src
+#
+# (OPTIONAL) Append REPLACE - Replaces the List of directories
+# to be used in the SUBDIRS variable
+#
+# Example: make all VOB=GP10 APPDIR=Host\vxTemplate\src REPLACE="src_api src_debug"
+#
+# Note: This make file must reference a VOB that
+# has a defs.mk in the top level directory.
+#
+##########################################################
+
+SUBDIRS = src
+
+# TOP_OF_VOB must be defined before including l3defs.mk
+TOP_OF_VOB = ..
+
+VOBDIR = $(TOP_OF_VOB)/../$(VOB)
+
+# Allows a sub-set of the source code directories to be used
+
+ifneq ($(REPLACE),)
+ SUBDIRS = $(REPLACE)
+endif
+
+include $(VOBDIR)\l3defs.mk
+
+
diff --git a/data/mnet/Common/snmp/src/Makefile b/data/mnet/Common/snmp/src/Makefile
new file mode 100644
index 0000000..483efac
--- /dev/null
+++ b/data/mnet/Common/snmp/src/Makefile
@@ -0,0 +1,63 @@
+##########################################################
+#
+# (c) Copyright Cisco 2000
+# All Rights Reserved
+#
+# Use Examples:
+#
+# Case 1:
+# make all VOB=GP10 -
+# Places .out in VOB/bin directory
+#
+# Case 2:
+# make all VOB=GP10 APPDIR=Host\<Application Name>\<Source Directory> -
+# Places .o file(s) in VOB\$(APPDIR)\bin directory.
+#
+# <Application Name> = Name of Application directory
+# <Source Directory> = application sub directory where the calling
+# Makefile resides.
+#
+# Example: make all VOB=GP10 APPDIR=Host\vxTemplate\src
+#
+#
+# Note: This make file must reference a VOB that
+# has a defs.mk in the top level directory.
+#
+##########################################################
+
+# TOP_OF_VOB must be defined before including l3defs.mk
+TOP_OF_VOB = ..\..
+
+# Name of this App's Directory
+THIS_APP_DIR = snmp
+
+VOB2DIR = $(TOP_OF_VOB)\..\$(VOB)
+BINDIR = ..\bin
+
+ifeq ($(APPDIR),)
+ MY_OUTPUT = $(VOB2DIR)\bin\snmp_com.out
+else
+ MY_OUTPUT = $(OBJDIR)\snmp_com.out
+endif
+
+
+include $(VOB2DIR)\l3defs.mk
+
+CC_INCLUDE += -I$(VOB2DIR)\Host
+
+all: $(MY_OUTPUT)
+
+$(MY_OUTPUT): $(MODULE_OBJS)
+ $(LD) -r -o $@.tmp $(MODULE_OBJS)
+ $(NM) $@.tmp | munch > _ctdt.c
+ $(CC) -traditional $(CC_ARCH_SPEC) -c _ctdt.c
+ $(LD) -r -o $@ _ctdt.o $@.tmp
+ $(RM)$(subst /,$(DIRCHAR), _ctdt.c _ctdt.o $@.tmp)
+
+cleanall:
+ @for %f in ($(notdir $(MODULE_OBJS))) do \
+ $(RM) ..\bin\%f
+
+ $(RM) $(MY_OUTPUT)
+
+
diff --git a/data/mnet/Common/snmp/src/api_init.c b/data/mnet/Common/snmp/src/api_init.c
new file mode 100644
index 0000000..5c783f8
--- /dev/null
+++ b/data/mnet/Common/snmp/src/api_init.c
@@ -0,0 +1,85 @@
+#include <stdlib.h>
+#include "oam_trap.h"
+
+static ListHeadPtr OamTrapTableHead = NULL;
+static SEM_ID OamApiMutex = NULL;
+
+int oamApiDebugLevel= 0;
+
+STATUS oam_initApi(int debugLevel)
+{
+ if (OamTrapTableHead == NULL)
+ {
+ OamTrapTableHead = oam_newListHead();
+ /* create a binary semaphore that is initially full
+ * Tasks block on semaphore wait in priority order
+ */
+#if (defined(VXWORKS))
+ OamApiMutex = semBCreate(SEM_Q_PRIORITY, SEM_FULL);
+#endif
+
+ }
+ oamApiDebugLevel = debugLevel;
+
+ return STATUS_OK;
+}
+
+
+ListHeadPtr oam_getTrapTableHead()
+{
+ if ( OamTrapTableHead == NULL)
+ oam_initApi(0);
+ return OamTrapTableHead;
+}
+
+
+STATUS aom_cleanOamApi()
+{
+ if (OamTrapTableHead != NULL)
+ {
+ ListNodePtr list = OamTrapTableHead->first;
+ ListNodePtr node;
+ while(list != NULL)
+ {
+ node = list;
+ list =list->next;
+ free(node);
+ }
+ free(OamTrapTableHead);
+#if (defined(VXWORKS))
+ semDelete(OamApiMutex);
+#endif
+ }
+ return STATUS_OK;
+}
+
+ListHeadPtr oam_newListHead()
+{
+ ListHeadPtr hp = (ListHeadPtr) malloc(sizeof(ListHead));
+ if (hp != NULL)
+ {
+ hp->first = NULL;
+ hp->last = NULL;
+ hp->nodeCount = 0;
+ }
+ return hp;
+}
+
+void oam_lockMutex()
+{
+#if (defined(VXWORKS))
+ if (OamApiMutex != NULL)
+ semTake(OamApiMutex, WAIT_FOREVER);
+#endif
+}
+
+void oam_unlockMutex()
+{
+#if (defined(VXWORKS))
+ if (OamApiMutex != NULL)
+ semGive(OamApiMutex);
+#endif
+}
+
+
+
diff --git a/data/mnet/Common/snmp/src/link_list.c b/data/mnet/Common/snmp/src/link_list.c
new file mode 100644
index 0000000..8e5a849
--- /dev/null
+++ b/data/mnet/Common/snmp/src/link_list.c
@@ -0,0 +1,316 @@
+#include <stdlib.h>
+#include <oam_trap.h>
+
+
+ListNodePtr oam_newListNode(MibTag tag, MSG_Q_ID qid)
+{
+ ListNodePtr newNode = (ListNodePtr) malloc (sizeof (ListNode));
+ if (newNode != NULL)
+ {
+ newNode->tag = tag;
+ newNode->qid = qid;
+ newNode->next = NULL;
+ }
+
+ return newNode;
+}
+
+
+STATUS oam_insertNode(ListHeadPtr head, ListNodePtr aNode)
+{
+ if (head != NULL && aNode != NULL)
+ {
+ if (head->first == NULL)
+ {
+ head->first = head->last = aNode;
+ head->nodeCount = 1;
+ } else {
+
+ aNode->next = head->first;
+ head->first = aNode;
+ ++head->nodeCount;
+ }
+ return OK;
+ }
+ return STATUS_INVALID_PARAMS;
+
+}
+
+STATUS oam_insertNodeSortedByTag(ListHeadPtr head, ListNodePtr aNode)
+{
+
+ ListNodePtr prevNode, curNode;
+ int tblId;
+
+ if ( head != NULL && aNode != NULL)
+ {
+
+ prevNode = NULL;
+ curNode = head->first;
+ tblId = MIB_TBL(aNode->tag);
+
+ while( (curNode != NULL) && ((MIB_TBL(curNode->tag) < tblId )
+ || ((MIB_TBL(curNode->tag) == tblId )
+ && (curNode->mid <= aNode->mid ))))
+
+ {
+ prevNode = curNode;
+ curNode = curNode->next;
+ }
+
+
+ if (prevNode == NULL)
+ {
+ /* insert at the beginning */
+ aNode->next = head->first;
+ head->first = aNode;
+ } else {
+
+ aNode->next = curNode;
+ prevNode->next = aNode;
+ }
+
+ if (curNode == NULL)
+ {
+ /* insert at the end */
+ head->last = aNode;
+ }
+
+ ++head->nodeCount;
+ return OK;
+ }
+ return STATUS_INVALID_PARAMS;
+
+}
+
+
+STATUS oam_appendNode(ListHeadPtr head, ListNodePtr aNode)
+{
+
+ if (head != NULL && aNode != NULL)
+ {
+ aNode->next = NULL;
+ if (head->last == NULL)
+ {
+ head->first = head->last = aNode;
+ head->nodeCount = 1;
+ } else {
+
+ head->last->next = aNode;
+ head->last = aNode;
+ ++head->nodeCount;
+ }
+ return OK;
+ }
+ return STATUS_INVALID_PARAMS;
+}
+
+ListNodePtr oam_getNodeByID(ListHeadPtr head, MSG_Q_ID id)
+{
+
+ ListNodePtr tempNode = NULL;
+
+ if(head != NULL)
+ {
+ tempNode = head->first;
+
+ while(tempNode != NULL)
+ {
+ if (tempNode->qid == id)
+ break;
+ tempNode = tempNode->next;
+ }
+ }
+ return tempNode;
+}
+
+ListNodePtr oam_getFirstNodeByTag(ListHeadPtr head, INT_32_T tag)
+{
+
+ ListNodePtr tempNode = NULL;
+ int tblId = MIB_TBL(tag);
+
+ if(head != NULL)
+ {
+ tempNode = head->first;
+
+ while(tempNode != NULL)
+ {
+ if (MIB_TBL(tempNode->tag) >= tblId)
+ break;
+ tempNode = tempNode->next;
+ }
+ }
+ return tempNode;
+}
+
+
+STATUS oam_deleteNode(ListHeadPtr head, MibTag tag, OCTET_T mid)
+{
+
+ ListNodePtr prevNode, curNode;
+ int tblId = MIB_TBL(tag);
+
+
+ if ( head != NULL)
+ {
+ prevNode = NULL;
+ curNode = head->first;
+
+ /* skip until table id is smaller than the current one */
+ while(curNode != NULL && (MIB_TBL(curNode->tag) < tblId))
+ {
+ prevNode = curNode;
+ curNode = curNode->next;
+
+ }
+
+ /* search for the module Id and tag */
+ while(curNode != NULL && (MIB_TBL(curNode->tag) == tblId) && (curNode->mid != mid) && (curNode->tag != tag))
+ {
+
+ prevNode = curNode;
+ curNode = curNode->next;
+
+ }
+
+ if (curNode != NULL && (MIB_TBL(curNode->tag) == tblId))
+ {
+
+ /* Node found */
+
+ if(curNode == head->first || curNode == head->last)
+ {
+ if ( curNode == head->first)
+ {
+ head->first = head->first->next;
+ }
+ if (curNode == head->last)
+ {
+ head->last = prevNode;
+ if(prevNode != NULL)
+ prevNode->next = NULL;
+ }
+ } else {
+ prevNode->next = curNode->next;
+ }
+
+ --head->nodeCount;
+ free(curNode);
+ return OK;
+ }
+ return STATUS_NOT_FOUND;
+ }
+ return STATUS_INVALID_PARAMS;
+
+}
+
+STATUS oam_deleteNodeByModule(ListHeadPtr head, OCTET_T mid)
+{
+
+ ListNodePtr prevNode, curNode, nextNode;
+
+ if ( head != NULL)
+ {
+ prevNode = NULL;
+ curNode = head->first;
+
+ while(curNode != NULL)
+ {
+ if (curNode->mid == mid)
+ {
+ nextNode = curNode->next;
+ if(curNode == head->first || curNode == head->last)
+ {
+ if ( curNode == head->first)
+ {
+ head->first = head->first->next;
+ }
+ if (curNode == head->last)
+ {
+ head->last = prevNode;
+ if(prevNode != NULL)
+ prevNode->next = NULL;
+ }
+ } else {
+ prevNode->next = curNode->next;
+ }
+
+ --head->nodeCount;
+ free(curNode);
+ curNode = nextNode;
+ } else {
+ prevNode = curNode;
+ curNode = curNode->next;
+ }
+ }
+
+ return STATUS_OK;
+ }
+ return STATUS_INVALID_PARAMS;
+}
+
+STATUS oam_deleteNodeByQ(ListHeadPtr head, MSG_Q_ID qid)
+{
+
+ ListNodePtr prevNode, curNode, nextNode;
+
+ if ( head != NULL)
+ {
+ prevNode = NULL;
+ curNode = head->first;
+
+ while(curNode != NULL)
+ {
+ if (curNode->qid == qid)
+ {
+ nextNode = curNode->next;
+ if(curNode == head->first || curNode == head->last)
+ {
+ if ( curNode == head->first)
+ {
+ head->first = head->first->next;
+ }
+ if (curNode == head->last)
+ {
+ head->last = prevNode;
+ if(prevNode != NULL)
+ prevNode->next = NULL;
+ }
+ } else {
+ prevNode->next = curNode->next;
+ }
+
+ --head->nodeCount;
+ free(curNode);
+ curNode = nextNode;
+ } else {
+ prevNode = curNode;
+ curNode = curNode->next;
+ }
+ }
+
+ return STATUS_OK;
+ }
+ return STATUS_INVALID_PARAMS;
+}
+
+
+void oam_printList(ListHeadPtr head)
+{
+ ListNodePtr aNode;
+ if (head != NULL)
+ {
+ printf("%10s%15s%13s\n", "Table ID", "Module ID", "Tag");
+ printf("%10s%15s%15s\n", "========", "=========", "=========");
+
+ aNode = head->first;
+ while (aNode != NULL)
+ {
+ printf("%10d %13d %s\n", MIB_TBL(aNode->tag), aNode->mid, snmp_tagName(aNode->tag));
+ aNode = aNode->next;
+ }
+ printf ("Total items = %d\n", head->nodeCount);
+ }
+}
+
diff --git a/data/mnet/Common/snmp/src/oam_api.c b/data/mnet/Common/snmp/src/oam_api.c
new file mode 100644
index 0000000..9afd2dc
--- /dev/null
+++ b/data/mnet/Common/snmp/src/oam_api.c
@@ -0,0 +1,1274 @@
+/*********************************************************************/
+/* */
+/* (c) Copyright Cisco 2000 */
+/* All Rights Reserved */
+/* */
+/*********************************************************************/
+
+/*********************************************************************
+**
+** FILE NAME: oam_api.c
+**
+** DESCRIPTION: This file contains implementation of OAM API routines
+**
+** COMPONENTS:
+**
+**
+** NOTES:
+**
+** REVISION HISTORY
+** __________________________________________________________________
+** ----------+--------+----------------------------------------------
+** Name | Date | Reason
+** ----------+--------+----------------------------------------------
+** Bhawani |05/11/99| Initial Draft
+** Bhawani |12/29/00| resturctured to share among GP, GMS and GS
+** Bhawani |02/28/01| Change to use unify mib change part
+** Bhawani |04/10/01| Added oam_getMnc routine
+** ----------+--------+----------------------------------------------
+**********************************************************************
+*/
+
+/*
+**********************************************************************
+** Include Files.
+**********************************************************************
+*/
+#include "oam_api.h"
+#include "vipermib.h" /* Get the ViperCell MIB definitions.*/
+#include "Table.h"
+#include "vipertbl.h" /* Thi&Sandeep */
+
+
+/*
+*********************************************************************
+** Global Variables / Functions
+*********************************************************************/
+
+/********************************************************************
+** Static Variables
+*********************************************************************/
+
+/*
+ * gets address of a single MIB tag. Index is optional
+ * parameter if the tag is table entry of filed.
+*/
+
+void *oam_getMibAddress(MibTag tag, ...)
+{
+ void *retval = NULL;
+ va_list argn;
+ int idx = 0;
+ int typ = MIB_TYP(tag);
+
+
+ if (True == snmp_validTag(tag))
+ {
+ if (MTYPE_IS_TABLE(typ))
+ {
+ va_start(argn, tag);
+ idx = va_arg(argn, int);
+ va_end(argn);
+ }
+
+ retval = snmp_getAddress(tag, idx);
+ if ((NULL != retval) && (typ== MTYPE_STRING || typ == MTYPE_TSTRING || typ== MTYPE_TABLE))
+ {
+ retval = *((void **)retval);
+ }
+ }
+ return retval;
+}
+
+/*
+** This function stores address of the MIB variable to the out
+** parameters supplied.
+*/
+STATUS oam_getMibVarAdr(MibTag varTag, void ** mibVarAdr)
+{
+ static char fname[] = "oam_getMibVarAdr";
+
+ if (NULL == mibVarAdr)
+ {
+ LOG_ERROR(("Invalid output parameter(mibVarAdr = NULL)"));
+ return STATUS_INVALID_PARAMS;
+ }
+
+ *mibVarAdr = oam_getMibAddress(varTag);
+
+ if (*mibVarAdr == NULL)
+ {
+ LOG_ERROR(("Invalid Tag (varTag = %#x)", varTag));
+ return STATUS_INVALID_TAG;
+ }
+ return STATUS_OK;
+}
+
+
+/* get scalar integer variable and IP address */
+STATUS oam_getMibIntVar(MibTag varTag, INT_32_T *varPtr)
+{
+ INT_32_T* adr;
+ static char fname[] = "oam_getMibIntVar";
+
+ adr = oam_getMibAddress(varTag);
+
+ if (NULL == adr)
+ {
+ LOG_ERROR(("Invalid Tag (varTag = %#x)", varTag));
+ return STATUS_INVALID_TAG;
+ }
+
+ if (!MTYPE_IS_INT(MIB_TYP(varTag)))
+ {
+ LOG_ERROR(("Invalid scalar number Tag (varTag = %#x)", varTag));
+ return STATUS_INVALID_TAG;
+ }
+
+
+ if (NULL == varPtr)
+ {
+ LOG_ERROR(("Invalid output parameter (varPtr = NULL)"));
+ return STATUS_INVALID_PARAMS;
+ }
+
+ *varPtr = *adr;
+
+ return STATUS_OK;
+}
+
+
+/* get scalar string variable example tag: MIB_viperCellName */
+
+STATUS oam_getMibByteAry(MibTag aryTag, OCTET_T *buffer, INT_32_T size)
+{
+
+ char *pStr;
+ static char fname[] = "oam_getMibByteAry";
+
+ pStr = oam_getMibAddress(aryTag);
+
+ if (NULL == pStr)
+ {
+ LOG_ERROR(("Invalid Tag (aryTag = %#x)", aryTag));
+ return STATUS_INVALID_TAG;
+ }
+
+ if (!MTYPE_IS_STR(MIB_TYP(aryTag)))
+ {
+ LOG_ERROR(("Invalid scalar string Tag (aryTag = %#x)", aryTag));
+ return STATUS_INVALID_TAG;
+ }
+
+ if (NULL == buffer || size <= 0 )
+ {
+ LOG_ERROR(("Invalid Output parameters (buffer = %#x, size=%d)", aryTag, size));
+ return STATUS_INVALID_PARAMS;
+ }
+
+ strncpy(buffer, pStr, size);
+ return STATUS_OK;
+}
+
+/*
+** Returns the struct type of MIB variable
+*/
+
+STATUS oam_getMibStruct(MibTag structTag, OCTET_T * buffer, int size)
+
+{
+ int typ = MIB_TYP(structTag);
+ int sz = MIB_SIZ(structTag);
+ OCTET_T* addr;
+ static char fname[] = "oam_getMibStruct";
+
+ addr = oam_getMibAddress(structTag);
+
+ if (NULL == addr)
+ {
+ LOG_ERROR(("Invalid Tag (structTag = %#x)", structTag));
+ return STATUS_INVALID_TAG;
+ }
+
+ if (typ != MTYPE_STRUCT )
+ {
+ LOG_ERROR(("Invalid struct type Tag (structTag = %#x)", structTag));
+ return STATUS_INVALID_TAG;
+ }
+
+
+ if (buffer == NULL || size < sz)
+ {
+
+ LOG_ERROR(("Invalid Parameters (tag= %s, buffer = %#x, size = %d)",
+ snmp_tagName(structTag), buffer, size ));
+ return STATUS_INVALID_PARAMS;
+ }
+
+ memcpy(buffer, addr, sz);
+
+ return STATUS_OK;
+}
+
+
+/*
+ * returns size,in bytes, of the Table entry.
+ * returns STATUS_INVALID_TAG (-1) if the tag is invalid
+ * tag is Table tag eg: MIB_trapFwdTable
+*/
+
+int oam_getMibTblEntSz(MibTag tag)
+{
+
+ Table* tbl;
+ static char fname[] = "oam_getMibTblEntSz";
+
+ if (MIB_TYP(tag) == MTYPE_TENTRY)
+ {
+ tag = MIB_TABLE(MIB_TBL(tag), MIB_ITM(tag));
+ }
+
+ if (MIB_TYP(tag) != MTYPE_TABLE )
+ {
+ LOG_ERROR(("Invalid Table Tag (tag = %#x)", tag));
+ return STATUS_INVALID_TAG;
+ }
+
+ tbl = (Table *) oam_getMibAddress(tag);
+
+ if (tbl == NULL)
+ {
+ LOG_ERROR(("Invalid Tag (tag = %#x)", tag));
+ return STATUS_INVALID_TAG;
+ }
+
+ return table_size(tbl);
+}
+
+/*
+* returns number of rows on the table.
+* returns STATUS_INVALID_TAG (-1) if the tag is invalid
+* tag is Table tag eg: MIB_trapFwdTable
+*/
+
+int oam_getMibTblEntCount(MibTag tag)
+{
+ Table* tbl;
+ static char fname[] = "oam_getMibTblEntCount";
+
+ if (MIB_TYP(tag) == MTYPE_TENTRY)
+ {
+ tag = MIB_TABLE(MIB_TBL(tag), MIB_ITM(tag));
+ }
+
+ if (MIB_TYP(tag) != MTYPE_TABLE )
+ {
+ LOG_ERROR(("Invalid Table Tag (tag = %#x)", tag));
+ return STATUS_INVALID_TAG;
+ }
+
+ tbl = (Table *) oam_getMibAddress(tag);
+
+ if (tbl == NULL)
+ {
+ LOG_ERROR(("Invalid Tag (tag = %#x)", tag));
+ return STATUS_INVALID_TAG;
+ }
+ return table_end(tbl);
+}
+
+
+
+/*
+ * get the entire table into the burffer supplied.
+ * tag is Table tag eg: MIB_trapFwdTable
+ */
+
+STATUS oam_getMibTbl(MibTag tblTag, void *tblBuf, int bufSize)
+{
+ int entCnt;
+ int entSz;
+ Table* tbl;
+
+ static char fname[] = "oam_getMibTbl";
+
+ if (MIB_TYP(tblTag) == MTYPE_TENTRY)
+ {
+ tblTag = MIB_TABLE(MIB_TBL(tblTag), MIB_ITM(tblTag));
+ }
+
+ if (MIB_TYP(tblTag) != MTYPE_TABLE )
+ {
+ LOG_ERROR(("Invalid Table Tag (tblTag = %#x)", tblTag));
+ return STATUS_INVALID_TAG;
+ }
+
+ tbl = (Table *) oam_getMibAddress(tblTag);
+
+ if (tbl == NULL)
+ {
+ LOG_ERROR(("Invalid Tag (tblTag = %#x)", tblTag));
+ return STATUS_INVALID_TAG;
+ }
+
+ entCnt = table_end(tbl);
+ entSz = table_size(tbl);
+
+ if (bufSize < entCnt*entSz)
+ {
+ LOG_ERROR(("Too small buffer(supplied size=%d, needed =%d)",
+ bufSize, entCnt*entSz));
+ return STATUS_INVALID_PARAMS;
+ }
+
+
+ if (NULL == tblBuf)
+ {
+ LOG_ERROR(("Output parameter buffer is null"));
+ return STATUS_INVALID_PARAMS;
+ }
+
+ memcpy(tblBuf, table_getRow(tbl, 0), entCnt*entSz);
+ return STATUS_OK;
+
+}
+
+
+/*
+ * retrieves a Table Entry of the into the memory supplied
+ * Tag is Table Entry tag, eg: MIBT_trapFwdEntry
+ */
+
+STATUS oam_getMibTblEntry(MibTag tblEntryTag, int idx, void *buffer, int bufSize)
+{
+ char* etyAddr;
+ int entSz = MIB_SIZ(tblEntryTag);
+ int typ = MIB_TYP(tblEntryTag);
+
+ static char fname[] = "oam_getMibTblEntry";
+
+ etyAddr = oam_getMibAddress(tblEntryTag, idx);
+
+ if (etyAddr == NULL)
+ {
+ LOG_ERROR(("Invalid Tag (tblEntryTag = %#x)", tblEntryTag));
+ return STATUS_INVALID_TAG;
+ }
+
+ if (typ != MTYPE_TENTRY)
+ {
+ LOG_ERROR(("Invalid Table Entry Tag (tag = %#x)", tblEntryTag));
+ return STATUS_INVALID_TAG;
+ }
+
+
+ if (bufSize < entSz)
+ {
+ LOG_ERROR(("The buffer not enough to fit the entry(supplied=%d, needed =%d)",
+ bufSize, entSz));
+ return STATUS_INVALID_PARAMS;
+ }
+
+
+ if (NULL == buffer)
+ {
+ LOG_ERROR(("Output parameter buffer is null"));
+ return STATUS_INVALID_PARAMS;
+ }
+
+ memcpy(buffer, etyAddr, entSz);
+ return STATUS_OK;
+
+}
+
+
+/*
+ * retrieves an individual field of integer type from
+ * the given row of a table.
+ * Tag is Table Entry tag, eg: MIBT_trapPort, MIBT_trapIpAddress
+ */
+
+STATUS oam_getMibTblNumberField(MibTag colTag, int idx, INT_32_T *value)
+{
+ INT_32_T* addr; /* Raju: fixing a bug */
+ int typ = MIB_TYP(colTag);
+ static char fname[] = "oam_getMibTblNumberField";
+
+ addr = (INT_32_T *)oam_getMibAddress(colTag, idx);
+
+ if (NULL == addr)
+ {
+ LOG_ERROR(("Invalid Tag (colTag = %#x)", colTag));
+ return STATUS_INVALID_TAG;
+ }
+
+ if (!(MTYPE_IS_TINT(typ)))
+ {
+ LOG_ERROR(("Invalid Table Number Item tag (tag = %#x)", colTag));
+ return STATUS_INVALID_TAG;
+ }
+
+
+ if (NULL == value)
+ {
+ LOG_ERROR(("Invalid output parameter value=NULL"));
+ return STATUS_INVALID_PARAMS;
+ }
+
+ *value = *addr;
+ return STATUS_OK;
+
+}
+
+
+/*
+ * retrieves an individual field of string type from
+ * the given row of a table.
+ * Tag is Table Entry tag, eg: MIBT_trapPort, MIBT_trapIpAddress
+ */
+
+STATUS oam_getMibTblStringField(MibTag tblStrTag, int idx, OCTET_T *buffer, INT_32_T size)
+{
+ char *str;
+ int typ = MIB_TYP(tblStrTag);
+ static char fname[] = "oam_getMibTblStringField";
+
+ str = oam_getMibAddress(tblStrTag, idx);
+
+ if (NULL == str)
+ {
+ LOG_ERROR(("Invalid Tag (tblStrTag = %#x)", tblStrTag));
+ return STATUS_INVALID_TAG;
+ }
+
+ if (!(MTYPE_IS_TSTR(typ)))
+ {
+ LOG_ERROR(("Invalid table string tag(tblStrTag = %#x)", tblStrTag));
+ return STATUS_INVALID_TAG;
+ }
+
+ if (NULL == buffer || size <= 0 )
+ {
+ LOG_ERROR(("Invalid output parameters (buffer = %#x, size=%d)", buffer, size));
+ return STATUS_INVALID_PARAMS;
+ }
+
+ strncpy(buffer, str, size);
+ return STATUS_OK;
+}
+
+#ifdef MNET_GP10
+
+/* convert int to three digit mnc */
+STATUS oam_getMncFromInt(int nMnc, UINT8 *pszMnc)
+{
+
+ int i = 0;
+ if ( nMnc >= 100)
+ {
+ pszMnc[i++] = nMnc/100;
+ pszMnc[i++] = (nMnc%100)/10;
+ pszMnc[i++] = nMnc%10;
+ }
+ else
+ {
+ pszMnc[i++] = nMnc/10;
+ pszMnc[i++] = nMnc%10;
+ pszMnc[i++] = 0x0F;
+ }
+ return STATUS_OK;
+
+}
+
+/* returns 3 bytes of MNC as an arrary */
+STATUS oam_getMnc(UINT8 *pszMnc)
+{
+ INT_32_T mnc;
+ int i;
+ static char fname[] = "oam_getMnc";
+
+ if (STATUS_OK != oam_getMibIntVar(MIB_bts_mnc, &mnc))
+ {
+ LOG_ERROR(("Not available(MIB_bts_mnc = %#x)", MIB_bts_mnc));
+ return STATUS_NOT_FOUND;
+ }
+ return oam_getMncFromInt(mnc, pszMnc);
+}
+
+
+STATUS oam_getMccMncByteAryByInt(INT_32_T intVal, char * byteAry)
+{
+ byteAry[2] = (UINT8) (intVal & 0xF);
+ intVal >>= 4;
+ byteAry[1] = (UINT8) (intVal & 0xF);
+ intVal >>= 4;
+ byteAry[0] = (UINT8) (intVal & 0xF);
+
+ return STATUS_OK;
+}
+
+
+#endif // MNET_GP10
+
+#ifdef MNET_GMC
+/*
+*/
+
+STATUS oam_getMncFromInt(int nMnc, UINT8 *pszMnc)
+{
+ pszMnc[2] = (UINT8) (nMnc & 0xF);
+ nMnc = nMnc >> 4;
+ pszMnc[1] = (UINT8) (nMnc & 0xF);
+ nMnc = nMnc >> 4;
+ pszMnc[0] = (UINT8) (nMnc & 0xF);
+
+ return STATUS_OK;
+
+}
+
+STATUS oam_getMccFromInt(int nMcc, UINT8 *pszMcc)
+{
+
+ pszMcc[2] = (UINT8) (nMcc & 0xF);
+ nMcc = nMcc >> 4;
+ pszMcc[1] = (UINT8) (nMcc & 0xF);
+ nMcc = nMcc >> 4;
+ pszMcc[0] = (UINT8) (nMcc & 0xF);
+
+ return STATUS_OK;
+
+}
+
+
+STATUS oam_getMnc(UINT8 *pszMnc)
+{
+ INT_32_T mnc;
+ static char fname[] = "oam_getMnc";
+
+
+ if (STATUS_OK != oam_getMibIntVar(MIB_mnetMNC, &mnc))
+ {
+ LOG_ERROR(("Not available(MIB_mnetMNC = %#x)", MIB_mnetMNC));
+ return STATUS_NOT_FOUND;
+ }
+ return oam_getMncFromInt(mnc, pszMnc);
+}
+
+STATUS oam_getMcc(UINT8 *pszMcc)
+{
+ INT_32_T mcc;
+ static char fname[] = "oam_getMnc";
+
+
+ if (STATUS_OK != oam_getMibIntVar(MIB_mnetMCC, &mcc))
+ {
+ LOG_ERROR(("Not available(MIB_mnetMCC = %#x)", MIB_mnetMCC));
+ return STATUS_NOT_FOUND;
+ }
+ return oam_getMccFromInt(mcc, pszMcc);
+}
+
+void testAdjMNC(int idx)
+{
+ UINT8 buf[3];
+
+ buf[0] = 0;
+ buf[1] = 0;
+ buf[2] = 0;
+
+ printf("testAdjMNC: before buf = %d,%d,%d\n",buf[0],buf[1],buf[2]);
+
+ oam_getAdjacentLocationAreaMNC(buf, idx);
+
+ printf("testAdjMNC: after buf = %d,%d,%d\n",buf[0],buf[1],buf[2]);
+}
+
+
+STATUS oam_getAdjacentLocationAreaMNC(UINT8 *pszMnc, int idx)
+{
+ INT_32_T mnc;
+ static char fname[] = "oam_getMnc";
+
+
+ if (STATUS_OK != oam_getMibTblNumberField(MIBT_adjacentLocationAreaMNC, idx, &mnc))
+ {
+ LOG_ERROR(("Not available(MIBT_adjacentLocationAreaMNC = %#x)", MIBT_adjacentLocationAreaMNC));
+ return STATUS_NOT_FOUND;
+ }
+
+ return oam_getMncFromInt(mnc, pszMnc);
+}
+
+
+STATUS oam_getAdjacentLocationAreaMCC(UINT8 *pszMcc, int idx)
+{
+ INT_32_T mcc;
+ static char fname[] = "oam_getMnc";
+
+
+ if (STATUS_OK != oam_getMibTblNumberField(MIBT_adjacentLocationAreaMCC, idx, &mcc))
+ {
+ LOG_ERROR(("Not available(MIBT_adjacentLocationAreaMCC = %#x)", MIBT_adjacentLocationAreaMCC));
+ return STATUS_NOT_FOUND;
+ }
+ return oam_getMccFromInt(mcc, pszMcc);
+}
+
+
+STATUS msrn_addTblEntry(char *msrnValue)
+{
+ int i, msrnRowUsed;
+ Boolean availSlotFound = FALSE;
+
+ if (strlen(msrnValue) > SIZE_E164) /* make sure msrn string does not exceed E164 size */
+ return STATUS_INVALID_PARAMS;
+
+ for (i = 0; i < MsrnTableLimit && !availSlotFound; i++)
+ {
+ if (oam_getMibTblNumberField(MIBT_msrnRowUsed, i, (INT_32_T *)&msrnRowUsed) != STATUS_OK)
+ return STATUS_INVALID_PARAMS;
+ if (msrnRowUsed == 0)
+ {
+ oam_setTblEntryField(SNMP_AGENT_MODULE_ID, MIBT_msrnRowUsed, i, 1);
+ oam_setTblEntryStrField(SNMP_AGENT_MODULE_ID, MIBT_msrn, i, msrnValue, strlen(msrnValue)+1);
+ availSlotFound = TRUE;
+ }
+ }
+ if (!availSlotFound)
+ return STATUS_NOT_FOUND;
+ return STATUS_OK;
+}
+
+STATUS msrn_delTblEntry(char *msrnValue)
+{
+ int i;
+ MsrnEntry msrnEntry;
+ Boolean entryFound = FALSE;
+ char *pMsrn;
+
+ if (strlen(msrnValue) > SIZE_E164) /* make sure msrn string does not exceed E164 size */
+ return STATUS_INVALID_PARAMS;
+
+ for (i = 0; i < MsrnTableLimit && !entryFound; i++)
+ {
+ memset(&msrnEntry, 0, sizeof(msrnEntry));
+ if (oam_getMibTblEntry(MIBT_msrnEntry, i, &msrnEntry, sizeof(msrnEntry)) != STATUS_OK)
+ return STATUS_INVALID_PARAMS;
+ if (msrnEntry.msrnRowUsed != 0)
+ {
+ pMsrn = msrnEntry.msrn;
+
+ if ((NULL != pMsrn) && (strncmp(msrnValue, pMsrn, strlen(pMsrn)) == 0))
+ {
+ /* entry found, mark slot as available */
+ oam_setTblEntryField(SNMP_AGENT_MODULE_ID, MIBT_msrnRowUsed, i, 0);
+ entryFound = TRUE;
+ }
+ }
+ }
+ if (!entryFound)
+ return STATUS_NOT_FOUND;
+ return STATUS_OK;
+}
+
+char *msrn_getNextEntry(int *counter)
+{
+ int i;
+ MsrnEntry msrnEntry;
+ char *pMsrn;
+
+ for (i = *counter; i < MsrnTableLimit; i++)
+ {
+ memset(&msrnEntry, 0, sizeof(msrnEntry));
+ if (oam_getMibTblEntry(MIBT_msrnEntry, i, &msrnEntry, sizeof(msrnEntry)) != STATUS_OK)
+ return NULL;
+ if (msrnEntry.msrnRowUsed != 0)
+ {
+ *counter = i + 1;
+ pMsrn = msrnEntry.msrn;
+ return pMsrn;
+ }
+ }
+ return NULL;
+}
+
+void msrn_testFunction()
+{
+ char buffer[256];
+ char *p = NULL;
+ int i = 0;
+ while (p = msrn_getNextEntry(&i))
+ {
+ strcpy(buffer, p); /* to test strcpy to a buffer */
+ printf("***** %d ***** %s\n", i, buffer);
+ }
+}
+
+#endif /* MNET_GMC */
+
+
+#ifdef MNET_GS
+
+/*
+This API expects pszAPN parameter in ASCII null terminated
+string format (Ex: "gprs.cisco.com"). Stores IP Address
+in pIpAddr if operation is successful. Return value
+indicates the status of the operation.
+
+This API first looks-up in the local table. If the lookup fails
+and the DNS server is configured then performs DNS lookup.
+
+Note that a call to this routine may be blocked
+for long time (up to 10 seconds or more if the DNS server
+is not responding). Caller should be prepared for such
+long delays.
+*/
+STATUS oam_getGgsnIpAddress(char *pszAPN, UINT32 *pIpAddr)
+{
+ Table *tbl;
+ int j,end;
+ char *apnName;
+ static char fname[] = "oam_getGgsnIpAddress";
+
+ if ((pszAPN == NULL) || (pIpAddr == NULL))
+ {
+ LOG_ERROR(("Invalid arguments to the funcation call"));
+ return STATUS_NOK;
+ }
+
+ /* First do a look-up in the Local APN table */
+
+ if ((tbl = snmp_getTableAddress(MIBT_apnName)))
+ {
+ end = table_end(tbl);
+ for (j=0; j < end; j++)
+ {
+ apnName = (char *) snmp_getValue(MIBT_apnName, j);
+ if (apnName != NULL)
+ {
+ /* Since APN name is a hostname, hence it is case insensitive */
+ if (strcasecmp(apnName, pszAPN) == 0)
+ {
+ return oam_getMibTblNumberField(MIBT_apnGgsnIpAddress,j,(INT_32_T*)pIpAddr);
+ }
+ }
+ }
+ }
+
+ /* Since, local lookup failed now try the DNS lookup */
+ /* To be completed */
+
+ return STATUS_NOK;
+}
+
+void debugApnLookup(char *apnName)
+{
+ UINT32 ipaddr;
+
+ if (apnName == NULL)
+ {
+ printf("Usage: debugApnLookup apnName\n");
+ return;
+ }
+ if (oam_getGgsnIpAddress(apnName, &ipaddr) == STATUS_OK)
+ {
+ printf ("GGSN IP Address for APN Name \"%s\" is %s\n",apnName,int2ip(ipaddr));
+ } else
+ {
+ printf("APN looup failed for \"%s\".\n",apnName);
+ }
+}
+
+/*
+Returns name of the default APN. Willl return NULL if
+no default APN name is configured by the user. Return value
+is null terminated. Format for the return value is ASCII
+(Ex: "gprs.cisco.com")
+*/
+char * oam_getDefaultAPN()
+{
+ char *name;
+
+ name = (char *) snmp_getValue(MIB_sgsnDefApnName);
+ if ((name == NULL) || (strlen(name) == 0))
+ {
+ return (char *)0;
+ }
+ return name;
+}
+
+#endif /* MNET_GS */
+
+int oam_isSnmpEnabled()
+{
+ INT_32_T status;
+
+ if (STATUS_OK != oam_getMibIntVar(MIB_snmpServiceEnabled, &status))
+ {
+ /* if there is any error, assume SNMP is enabled */
+ return 1;
+ }
+
+ return (int) status;
+}
+
+int oam_isHttpEnabled()
+{
+ INT_32_T status;
+
+ if (STATUS_OK != oam_getMibIntVar(MIB_httpServiceEnabled, &status))
+ {
+ /* if there is any error, assume HTTP is enabled */
+ return 1;
+ }
+
+ return (int) status;
+}
+
+int oam_isFtpEnabled()
+{
+ INT_32_T status;
+
+ if (STATUS_OK != oam_getMibIntVar(MIB_ftpServiceEnabled, &status))
+ {
+ /* if there is any error, assume FTP is enabled */
+ return 1;
+ }
+
+ return (int) status;
+}
+
+void oam_setSnmpEnabled(int status)
+{
+ int value = 1;
+
+ if (status == 0)
+ value = 0;
+
+ snmp_setEntry(MIB_snmpServiceEnabled, 0, (void *) value, 4);
+ agent_setSnmpEnabled(value);
+}
+
+void oam_setHttpEnabled(int status)
+{
+ int value = 1;
+
+ if (status == 0)
+ value = 0;
+
+ snmp_setEntry(MIB_httpServiceEnabled, 0, (void *) value, 4);
+}
+
+void oam_setFtpEnabled(int status)
+{
+ int value = 1;
+
+ if (status == 0)
+ value = 0;
+
+ snmp_setEntry(MIB_ftpServiceEnabled, 0, (void *) value, 4);
+
+ /* No harm in calling ftpdDelete/ftpdInit even though
+ FTP server is not running/already running
+ */
+ if (value == 0)
+ ftpdDelete();
+ else
+ ftpdInit((FUNCPTR *)0, 0);
+}
+
+/******************************************************************
+** API used to set MIB variables.
+******************************************************************/
+
+/*
+** The same set of API are used to set MIB variables by both agent
+** and application modules. Source Module ID is passed so that the
+** implementation knows the direction of message flow.
+*/
+
+/* sets a single mib variable.
+ * tag is */
+STATUS oam_setMibIntVar(OCTET_T srcModuleId, MibTag varTag, INT_32_T varVal)
+{
+ static char fname[] = "oam_setMibIntVar";
+
+ if (False == snmp_validTag(varTag))
+ {
+ LOG_ERROR(("Invalid Tag (varTag = %#x)", varTag));
+ return STATUS_INVALID_TAG;
+ }
+
+ if (!MTYPE_IS_INT(MIB_TYP(varTag)))
+ {
+ LOG_ERROR(("Invalid Tag for integer type item (tag = %#x)", varTag));
+ return STATUS_INVALID_TAG;
+ }
+
+ if (Success == snmp_setEntry(varTag, 0, (void *) varVal, 4))
+ {
+ oam_processTrap(srcModuleId, varTag, VT_VALUE, varVal, 0);
+ return STATUS_OK;
+ }
+
+ LOG_ERROR(("Invalid Parameters (varTag =%s(%#x), varVal = %d)",
+ snmp_tagName(varTag), varTag, varVal));
+
+ return STATUS_NOK;
+}
+
+
+
+/* sets mib string
+ * tag is a string: eg: MIB_viperCellName */
+STATUS oam_setMibByteAry(OCTET_T srcModuleId, MibTag strTag, OCTET_T *byteAryPtr, INT_32_T byteCount)
+{
+ static char fname[] = "oam_setMibByteAry";
+
+ if (False == snmp_validTag(strTag))
+ {
+ LOG_ERROR(("Invalid Tag (strTag = %#x)", strTag));
+ return STATUS_INVALID_TAG;
+ }
+
+ if (!MTYPE_IS_STR(MIB_TYP(strTag)))
+ {
+ LOG_ERROR(("Invalid string tag (tag = %#x)", strTag));
+ return STATUS_INVALID_TAG;
+ }
+
+ if (Success == snmp_setEntry(strTag, 0, (void *) byteAryPtr, byteCount))
+ {
+ oam_processTrap(srcModuleId, strTag, VT_ADDRESS, (int) oam_getMibAddress(strTag), 0);
+ return STATUS_OK;
+ }
+ LOG_ERROR(("Invalid Parameters (tag =%s(%#x), byteAryPtr = %#x, byteCount=%d)",
+ snmp_tagName(strTag), strTag, byteAryPtr, byteCount));
+ return STATUS_NOK;
+
+}
+
+
+/*
+ * sets an entry of a Table, an entry is actually is row of MIB table
+ * tag is a table entry, eg: MIBT_trapFwdEntry
+ */
+
+STATUS oam_setMibTblEntry(OCTET_T srcModuleId, MibTag entryTag, int idx, void *tblEntBuf, int bufSize)
+{
+ static char fname[] = "oam_getMibTblEntry";
+
+ if (False == snmp_validTag(entryTag))
+ {
+ LOG_ERROR(("Invalid Tag (entryTag = %#x)", entryTag));
+ return STATUS_INVALID_TAG;
+ }
+
+ if (MIB_TYP(entryTag) != MTYPE_TENTRY)
+ {
+ LOG_ERROR(("Invalid table entry tag (tag = %#x)", entryTag));
+ return STATUS_INVALID_TAG;
+ }
+
+ if (Success == snmp_setEntry(entryTag, idx, tblEntBuf, bufSize))
+ {
+ oam_processTrap(srcModuleId, entryTag, VT_TABLE,
+ (int) oam_getMibAddress(entryTag, idx), idx);
+ return STATUS_OK;
+ }
+ LOG_ERROR(("Invalid Parameters (entryTag =%s(%#x), idx = %d, tblEntBuf = 0x%08p, bufSize=%d)",
+ snmp_tagName(entryTag), entryTag, idx, tblEntBuf, bufSize));
+ return STATUS_NOK;
+}
+
+
+/*
+** sets a individual number field of the given table
+** The field is identified using the tag name, which is the column tag name
+** and the row index of the table. The index start from 0.
+** tag example: MIBT_trapPort, MIBT_trapIpAddress
+*/
+
+STATUS oam_setTblEntryField(OCTET_T srcModuleId, MibTag colTag, int idx, INT_32_T fieldVal)
+{
+
+ int typ = MIB_TYP(colTag);
+ static char fname[] = "oam_setTblEntryField";
+
+ if (False == snmp_validTag(colTag))
+ {
+ LOG_ERROR(("Invalid Tag (colTag = %#x)", colTag));
+ return STATUS_INVALID_TAG;
+ }
+
+ if (!(MTYPE_IS_TINT(typ)))
+ {
+ LOG_ERROR(("Invalid table number tag %s(%#x)", snmp_tagName(colTag), colTag));
+ return STATUS_INVALID_TAG;
+ }
+
+
+ if (Success == snmp_setEntry(colTag, idx, (void*) fieldVal, 4))
+ {
+ oam_processTrap(srcModuleId, colTag, VT_TABLE, fieldVal, idx);
+ return STATUS_OK;
+ }
+ LOG_ERROR(("Invalid Parameters (colTag =%s(%#x), idx = %d, fieldVal=%d)",
+ snmp_tagName(colTag), colTag, idx, fieldVal));
+ return STATUS_NOK;
+
+}
+
+
+/*
+** sets a individual string field of the given table
+** tag is table string, which is the column tag name
+** (eg MIBT_trapCommunity) and the row index of the table.
+** The index start from 0.
+ */
+
+STATUS oam_setTblEntryStrField(OCTET_T srcModuleId, MibTag tstrTag, int idx, OCTET_T *tstr, INT_32_T byteCount)
+{
+
+ static char fname[] = "oam_setTblEntryField";
+
+ if (False == snmp_validTag(tstrTag))
+ {
+ LOG_ERROR(("Invalid Tag (tstrTag = %#x)", tstrTag));
+ return STATUS_INVALID_TAG;
+ }
+
+ if (MIB_TYP(tstrTag) != MTYPE_TSTRING)
+ {
+ LOG_ERROR(("Invalid table string tag (tag = %#x)", tstrTag));
+ return STATUS_INVALID_TAG;
+ }
+
+
+ if (Success == snmp_setEntry(tstrTag, idx, (void*) tstr, byteCount))
+ {
+ oam_processTrap(srcModuleId, tstrTag, VT_TABLE,
+ (int) oam_getMibAddress(tstrTag, idx), idx);
+ return STATUS_OK;
+ }
+ LOG_ERROR(("Invalid Parameters (tstrTag =%s(%#x), idx = %d, tstr = %#x, byteCount=%d)",
+ snmp_tagName(tstrTag), tstrTag, idx, tstr, byteCount));
+
+ return STATUS_NOK;
+
+}
+
+/******************************************************************
+** API used to subscribe trap
+******************************************************************/
+
+/*
+* Applications interested in receiving notification
+* when the value of certain MIB variables get changed can do so
+* by calling following APIs.
+*/
+
+/* setting trap on a single MIB variable */
+STATUS oam_setTrap (OCTET_T srcModuleId, MSG_Q_ID msgQid, MibTag mibTag)
+{
+ ListNodePtr nodePtr;
+ int status = STATUS_NO_MEMORY;
+ nodePtr = oam_newListNode(mibTag, msgQid);
+ if (nodePtr != NULL)
+ {
+ nodePtr->mid = srcModuleId;
+ oam_lockMutex();
+ status = oam_insertNodeSortedByTag(oam_getTrapTableHead(),nodePtr);
+ oam_unlockMutex();
+ }
+ return status;
+
+}
+
+STATUS setTrap (OCTET_T srcModuleId, MSG_Q_ID msgQid, MibTag mibTag)
+{
+ return oam_setTrap(srcModuleId, msgQid, mibTag);
+}
+
+/* setting trap on a multiple MIB variables */
+STATUS oam_setMultipleTrap (OCTET_T srcModuleId, MSG_Q_ID msgQid, MibTag mibTag[], INT_32_T tagCount)
+{
+ ListNodePtr nodePtr;
+ int i, status = STATUS_OK;
+ oam_lockMutex();
+ for (i= 0; i < tagCount && status == STATUS_OK; i++)
+ {
+ nodePtr = oam_newListNode(mibTag[i], msgQid);
+ if (nodePtr != NULL)
+ {
+ nodePtr->mid = srcModuleId;
+ status = oam_insertNodeSortedByTag(oam_getTrapTableHead(),nodePtr);
+ } else {
+ status = STATUS_NO_MEMORY;
+ }
+ }
+ oam_unlockMutex();
+ return STATUS_OK;
+
+}
+
+/* setting trap on a multiple MIB variables */
+STATUS oam_unsetTrapByModule (OCTET_T srcModuleId)
+{
+ int status;
+ oam_lockMutex();
+ status= oam_deleteNodeByModule(oam_getTrapTableHead(), srcModuleId);
+ oam_unlockMutex();
+ return status;
+
+}
+
+
+/* setting trap on a multiple MIB variables */
+STATUS oam_unsetTrap(OCTET_T srcModuleId, MibTag tag)
+{
+ int status;
+ oam_lockMutex();
+ status= oam_deleteNode(oam_getTrapTableHead(), tag, srcModuleId);
+ oam_unlockMutex();
+ return status;
+
+}
+
+
+/* sends the actual message through message queue */
+static STATUS oam_trapSend(MSG_Q_ID qid, char * trapMsg)
+{
+
+ /* send a normal priority message, blocking if queue is full */
+#if (defined(VXWORKS))
+ int status;
+ status = msgQSend (qid, trapMsg, sizeof (TrapMsg), WAIT_FOREVER,
+ MSG_PRI_NORMAL);
+ if (status == ERROR)
+ {
+
+ /* We need to check here the followings:
+ S_objLib_OBJ_ID_LOG_ERROR
+ - msgQId is invalid.
+ S_objLib_OBJ_DELETED
+ - the message queue was deleted while waiting to a send message.
+ */
+ return STATUS_MSGQ_SEND_ERROR;
+ }
+#endif
+
+ return STATUS_OK;
+}
+
+STATUS oam_processTrap(OCTET_T srcMdlId, MibTag tag, OCTET_T valueType, INT_32_T newValue, int idx)
+{
+
+ TrapMsg trapMsg;
+ ListNodePtr nodePtr;
+
+ static char fname[] ="oam_processTrap";
+ int prevModuleId;
+
+ LOG_TRACE(("(module=%d, tag=%s, vt=%d, value=%#x, idx=%d)", srcMdlId, snmp_tagName(tag), valueType, newValue, idx));
+
+ /* Poputlate the Trap Message */
+ trapMsg.srcModuleId = MODULE_OAM; /* always MODULE_OAM */
+ trapMsg.msgType = MT_TRAP;
+ trapMsg.mibTag = tag;
+ trapMsg.valType = valueType;
+
+
+ switch(valueType)
+ {
+ case VT_VALUE:
+ {
+ trapMsg.val.varVal = newValue;
+ break;
+ }
+ case VT_ADDRESS:
+ {
+
+ trapMsg.val.varAdr = (void *) newValue;
+ break;
+ }
+ case VT_TABLE:
+ {
+ trapMsg.val.varTbl.idx = idx;
+ trapMsg.val.varTbl.value = newValue;
+ break;
+ }
+ default:
+ LOG_ERROR(("Invalid value type: %d", valueType));
+ return STATUS_INVALID_PARAMS;
+ break;
+ }
+
+ /* The 2nd condition should only be evaluated if the 1st is True.
+ * The condition inside the while loop below shoud be safe.
+ */
+ prevModuleId = -1;
+ nodePtr = oam_getFirstNodeByTag(oam_getTrapTableHead(), tag);
+
+ while(nodePtr != NULL && MIB_TBL(nodePtr->tag) == MIB_TBL(tag))
+ {
+
+ if (nodePtr->mid != srcMdlId && prevModuleId != nodePtr->mid
+ && (MIB_TYP(nodePtr->tag) == MTYPE_STRUCT || nodePtr->tag == tag))
+ {
+
+ /*
+ * We should not trap the module which sets the variable.
+ */
+ if (oam_trapSend(nodePtr->qid, (char *) &trapMsg) != STATUS_OK)
+ {
+ LOG_ERROR(("Message Queue Send failure (mid = %d, qid = %#x", nodePtr->mid, nodePtr->qid));
+ perror("Reason of Failure");
+
+ }
+
+ prevModuleId = nodePtr->mid;
+ LOG_TRACE(("Sent Trap Message on tag %s to %d module", snmp_tagName(tag), nodePtr->mid));
+
+ }
+ nodePtr = nodePtr->next;
+ }
+ return STATUS_OK;
+}
+
+/* this function returns byte arrary from a given integer value */
+
+STATUS oam_getByteAryByInt(INT_32_T intVal, char * byteAry, int size)
+{
+ int i;
+
+ if ( intVal < 0 || byteAry == NULL || size <1 )
+ return STATUS_INVALID_PARAMS;
+ memset(byteAry, 0, size);
+ for (i = size-1; i>=0 && intVal > 0; i--)
+ {
+ byteAry[i] = intVal%10;
+ intVal = intVal/10;
+ }
+ return STATUS_OK;
+}
+
+/* Test Print Routine */
+void oam_printTrapList()
+{
+ oam_printList(oam_getTrapTableHead());
+}
+
+/* oam message printing routine */
+void oam_msgPrint(char *format, ...)
+{
+ va_list marker;
+ va_start( marker, format ); /* Initialize variable arguments. */
+ vprintf(format, marker);
+ printf("\n");
+ fflush(stdout);
+ va_end( marker ); /* Reset variable arguments. */
+ return;
+
+}
+
diff --git a/data/mnet/Common/snmp/src/snmpLocalIoLib.c b/data/mnet/Common/snmp/src/snmpLocalIoLib.c
new file mode 100644
index 0000000..6ccd047
--- /dev/null
+++ b/data/mnet/Common/snmp/src/snmpLocalIoLib.c
@@ -0,0 +1,327 @@
+/*
+************************************************************************
+*
+* (c) Copyright Cisco 2000
+* All Rights Reserved
+*_______________________________________________________________________
+*
+* FILE NAME: sndcpLocalIo.c
+*
+* DESCRIPTION: This file contains snmp Local I/O routines that links
+* WindSnmp Callback to our customized get, set, test, next
+* etc method handlers.
+*
+* COMPONENTS:
+*
+*
+* NOTES:
+*
+* REVISION HISTORY:
+*----------+--------+---------------------------------------------------
+* Name | Date | Reason
+*----------+--------+---------------------------------------------------
+* Bhawani |01/23/01| Initial Draft
+*----------+--------+---------------------------------------------------
+************************************************************************
+*/
+
+#include <vxWorks.h>
+#include <stdio.h>
+#include <sys/socket.h>
+#include <sockLib.h>
+#include <sys/types.h>
+#include <netinet/in.h>
+#include <ioLib.h>
+#include <taskLib.h>
+#include <snmpdLib.h>
+#include <snmpIoLib.h>
+#include <view.h>
+#include <snmpstat.h>
+#include <auxfuncs.h>
+#include <hostLib.h>
+#include <inetLib.h>
+#include <buildpkt.h>
+#include <objectid.h>
+#include <m2Lib.h>
+#include <semLib.h>
+#include <subInstall.h>
+
+
+#include <timers.h>
+#include <selectLib.h>
+
+#include "oam_api.h"
+#include "vipermib.h"
+#include "vipertbl.h"
+
+#define SNMP_PORT 161 /* port for snmp */
+#define TRAP_PORT 162 /* port for snmp traps */
+
+/*
+************************************************************************
+* External variable defined snmpIoLib.c
+************************************************************************
+*/
+
+extern int snmpRemoteIP;
+extern int snmpRemotePort;
+extern int snmpProxyIP;
+
+
+/* Snmp Call back routines */
+typedef int (*SnmpFuncPtr) (SNMP_PKT_T *pktp);
+extern SnmpFuncPtr pSnmpPrivateRelease;
+extern SnmpFuncPtr pSnmpSetPduValidate;
+extern SnmpFuncPtr pSnmpPreSetRoutine;
+extern SnmpFuncPtr pSnmpPostSetRoutine;
+extern SnmpFuncPtr pSnmpSetFailedRoutine;
+
+/* SNMP PDU Processing method routines */
+typedef void (*SnmpPduProsFuncPtr) (
+ OIDC_T lastmatch,
+ int compc,
+ OIDC_T *compl,
+ SNMP_PKT_T *pktp,
+ VB_T *vbp);
+
+extern SnmpPduProsFuncPtr pSnmpTestMethod;
+extern SnmpPduProsFuncPtr pSnmpGetMethod ;
+extern SnmpPduProsFuncPtr pSnmpNextMethod;
+extern SnmpPduProsFuncPtr pSnmpSetMethod;
+
+typedef void (*SnmpCallbackFuncPtr) (int snmpSocket);
+
+extern SnmpCallbackFuncPtr pSnmpCallbackHandler;
+
+/* struct for community to view index mapping */
+typedef struct {
+ char * Cmnty;
+ int viewIndex;
+} CMNTY_TO_VIEW_T;
+
+static CMNTY_TO_VIEW_T getCmntyViewTbl[] = { {NULL, 1},
+ {NULL, 1},
+ {"icmp", 2},
+ {NULL, 0}
+ };
+
+typedef int (*SnmpIoCommunityValidateFuncPtr) (
+ SNMP_PKT_T * pPkt, /* ptr to snmp pkt */
+ SNMPADDR_T * pRemoteAddr, /* remote address */
+ SNMPADDR_T * pLocalAddr /* local address */
+ );
+
+extern SnmpIoCommunityValidateFuncPtr pSnmpLocalIoCommunityValidate;
+
+int snmpLocalIoCommunityValidate(SNMP_PKT_T *pPkt, SNMPADDR_T *pRemoteAddr,
+ SNMPADDR_T *pLocalAddr);
+
+/* Defined other places */
+extern void snmp_initializeMib();
+extern void snmp_getMethod (
+ OIDC_T lastmatch,
+ int compc,
+ OIDC_T *compl,
+ SNMP_PKT_T *pktp,
+ VB_T *vbp);
+
+extern void snmp_setMethod(
+ OIDC_T lastmatch,
+ int compc,
+ OIDC_T *compl,
+ SNMP_PKT_T *pktp,
+ VB_T *vbp);
+
+extern void snmp_nextMethod (
+ OIDC_T lastmatch,
+ int compc,
+ OIDC_T *compl,
+ SNMP_PKT_T *pktp,
+ VB_T *vbp);
+
+
+extern void snmp_testMethod (
+ OIDC_T lastmatch,
+ int compc,
+ OIDC_T *compl,
+ SNMP_PKT_T *pktp,
+ VB_T *vbp);
+
+
+/* gets string dot form IP from 32 bit unsighed integer */
+
+char * IPDotAddr( int addr)
+{
+ static char buf[20];
+ unsigned char *ip = (unsigned char *) &addr;
+
+ sprintf(buf, "%d.%d.%d.%d", ip[3], ip[2], ip[1], ip[0]);
+ return buf;
+}
+
+
+
+/* Snmp User Private release routine */
+int SnmpPrivateRelease ( SNMP_PKT_T *pktp)
+{
+ return 0;
+};
+
+/* Snmp Set PDU validate routine */
+int SnmpSetPduValidate ( SNMP_PKT_T *pktp)
+{
+ return 0;
+};
+
+
+/* SNMP Pre set Routine */
+int SnmpPreSetRoutine ( SNMP_PKT_T *pktp)
+{
+ return 0;
+};
+
+
+/* Snmp Set Failed Routine */
+int SnmpSetFailedRoutine ( SNMP_PKT_T *pktp)
+{
+ return 0;
+};
+
+/* Snmp Local IO Init routine */
+snmpLocalIoInit()
+{
+ /* Populate Call back routines */
+
+ pSnmpPrivateRelease = SnmpPrivateRelease;
+ pSnmpSetPduValidate = SnmpSetPduValidate;
+ pSnmpPreSetRoutine = SnmpPreSetRoutine;
+ pSnmpSetFailedRoutine = SnmpSetFailedRoutine;
+
+ /* Populate PDU Processing routines */
+
+ pSnmpTestMethod = snmp_testMethod;
+ pSnmpGetMethod = snmp_getMethod;
+ pSnmpNextMethod = snmp_nextMethod;
+ pSnmpSetMethod = snmp_setMethod;
+
+ pSnmpLocalIoCommunityValidate = snmpLocalIoCommunityValidate;
+
+}
+
+void snmpLocalInitCommunityNames()
+{
+
+ /* community table for gets, NULL entry terminated */
+ getCmntyViewTbl[0].Cmnty = oam_getMibAddress(MIB_readCommunity);
+ getCmntyViewTbl[1].Cmnty = oam_getMibAddress(MIB_writeCommunity);
+
+ if (strlen(getCmntyViewTbl[0].Cmnty) == 0)
+ {
+ strcpy(getCmntyViewTbl[0].Cmnty, "public");
+ }
+
+ if (strlen(getCmntyViewTbl[1].Cmnty) == 0)
+ {
+ strcpy(getCmntyViewTbl[1].Cmnty, "private");
+ }
+}
+
+
+/*******************************************************************************
+* snmpLocalIoCommunityValidate - community validation routine
+*
+* This routine is used to set up the view-index field in the SNMP
+* packet. This product is shipped with defaults such that the "priv"
+* community is allowed to `set' variables, and the "pub" community is
+* allowed to `get' variables.
+*
+* The agent designer is required to write this function according to
+* the design of the application.
+*
+* RETURNS: 0 if the community is acceptable, otherwise 1.
+*/
+
+int snmpLocalIoCommunityValidate
+ (
+ SNMP_PKT_T * pPkt, /* ptr to snmp pkt */
+ SNMPADDR_T * pRemoteAddr, /* remote address */
+ SNMPADDR_T * pLocalAddr /* local address */
+ )
+{
+ int pktCmntyLen; /* length of community string
+ in received pkt */
+ CMNTY_TO_VIEW_T * pEntry; /* ptr to traverse community
+ to view tables */
+
+ char * pCmnty; /* ptr to Cmnty field */
+
+ /* We don't use private memory so set this to NULL else the
+ * hook to release this is invoked if non NULL
+ */
+
+ pPkt->user_private = (char *) 0;
+
+ /*
+ * Install the local and remote network addresses in the packet.
+ * These will be used later to respond to this pdu
+ */
+
+ (void) memcpy ((char *) &(pPkt->pkt_src), (char *) pRemoteAddr,
+ sizeof (struct sockaddr_in));
+ (void) memcpy((char *) &(pPkt->pkt_dst), (char *) pLocalAddr,
+ sizeof (struct sockaddr_in) );
+
+ pktCmntyLen = EBufferUsed (&(pPkt->community));
+
+ /* select get or set cmmunity to view table as appropriate */
+
+ pEntry = getCmntyViewTbl;
+
+
+ for ( pCmnty = pEntry->Cmnty; pCmnty != NULL;
+ ++ pEntry, pCmnty = pEntry->Cmnty)
+ {
+ if ((strlen (pCmnty) == pktCmntyLen) &&
+ (memcmp (pCmnty, pPkt->community.start_bp, pktCmntyLen) == 0))
+ {
+ pPkt->view_index = pEntry->viewIndex;
+ return (0);
+ }
+ }
+
+ /* Got a bad community if were here, so increment the
+ * snmpInBadCommunityNames counter
+ */
+
+ ++ snmp_stats.snmpInBadCommunityNames;
+
+ /* An auth fail trap may be sent here */
+
+ return (1);
+}
+
+int snmpSetCommunityNames(char *read, char *write)
+{
+ int retValue = STATUS_INVALID_PARAMS;
+
+ if (NULL == read || NULL == write)
+ {
+ return STATUS_INVALID_PARAMS;
+ }
+
+ retValue = oam_setMibByteAry(SNMP_AGENT_MODULE_ID, MIB_readCommunity, read, strlen(read)+1);
+
+
+ if (STATUS_OK == retValue)
+ {
+ printf ("Set read community = %s\n", read);
+ retValue = oam_setMibByteAry(SNMP_AGENT_MODULE_ID, MIB_writeCommunity, write, strlen(write)+1);
+ }
+
+ if ( STATUS_OK == retValue)
+ {
+ printf ("Set write community = %s\n", write);
+ }
+
+ return retValue;
+}
diff --git a/data/mnet/Common/snmp/src/snmp_fileio.c b/data/mnet/Common/snmp/src/snmp_fileio.c
new file mode 100644
index 0000000..24eb37b
--- /dev/null
+++ b/data/mnet/Common/snmp/src/snmp_fileio.c
@@ -0,0 +1,492 @@
+
+/*
+************************************************************************
+*
+* (c) Copyright Cisco 2000
+* All Rights Reserved
+*-----------------------------------------------------------------------
+*
+* FILE NAME: snmp_fileio.c
+*
+* DESCRIPTION: This file contains snmp agent file I/O routines
+*
+*
+* COMPONENTS:
+*
+*
+* NOTES:
+*
+* REVISION HISTORY:
+*----------+--------+---------------------------------------------------
+* Name | Date | Reason
+*----------+--------+---------------------------------------------------
+* Bhawani |02/28/00| Initial Draft
+*----------+--------+---------------------------------------------------
+************************************************************************
+*/
+
+/*
+************************************************************************
+* Common Include files
+************************************************************************
+*/
+#include <vxWorks.h>
+#include <stdlib.h>
+#include <stdio.h> /* for printf... */
+#include <string.h>
+
+#include <ioLib.h>
+#include <fioLib.h>
+#include <wdLib.h>
+#include <sysLib.h>
+#include <taskLib.h>
+#include <inetLib.h>
+#include <rebootLib.h>
+
+
+#include "vipermib.h" /* Get the MIB definitions. */
+#include "vipertbl.h" /* Control Table definitions. */
+
+
+/********************************************************************
+* Defines
+*********************************************************************/
+
+
+#define FMT_SPEC_STRING "%s.%u=\"%s\"\n"
+#define FMT_SPEC_NUMBER "%s.%u=\"%d\"\n"
+#define SIZE_MibTagName 128
+#define MAX_LINE SIZE_DisplayString + SIZE_MibTagName + 5
+#define MAX_PATH_NAME 256
+
+/********************************************************************
+* Global variables
+*********************************************************************/
+
+SEM_ID SnmpSemaIo; /* Snmp IO task semaphore */
+char SnmpMibFileNameBuffer[SIZE_DisplayString];
+
+/********************************************************************
+* Defined in vipermib.h
+*********************************************************************/
+
+extern int SnmpMibLoadCount;
+extern int SnmpMibSaveCount;
+extern int SnmpPostSetEnabled;
+extern int SnmpTimerMibFlushDelay;
+extern int SnmpTimerRebootDelay;
+extern int SnmpTimerRebootShortDelay;
+extern char SnmpDefaultMibFileName[];
+
+
+/********************************************************************
+* Routines
+*********************************************************************/
+
+char* StringToken( char* pszThis, char* pszDelims, char** ppszNext )
+{
+ size_t szToken;
+
+ if( pszThis == NULL )
+ pszThis = *ppszNext;
+
+ while( *pszThis != '\0' && 0 == ( szToken = strcspn( pszThis, pszDelims ) ) )
+ pszThis++; /* skipping leading delimiters */
+
+ switch( *pszThis )
+ {
+ case '\0':
+ return NULL;
+
+ case '"': /* remove this case if there's no need to treat quotation marks specially */
+ return StringToken( pszThis + 1, "\"", ppszNext );
+
+ default:
+ if( *( *ppszNext = pszThis + szToken ) != '\0' )
+ *(*ppszNext)++ = '\0';
+
+ return pszThis;
+ }
+}
+
+void StripEOL(char *pStr)
+{
+ int i;
+
+ if (NULL != pStr)
+ {
+ i = strlen(pStr);
+ if ((i > 0) && ((pStr[i-1] == '\r') || (pStr[i-1] == '\n')))
+ {
+ pStr[i-1] = 0;
+ }
+
+ i--;
+ if ((i > 0) && ((pStr[i-1] == '\r') || (pStr[i-1] == '\n')))
+ {
+ pStr[i-1] = 0;
+ }
+ }
+}
+
+
+/* writing mib varible to the file */
+Status snmp_writeString(FILE *fp, char *name, int idx, char *value)
+{
+
+ if ((NULL != value) && (0 != *value))
+ {
+ StripEOL(value);
+ fprintf (fp, FMT_SPEC_STRING, name, idx, value);
+ }
+ else
+ {
+ fprintf (fp, FMT_SPEC_STRING, name, idx, "");
+ }
+
+ return Success;
+}
+
+
+Status snmp_writeIpAddress(FILE *fp, char *name, int idx, UINT32 ip)
+{
+ return snmp_writeString(fp, name, idx, int2ip(ip));
+}
+
+
+Status snmp_writeNumber(FILE *fp, char *name, int idx, UINT32 number)
+{
+ fprintf (fp, FMT_SPEC_NUMBER, name, idx, (int) number);
+ return Success;
+}
+
+
+/* read mib varialbe from the file */
+Status snmp_parseLine(char *pszLine, char *pszTagName, int *pnInstance, char *pszValue)
+{
+ char *pToken;
+
+ if (!(pszLine && pszTagName && pnInstance && pszValue))
+ {
+ return Failure;
+ }
+ /* skip comments */
+
+ if (pszLine[0] == '#' || pszLine[0] == '!')
+ {
+ return Failure;
+ }
+
+ /* extract name */
+ pToken = StringToken(NULL, ".\n\r", &pszLine);
+ if (NULL == pToken)
+ {
+ return Failure;
+ }
+
+ pszTagName[SIZE_MibTagName] = 0;
+ strncpy(pszTagName, pToken, SIZE_MibTagName-1);
+
+
+ /* extract instance */
+ pToken = StringToken(NULL, "=\n\r", &pszLine);
+ if (NULL == pToken)
+ {
+ return Failure;
+ }
+ *pnInstance = atoi(pToken);
+
+ /* extract the value */
+ pToken = StringToken(NULL, " \t\n\r", &pszLine);
+
+ if (pToken == NULL)
+ {
+ return Failure;
+ }
+
+ pszValue[SIZE_DisplayString] = 0;
+ strncpy(pszValue, pToken, SIZE_DisplayString);
+ StripEOL(pszValue);
+ return Success;
+}
+
+
+Status snmp_saveMib(char *name)
+{
+ int i, j, end, tag, cnt = 0;
+ char tmpname[256];
+ Table *tbl;
+ FILE *fp;
+
+ DMSG("ascii mib", printf("snmp_saveMib('%s') called\n", name));
+
+ sprintf(tmpname, "%s.tmp",name);
+
+ /* Try to delete the tmp file */
+ unlink(tmpname);
+
+ if (NULL == (fp = fopen(tmpname, "w+")))
+ {
+
+ snmp_log(True, "Save MiB Error","Could not open file %s for writing (%s)", tmpname, strerror(errno));
+ return Failure;
+ }
+ SnmpMibSaveCount++;
+
+ for ( i=0; tag = mnetMibDataType[i].tag; i++)
+ {
+
+ if (mnetMibDataType[i].flag & SAVE_ASCII_OMIT)
+ {
+
+ DMSG("ascii mib", printf("snmp_saveMib. Skipping item %d, '%s', typ %d\n",
+ i, snmp_tagName(tag), mnetMibDataType[i].type));
+ continue;
+ }
+
+ DMSG("ascii mib", printf("snmp_saveMib. Procesisng item %d, '%s', typ %d\n",
+ i, snmp_tagName(tag), mnetMibDataType[i].type));
+
+ switch(MIB_TYP(tag))
+ {
+ case MTYPE_NUMBER:
+ snmp_writeNumber(fp, mnetMibDataType[i].name, 0, (INT32) snmp_getValue(tag));
+ break;
+
+ case MTYPE_IPADDR:
+ snmp_writeIpAddress(fp, mnetMibDataType[i].name, 0, (INT32) snmp_getValue(tag));
+ break;
+
+ case MTYPE_STRING:
+ snmp_writeString(fp, mnetMibDataType[i].name, 0, (char *) snmp_getValue(tag));
+ break;
+
+ case MTYPE_TNUMBER:
+
+ if ((tbl = snmp_getTableAddress(tag)))
+ {
+ end = table_end(tbl);
+ for (j=0; j < end; j++)
+ {
+ snmp_writeNumber(fp, mnetMibDataType[i].name, j, (INT32) snmp_getValue(tag, j));
+ }
+ }
+ break;
+
+ case MTYPE_TIPADDR:
+
+ if ((tbl = snmp_getTableAddress(tag)))
+ {
+ end = table_end(tbl);
+ for (j=0; j < end; j++)
+ {
+ snmp_writeIpAddress(fp, mnetMibDataType[i].name, j, (INT32) snmp_getValue(tag, j));
+
+ }
+ }
+ break;
+ case MTYPE_TSTRING:
+
+ if ((tbl = snmp_getTableAddress(tag)))
+ {
+ end = table_end(tbl);
+ for (j=0; j < end; j++)
+ {
+ snmp_writeString(fp, mnetMibDataType[i].name, j, (char *) snmp_getValue(tag, j));
+
+ }
+ }
+ break;
+
+ default:
+ DMSG("save mib", printf("Skipped Item %s (type= %d)", mnetMibDataType[i].name, MIB_TYP(tag)));
+ break;
+
+ } /*switch */
+ } /* for */
+ fclose(fp);
+
+ /* Now remove the target file. */
+ unlink(name);
+
+ /* Try to rename the tmp file to the target file */
+ if (rename(tmpname, name) == ERROR)
+ {
+ if (copy(tmpname, name) == ERROR)
+ {
+ snmp_log(False, "snmp_saveMib", "Error: Could not rename/copy file %s to %s: %s", tmpname, name, strerror(errno));
+ return Failure;
+ }
+ unlink(tmpname);
+ }
+
+ return Success;
+}
+
+
+Status snmp_loadMib( char *name)
+{
+ FILE *fs;
+ char buf[MAX_LINE];
+ UINT32 ip;
+
+ int i, idx, tag;
+ int line = 0;
+
+ char pszTagName[SIZE_MibTagName+1];
+ char pszValue[SIZE_DisplayString+1];
+
+ if (NULL == (fs = fopen(name, "r")))
+ {
+ snmp_log(True, "Load Mib Error", "Could not open file %s for reading: %s.", name, strerror(errno));
+ return Failure;
+ }
+
+ snmp_log(False, "snmp_loadMib", "Loading mib from file %s", name);
+ SnmpMibLoadCount++;
+
+ while (NULL != fgets(buf, MAX_LINE, fs))
+ {
+ line++;
+ if (Failure == snmp_parseLine(buf, pszTagName, &idx, pszValue))
+ {
+ continue;
+ }
+
+ /* Search the tagname */
+ for ( i=0; mnetMibDataType[i].tag; i++)
+ {
+ if (!strcmp(mnetMibDataType[i].name, pszTagName))
+ {
+ break;
+ }
+ }
+
+ tag = mnetMibDataType[i].tag;
+
+ if (0== tag)
+ {
+ snmp_log(True, "Load Mib Error", "%s(%d): %s is not a valid tag.", name, line, pszTagName);
+ continue;
+ }
+
+ switch(MIB_TYP(tag))
+ {
+ case MTYPE_NUMBER:
+ case MTYPE_TNUMBER:
+ snmp_setEntry(tag, idx, (void *) atoi(pszValue), 4);
+ break;
+
+ case MTYPE_IPADDR:
+ case MTYPE_TIPADDR:
+ if (ERROR != (ip = inet_addr(pszValue)))
+ {
+ snmp_setEntry(tag, idx, (void *) ip, 4);
+ }
+ else
+ {
+ /* in case the ip addres is saved as plain integer */
+ snmp_setEntry(tag, idx, (void *) atoi(pszValue), 4);
+ }
+
+ break;
+
+ case MTYPE_STRING:
+ case MTYPE_TSTRING:
+ snmp_setEntry(tag, idx, (void *) pszValue, strlen(pszValue));
+ break;
+
+ default:
+ snmp_log(True, "Load Mib Warning", "%s(%d): tag %s (type=%d) is not not loadable tag.", name, line, pszTagName, MIB_TYP(tag));
+ break;
+ } /* switch */
+ } /* fgets */
+ fclose(fs);
+
+ /* Set SNMP Agent's status */
+ agent_setSnmpEnabled(oam_isSnmpEnabled());
+
+ /* update FTP Server status */
+ oam_setFtpEnabled(oam_isFtpEnabled());
+
+ return Success;
+}
+
+
+/********************************************************************
+* snmp Mib Save Timer
+*********************************************************************/
+WDOG_ID SnmpWdTimer;
+BOOL bIsMibSaveTimerActive = FALSE;
+
+
+void snmp_mibTimerInit()
+{
+ SnmpWdTimer = wdCreate();
+}
+
+void snmp_mibTimerDelete()
+{
+ wdDelete(SnmpWdTimer);
+}
+
+int snmpMibWriteDelayTimeoutHandler(int arg)
+{
+ char *name = (char *) arg;
+
+ /*memset(SnmpMibFileNameBuffer, 0, SIZE_DisplayString); */
+ strncpy(SnmpMibFileNameBuffer, name, SIZE_DisplayString-1);
+ SnmpMibFileNameBuffer[SIZE_DisplayString-1] = 0;
+ semGive (SnmpSemaIo);
+ bIsMibSaveTimerActive = FALSE;
+ return Success;
+};
+
+void snmp_mibTimerSet(char* arg)
+{
+ if (TRUE == bIsMibSaveTimerActive)
+ {
+ wdCancel(SnmpWdTimer);
+ }
+ wdStart(SnmpWdTimer, SnmpTimerMibFlushDelay*sysClkRateGet(), snmpMibWriteDelayTimeoutHandler, (int) arg);
+ bIsMibSaveTimerActive = TRUE;
+}
+
+int snmp_reboot(int delay)
+{
+ SnmpPostSetEnabled = False;
+
+ if (TRUE == bIsMibSaveTimerActive)
+ {
+ wdCancel(SnmpWdTimer);
+ if (delay < SnmpTimerRebootShortDelay)
+ {
+ delay = SnmpTimerRebootShortDelay;
+ }
+ SnmpTimerRebootDelay = delay*sysClkRateGet();
+ snmpMibWriteDelayTimeoutHandler((int) SnmpDefaultMibFileName);
+ }
+ return OK;
+}
+
+int snmp_ioThread(int arg)
+{
+ do
+ {
+ semTake (SnmpSemaIo, WAIT_FOREVER);
+ snmp_saveMib(SnmpMibFileNameBuffer);
+ }while (SnmpTimerRebootDelay <= 0);
+
+ taskDelay(SnmpTimerRebootDelay);
+ reboot(0);
+ return OK;
+}
+
+void snmp_initIoTask()
+{
+
+ SnmpSemaIo = semBCreate (SEM_Q_FIFO, SEM_EMPTY);
+ taskSpawn("tSnmpIo", 100, 0, 40000, (FUNCPTR) snmp_ioThread,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
+}
+
diff --git a/data/mnet/Common/snmp/src/snmp_trap.c b/data/mnet/Common/snmp/src/snmp_trap.c
new file mode 100644
index 0000000..cde12be
--- /dev/null
+++ b/data/mnet/Common/snmp/src/snmp_trap.c
@@ -0,0 +1,437 @@
+/*********************************************************************/
+/* */
+/* (c) Copyright Cisco 2000-2001 */
+/* All Rights Reserved */
+/* */
+/*********************************************************************/
+
+/*********************************************************************/
+/* */
+/* Version : 1.0 */
+/* Status : Under development */
+/* File : snmp_trap.h */
+/* Author(s) : Bhawani Sapkota */
+/* Create Date : 02/05/01 */
+/* Description : This file contains routines to send SNMP enterprise */
+/* trap to multiple destinations. */
+/* */
+/*********************************************************************/
+/* REVISION HISTORY */
+/*___________________________________________________________________*/
+/*----------+--------+-----------------------------------------------*/
+/* Name | Date | Reason */
+/*----------+--------+-----------------------------------------------*/
+/* Bhawani |02/05/01| Initial Draft */
+/*----------+--------+-----------------------------------------------*/
+/*********************************************************************/
+
+
+/*******************************************************************************
+** Include Files
+*******************************************************************************/
+
+
+#include <vxWorks.h>
+#include <sys/socket.h>
+#include <snmpdLib.h>
+#include <snmpIoLib.h>
+#include <hostLib.h>
+#include <inetLib.h>
+
+#include <symLib.h>
+#include <sysSymTbl.h>
+#include <loadLib.h>
+#include <usrLib.h>
+#include <stdio.h>
+#include <taskLib.h>
+
+#include "oam_api.h"
+
+/* Allocation default severity of AlarmCode space per module */
+#define ALARM_CRITICAL_START_POINT 0x0001
+#define ALARM_MAJOR_START_POINT 0x0100
+#define ALARM_MINOR_START_POINT 0x0800
+#define ALARM_INFO_START_POINT 0x1000
+
+#define ALARM_SEV_CRITICAL 1
+#define ALARM_SEV_MAJOR 2
+#define ALARM_SEV_MINOR 3
+#define ALARM_SEV_INFORMATION 4
+
+#define MAX_LINE 512
+#define CLEAN_MSG 40
+
+struct alarmDetail_t
+{
+ int code;
+ char *synopsis;
+ char *detail;
+ struct alarmDetail_t *next;
+};
+
+typedef struct alarmDetail_t AlarmEntry;
+
+AlarmEntry *AlarmListEntryHead = NULL;
+/*-------------------------------------------------------------------------------*/
+AlarmEntry *
+ReadAlarmFile()
+{
+ FILE *fp;
+ char buffer[MAX_LINE];
+ char *subject1=NULL,*subject2=NULL;
+ AlarmEntry *head=NULL, *node=NULL, *tmpNode;
+ int len,i=0,j,slen;
+
+
+ memset(buffer, 0, MAX_LINE);
+ strcpy(buffer, getenv( "MNET_BASE" ));
+ strcat(buffer,"/Alarm/AlarmCode.English");
+
+ fp = fopen(buffer, "r");
+ if (fp == NULL)
+ {
+ printf("Cannot open Alarm Code file: %s\n", buffer);
+ perror("Reason:");
+ return NULL;
+ }
+
+ while(fgets(buffer, MAX_LINE, fp) != NULL)
+ {
+ /* skip line starting with / or # as comments */
+ if (buffer[0] =='/' || buffer[0] == '#')
+ continue;
+
+ tmpNode = (AlarmEntry *) malloc(sizeof(AlarmEntry));
+ if (tmpNode == NULL)
+ {
+ printf("tmpNode Memory Allocaton Failure");
+ break;
+ }
+
+ if (head == NULL)
+ {
+ head = node = tmpNode;
+ } else {
+ node->next = tmpNode;
+ node = node->next;
+ }
+
+ sscanf(buffer, "%d", &node->code);
+
+ subject1 = strstr(buffer, "|");
+ subject1++; i=0;
+ while(subject1[i++] != '|');
+
+ subject2 = strstr(subject1, "|");
+ subject2++;
+
+ node->synopsis = malloc(i);
+ memset(node->synopsis,0,i);
+ if(node->synopsis == NULL)
+ {
+ printf("synopsis : Memory Allocaton(%d) Failure\n%s\n",i,subject1);
+ break;
+ }
+ for(j=0;j<i - 1 ;j++)
+ node->synopsis[j]=subject1[j];
+
+
+
+ /* remove the end of line */
+ slen = strlen(subject2);
+ node->detail = malloc(slen+1);
+ memset(node->detail,0,slen+1);
+ if(node->detail == NULL)
+ {
+ printf("detail : Memory Allocaton(%d) Failure\n%s\n",slen,subject2);
+ break;
+ }
+ for(j=0;j<slen - 1 ;j++)
+ node->detail[j]=subject2[j];
+ }
+
+ fclose(fp);
+ if (node != NULL)
+ {
+ node->next = NULL;
+ }
+ return head;
+}
+
+
+char *trapAlarmDetail(int errorcode)
+{
+
+ AlarmEntry *tmpNode;
+ char *noDetail="Undifined alarm code";
+
+ if (AlarmListEntryHead == NULL)
+ AlarmListEntryHead = ReadAlarmFile();
+
+ tmpNode = AlarmListEntryHead;
+
+ while( tmpNode && tmpNode->code != errorcode)
+ {
+ tmpNode = tmpNode->next;
+ }
+
+ if ( tmpNode != NULL){
+ return tmpNode->synopsis;
+ }
+ return noDetail;
+}
+
+/*******************************************************************************
+*
+* Snmp Trap Callback Var Bind Data
+*/
+
+typedef struct SnmpTrapCallbackData_
+{
+ MibTag mibTag;
+ int snmpVersion;
+}SnmpTrapCallbackData;
+
+static INT_32_T getAlarmSev(INT_32_T errorCode)
+{
+ INT_32_T alarmCode;
+
+ alarmCode=(errorCode&0xFFFF);
+
+ if(alarmCode >= ALARM_INFO_START_POINT)
+ return ALARM_SEV_INFORMATION;
+ if(alarmCode >= ALARM_MINOR_START_POINT)
+ return ALARM_SEV_MINOR;
+ if(alarmCode >= ALARM_MAJOR_START_POINT)
+ return ALARM_SEV_MAJOR;
+
+ return ALARM_SEV_CRITICAL;
+}
+
+/*******************************************************************************
+*
+* trapBindVals - bind values in the trap
+*
+* This routine binds snmpv2 format variable to Snmp packet.
+*
+* RETURNS: OK, or ERROR if the bind to the SNMP packet fails
+*/
+
+
+
+int snmp_trapBindVals
+(
+ SNMP_PKT_T * pkt, /* internal representation of SNMP packet */
+ void * vals /* null cookie */
+ )
+{
+ static OIDC_T sysUpTimeOid [] = {1, 3, 6, 1, 2, 1, 1, 3, 0};
+ static OIDC_T snmpTrapOID [] = {1, 3, 6, 1, 6, 3, 1, 1, 4, 1, 0};
+
+ INT_32_T errorCode;
+ int i = 0;
+ int mid,severity;
+ char *alarmDetail;
+ char *moduleName;
+ char *alarmClearMsg="Module alarm has cleared.";
+
+ extern OIDC_T sysTrapOid [];
+ extern OIDC_T snmpTrapEventOid[];
+ extern OIDC_T errorCodeOamOid[];
+
+ extern OIDC_T trapAlarmModuleNameOid[];
+ extern OIDC_T trapAlarmCodeOid[];
+ extern OIDC_T trapAlarmDescOid[];
+
+ extern int SIZE_sysTrapOid;
+ extern int SIZE_snmpTrapEventOid;
+ extern int SIZE_errorCodeOamOid;
+
+ extern int SIZE_trapAlarmModuleNameOid;
+ extern int SIZE_trapAlarmCodeOid;
+ extern int SIZE_trapAlarmDescOid;
+
+
+ SnmpTrapCallbackData *pSnmpTrapCallbackData = ( SnmpTrapCallbackData*) vals;
+ MibTag tag = pSnmpTrapCallbackData->mibTag;
+ int version = pSnmpTrapCallbackData->snmpVersion;
+
+ int itm = MIB_ITM(tag);
+
+ static char fname[] = "snmp_trapBindVals";
+
+ LOG_TRACE(("Processing Trap Bind Vals for tag %s", snmp_tagName(tag)));
+
+ /* Release the Trap data first */
+ free (pSnmpTrapCallbackData);
+
+ /* First get the value of the error code */
+ errorCode = snmp_getValue(tag);
+ moduleName=GetMnetModuleName(itm - 1);
+
+ if(errorCode){
+ alarmDetail=trapAlarmDetail(errorCode);
+ severity=getAlarmSev(errorCode);
+ }
+ else
+ {
+ alarmDetail=alarmClearMsg;
+ severity=ALARM_SEV_INFORMATION;
+ }
+
+ snmpTrapEventOid[SIZE_snmpTrapEventOid-1] = severity;
+ errorCodeOamOid[SIZE_errorCodeOamOid-1] = itm;
+
+ if(version == SNMP_VERSION_2)
+ {
+ /* Bind the System upTime as the first variable */
+ if ((SNMP_Bind_Integer (pkt, i++, sizeof sysUpTimeOid / sizeof sysUpTimeOid [0], sysUpTimeOid,
+ ((tickGet()/sysClkRateGet())*100))) == -1)
+ return (ERROR);
+
+ /* Bind sys Trap OID */ /* Raju: Change sysTrapOid to snmpTrapOID to make it work with HPOV */
+ if ((SNMP_Bind_Object_ID (pkt, i++, sizeof snmpTrapOID/sizeof snmpTrapOID[0], snmpTrapOID,
+ SIZE_snmpTrapEventOid, snmpTrapEventOid)) == -1)
+ return (ERROR);
+ }
+
+ if (SNMP_Bind_String(pkt,i++,SIZE_trapAlarmModuleNameOid,trapAlarmModuleNameOid,VT_STRING,strlen(moduleName),moduleName,0) == -1)
+ {
+ printf("SNMP_Bind_String error in moduleName(%s)\n",moduleName);
+ return (ERROR);
+ }
+
+ if ((SNMP_Bind_Integer (pkt, i++, SIZE_trapAlarmCodeOid, trapAlarmCodeOid, errorCode)) == -1)
+ return (ERROR);
+
+ if (SNMP_Bind_String(pkt,i++,SIZE_trapAlarmDescOid,trapAlarmDescOid,VT_STRING,strlen(alarmDetail),alarmDetail,0) == -1)
+ {
+ printf("SNMP_Bind_String error in alarmDetail(%s)\n",alarmDetail);
+ return (ERROR);
+ }
+
+ return (OK);
+}
+
+
+/*******************************************************************************
+*
+* TrapFwdEntry - Get the Trap table entry
+*
+* RETURNS: Trap Table entry or NULL
+*/
+
+TrapFwdEntry *snmp_trapEntryGet(int idx)
+{
+ TrapFwdEntry *trapEntry;
+
+ trapEntry = (TrapFwdEntry *) snmp_getAddress(MIBT_trapFwdEntry, idx);
+
+ if (trapEntry->trapIpAddress != NULL)
+ {
+ return trapEntry;
+ }
+ return NULL;
+
+}
+
+/*******************************************************************************
+*
+* snmp_trapBroadcast - send a SNMP enterprise specific to all the destination
+* configured at trap config table.
+*
+*
+* RETURNS: N/A
+*/
+
+void snmp_trapBroadcast(MibTag tag)
+{
+ void * pDestAddr[1]; /* array of pointers to hosts */
+ struct sockaddr_in destAddr[1]; /* inet. domain addr. struct */
+ u_long snmpLocalIP; /* trap sender's ipaddress */
+ IMPORT int snmpSocket; /* socket descriptor for snmp */
+ char localhostname[MAXHOSTNAMELEN];
+ TrapFwdEntry* pTrapEntry;
+ int index;
+
+ extern OIDC_T enterpriseOid[];
+ extern int SIZE_enterpriseOid;
+
+ SnmpTrapCallbackData *pSnmpTrapCallbackData = NULL;
+ static char fname[] = "snmp_trapBroadcast";
+
+
+ /* agent's ipaddress converted from dot to long integer in network order */
+ gethostname(localhostname, MAXHOSTNAMELEN);
+ snmpLocalIP = hostGetByName(localhostname);
+
+ destAddr[0].sin_family = AF_INET;
+ pDestAddr[0] = &destAddr[0];
+
+ for (index = 0; index < TrapFwdTableLimit; index++)
+ {
+ pTrapEntry = snmp_trapEntryGet(index);
+
+
+ if (pTrapEntry)
+ {
+ LOG_TRACE(("Trap Entry type=%d, ip=%#x, port=%d, community=%s", pTrapEntry->trapType,
+ pTrapEntry->trapIpAddress, pTrapEntry->trapPort, pTrapEntry->trapCommunity));
+
+ destAddr[0].sin_port = htons (pTrapEntry->trapPort);
+ destAddr[0].sin_addr.s_addr = pTrapEntry->trapIpAddress;
+
+ pSnmpTrapCallbackData = (SnmpTrapCallbackData *) malloc(sizeof(SnmpTrapCallbackData));
+ pSnmpTrapCallbackData->mibTag = tag;
+
+ if (pTrapEntry->trapType == VAL_trapType_snmpv1Trap)
+ {
+ pSnmpTrapCallbackData->snmpVersion = SNMP_VERSION_1;
+
+ snmpdTrapSend
+ (
+ &snmpSocket, /* void* snmp agent transport endpoint */
+ 1, /* int number of destinations */
+ pDestAddr, /* void** array of ptrs to destinations */
+ NULL, /* void* local address */
+ SNMP_VERSION_1, /* int SNMP version */
+ pTrapEntry->trapCommunity, /* char* trap community string */
+ enterpriseOid, /* OIDC_T* agent object identifier */
+ SIZE_enterpriseOid, /* int length of agent object identifier */
+ &snmpLocalIP, /* u_long* ip address of sender */
+ ENTERPRISE_SPECIFIC, /* int trap type */
+ MIB_ITM(tag), /* int trap specific code */
+ 3, /* int number of varbinds in packet */
+ snmp_trapBindVals, /* FUNCPTR routine to bind varbinds */
+ (void*) pSnmpTrapCallbackData /* void* argument to binding routine */
+ );
+
+ }
+ else
+ {
+ pSnmpTrapCallbackData->snmpVersion = SNMP_VERSION_2;
+ snmpdTrapSend
+ (
+ &snmpSocket, /* void* snmp agent transport endpoint */
+ 1, /* int number of destinations */
+ pDestAddr, /* void** array of ptrs to destinations */
+ NULL, /* void* local address */
+ SNMP_VERSION_2, /* int SNMP version */
+ pTrapEntry->trapCommunity, /* char* trap community string */
+ NULL, /* OIDC_T* agent object identifier */
+ 0, /* int length of agent object identifier */
+ &snmpLocalIP, /* u_long* ip address of sender */
+ ENTERPRISE_SPECIFIC, /* int trap type */
+ 0, /* int trap specific code */
+ 5, /* int number of varbinds in packet */
+ snmp_trapBindVals, /* FUNCPTR routine to bind varbinds */
+ (void*) pSnmpTrapCallbackData /* void* argument to binding routine */
+ );
+ }
+
+
+ }
+ }
+}
+
+
diff --git a/data/mnet/Common/snmp/src/table.c b/data/mnet/Common/snmp/src/table.c
new file mode 100644
index 0000000..b12733d
--- /dev/null
+++ b/data/mnet/Common/snmp/src/table.c
@@ -0,0 +1,1129 @@
+/*--------------------------------------------------------------------------
+ *
+ * table.c Table handling routines
+ *
+ * This is a collection of routines that provide a simple method of
+ * handling a set of data structures.
+ *
+ * Add more and a simple tutorial.
+ *
+ * tbl = table_create(sizeof(TableEntry))
+ * table_free(tbl)
+ *
+ * Another way to look at the difference in this routine is where is in
+ * who's process space does the memory block reside? When one grabs the
+ * pointer to a row of a table, the table is managed by the SNMP manager
+ * and a pointer to the "live" data is returned. On the other hand, when
+ * one uses this function, rather than refering to the "live" data, a
+ * copy of the data is made into the buffer the task specified.
+ *
+ * You may have noticed that table_setRow is the only set function for
+ * the table routines. Since the table_getNth routines return a pointer
+ * to the table row, it is not necessary to have an equivalent set of
+ * functions to write the data. The following code fragment illustrates
+ * the difference:
+ *
+ * typedef struct Entry_t {
+ * int item1;
+ * int item2;
+ * int item3;
+ * } Entry;
+ *
+ * Table *tbl;
+ * Entry entry, *row;
+ * int idx;
+ *
+ * tbl = table_alloc(sizeof(Entry));
+ *
+ * The first method of loading entries into the table:
+ *
+ * idx = -1;
+ * while (++idx < 10) {
+ * entry.item1=1;
+ * entry.item2=2;
+ * entry.item3=3;
+ * table_setEntry(tbl, idx, &entry, sizeof(Entry));
+ * }
+ *
+ * The second method of loading entries into the table:
+ *
+ * table_extend(tbl, 10); * Extend the table to handle 10 rows.
+ * idx = -1; * Otherwise table_getNth will return
+ * while (++idx < 10) { * a NULL ptr if the row is not there.
+ * row = (Entry *)table_getRow(tbl, idx);
+ * row->item1=1;
+ * row->item2=2;
+ * row->item3=3;
+ * }
+ *
+ *--------------------------------------------------------------------------*/
+
+/*--------------------------------------------------------------------------
+ *
+ * table_create Allocate and initialize the Table control structure.
+ *
+ * tbl = table_create(row_size)
+ * Table *tbl; * Pointer to a table.
+ * int row_size; * size of a row.
+ *
+ * Return:
+ * tbl = A pointer to the initialized Table.
+ * null = Unable to allocate the memory to initialize the table.
+ *
+ * This routine is used to allocate a table. Tables consist of a table
+ * control structure and an array that contains the data in the table.
+ * When you create the table, you need to specify the size of the rows
+ * in the table. This is used when the table_* routines need to extend
+ * the table to accomidate new entries.
+ *
+ *--------------------------------------------------------------------------*/
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include "table.h"
+
+Table *
+table_create(
+ int size)
+{
+ Table *tbl;
+
+ if (!(tbl = (Table *) malloc(sizeof(Table))))
+ return False;
+
+ memset(tbl, 0, sizeof(Table)); /* malloc does not clear memory. */
+ tbl->magic = (Int16) TABLE_VALID; /* Mark this as a table. */
+ if (size < 4) /* Enforce a minimum limit. 4 bytes */
+ size = 4; /* is the same as a 32 bit word. */
+ tbl->size = size; /* Save the row size. */
+ tbl->end = -1; /* Nothing is in the table yet so*/
+ tbl->index = -1; /* all the indicies to indicate this */
+ tbl->status = Success; /* Mark this operation as successful.*/
+ tbl->insert = -1;
+ return tbl;
+}
+
+/*--------------------------------------------------------------------------
+ *
+ * err = table_free(tbl)
+ * Status err; * Success or Failure (invalid tbl).
+ * Table *tbl; * Pointer to a table.
+ *
+ * This routine is used to release a table when it is no longer in use.
+ * This will deallocate and return the memory used to store the table
+ * back to the system.
+ *
+ *--------------------------------------------------------------------------*/
+
+Status
+table_free(
+ Table *tbl)
+{
+ if (!tbl || (tbl->magic != TABLE_VALID))
+ return Failure;
+
+ tbl->magic = (Int16) TABLE_FREE; /* Mark the table as free. */
+ if (tbl->data) /* Then free the data array. */
+ free(tbl->data); /* Followed by the table control */
+ free(tbl); /* structure. */
+
+ return Success;
+}
+
+/*--------------------------------------------------------------------------
+ *
+ * table_getRow Return a pointer to the particular row in a table.
+ *
+ * row = table_getRow(tbl, idx);
+ * void *row; * Pointer to the entry for the row.
+ * Table *tbl; * Pointer to the table
+ * int idx; * Index of the desired row.
+ *
+ * This is a set of routines that are used to recover a pointer to the
+ * each row of data that is stored in the table. As the name of each
+ * routine indicates, they allow various ways to walk through the
+ * contents of the table. For this set of routines, there is no status
+ * return. Since these routines return a pointer to the row entry, if
+ * there was an error (i.e. an invalid table or no more entries), then
+ * a null pointer is returned.
+ *
+ *--------------------------------------------------------------------------*/
+
+void *
+table_getRow(
+ Table *tbl,
+ int idx)
+{
+ void *addr;
+
+ if (!VALID_TABLE(tbl))
+ return Failure;
+
+
+ if (idx < 0 || (idx > tbl->end)) {
+ tbl->status = Failure;
+ return Failure;
+ }
+ if (!tbl->data) { /* Logically can't happen, parinoia abounds */
+ tbl->status = Failure;
+ return Failure;
+ }
+
+ if (tbl->magic == TABLE_SORT) { /* Does the table need sorting? */
+ if (tbl->sort) {
+ DMSG("sort", printf("Calling sort procedure. qsort(tbl->data @%x, tbl->end %d, tbl->size %d, tbl->sort @%x\n",
+ (int) tbl->data, tbl->end+1, tbl->size, (int) tbl->sort));
+ qsort(tbl->data, tbl->end+1, tbl->size, tbl->sort);
+ }
+ tbl->magic = TABLE_VALID;
+ }
+ tbl->index = idx;
+ addr = (void *) ((int)tbl->data + (idx*tbl->size));
+ return addr;
+}
+
+/*--------------------------------------------------------------------------
+ *
+ * table_rowPointer Return a pointer to the particular row in a table.
+ *
+ * row = table_rowPointer(tbl, idx);
+ * void *row; * Pointer to the entry for the row.
+ * Table *tbl; * Pointer to the table
+ * int idx; * Index of the desired row.
+ *
+ * This is almost identical to the above routine. However, it does not
+ * cause the table to be sorted if it is out of order. This is called
+ * by the table_setEntry and table_setValue routines. When we set values,
+ * we do not worry if the table is in order. The magic flag will be get
+ * set to indicate the table is out of order. This will cause the table
+ * to be sorted before an item is retrieved with either table_getValue
+ * or table_getRow.
+ *
+ *--------------------------------------------------------------------------*/
+
+void *
+table_rowPointer(
+ Table *tbl,
+ int idx)
+{
+ void *addr;
+
+ if (!VALID_TABLE(tbl))
+ return Failure;
+
+ if (idx < 0 || (idx > tbl->end)) {
+ tbl->status = Failure;
+ return Failure;
+ }
+
+ if (!tbl->data) { /* Logically can't happen, parinoia abounds */
+ tbl->status = Failure;
+ return Failure;
+ }
+
+ tbl->index = idx;
+ addr = (void *) ((int)tbl->data + (idx * tbl->size));
+ return addr;
+}
+/*--------------------------------------------------------------------------
+ *
+ * table_getValue Return a value or a pointer to a table entry.
+ *
+ * value = table_getValue(tbl, idx);
+ * void *value; * Pointer to the entry for the row.
+ * Table *tbl; * Pointer to the table
+ * int idx; * Index of the desired row.
+ *
+ * This is a specialized form of the table_getRow call. A very handy
+ * use of the table routines is to manage a array of opaque 32 bit values
+ * such as pointers to data structures. There is special handling for the
+ * table in this case. Essentially, if the table is 4 or less bytes wide,
+ * we return the contents of the table item rather than a pointer to the
+ * contents of the data item. In this case table_getRow() will return a
+ * pointer to the table item rather than the contents. These types of
+ * tables can be sorted as well, in which case the qsort function has to
+ * take into account the indirection of the arguments.
+ *
+ *--------------------------------------------------------------------------*/
+
+void *
+table_getValue(
+ Table *tbl,
+ int idx)
+{
+ void *value;
+
+ if ((value = table_getRow(tbl, idx)) &&
+ (tbl->size <= 4))
+ value = (void *)*(void **)value;
+
+ return value;
+}
+
+/*--------------------------------------------------------------------------
+ *
+ * table_get.... Retrieve various entries in the table.
+ *
+ * row = table_getFirst(tbl);
+ * row = table_getLast(tbl);
+ * row = table_getNext(tbl);
+ * row = table_getPrev(tbl);
+ *
+ * These are variations of the table_getRow routine. They are used to
+ * sequentially walk through the table. The functionality is similar to
+ * walking through a doublely linked list.
+ *
+ *--------------------------------------------------------------------------*/
+void *
+table_getFirst(
+ Table *tbl)
+{ /* Just get the first entry in the*/
+ return table_getRow(tbl, 0); /* table. getRow does the validate*/
+}
+
+void *
+table_getLast( /* This time, we need to look into*/
+ Table *tbl) /* tbl header, so we have to make */
+{ /* shure we have a valid header. */
+ if (!VALID_TABLE(tbl))
+ return Failure;
+
+ return table_getRow(tbl, tbl->end);
+}
+
+void *
+table_getPrev( /* This one works off of tbl->idx*/
+ Table *tbl) /* which reflects the cur entry. */
+{
+ if (!VALID_TABLE(tbl))
+ return Failure;
+
+ return table_getRow(tbl, tbl->index-1);
+}
+
+void *
+table_getNext( /* This one retrieves that next */
+ Table *tbl) /* sequential entry in the table. */
+{
+ if (!VALID_TABLE(tbl))
+ return Failure;
+
+ return table_getRow(tbl, tbl->index+1);
+}
+
+/*--------------------------------------------------------------------------
+ *
+ * err = table_getEntry(tbl, idx, row, size);
+ * Table *tbl; * Pointer to the table.
+ * int idx; * The desired row index.
+ * char *row; * Buffer to receive entry data.
+ * int size; * Size of the buffer.
+ *
+ * The row entry itself can be retrieved, rather than a pointer to the
+ * row. At this level, the entry is seen as some number of bytes that
+ * are to be stores into a buffer. The size parameter specifies the
+ * size of the buffer that is being copied into. It may be less than
+ * the size specified for a row in the initial table_alloc() function.
+ * However, in this case, the state of the "extra" bytes at the end of
+ * the entry is undetermined. In any case, the smaller of the two values
+ * is used to determine the amount of data copied.
+ *
+ *--------------------------------------------------------------------------*/
+
+Status
+table_getEntry(
+ Table *tbl, /* Pointer to the table. */
+ int idx, /* The desired row index. */
+ void *row, /* Buffer to receive entry data. */
+ int size) /* Size of the buffer. */
+{
+ void *ent;
+
+ if ((ent = table_getRow(tbl, idx)) == Failure)
+ return Failure;
+
+ memcpy(row, ent, tbl->size < size ? tbl->size : size);
+
+ tbl->status = Success;
+ return Success;
+}
+
+/*--------------------------------------------------------------------------
+ *
+ * err = table_setEntry(tbl, idx, row, size);
+ * Table *tbl; * Pointer to the table.
+ * int idx; * The desired row index.
+ * Entry *row; * Buffer to receive entry data.
+ * int size; * Size of the buffer.
+ *
+ * This function is the coverse of getRow. This is used to set the
+ * value of a row. The contents of the entry is simply copied to the
+ * table. The lesser of the buffer size or the row size specified when
+ * the table was created governs the amount of data that is copied.
+ *
+ *--------------------------------------------------------------------------*/
+
+Status
+table_setEntry(
+ Table *tbl,
+ int idx,
+ void *row,
+ int size)
+{
+
+ void *ent;
+
+ if (!VALID_TABLE(tbl))
+ return Failure;
+
+ if (idx >= tbl->last) /* Is the table large enough? */
+ if (table_extend(tbl, idx) == Failure) { /* No, extend it. */
+ DMSG("table", printf("table_setEntry: TableExtend failed.\n"));
+ return Failure; /* Oops, alloc failed*/
+ }
+ if ((ent = table_rowPointer(tbl, idx)) == Failure) {
+ DMSG("table", printf("table_setEntry: table_rowPointer(tbl, %d) failed!\n", idx));
+ return Failure;
+ }
+ memcpy(ent, row, tbl->size < size ? tbl->size : size);
+
+ if (tbl->sort) /* Is this a sorted table ? */
+ tbl->magic = TABLE_SORT; /* Yes, trigger a qsort. */
+
+ if (idx > tbl->end) /* Keep track of the largest */
+ tbl->end = idx; /* entry allocated in tbl->data */
+
+ tbl->index = idx;
+ tbl->status = Success;
+ tbl->insert = idx;
+ return Success;
+}
+
+/*--------------------------------------------------------------------------
+ *
+ * err = table_addEntry(tbl, row, size);
+ * Table *tbl; * Pointer to the table.
+ * Entry *row; * Buffer to receive entry data.
+ * int size; * Size of the buffer.
+ *
+ * This function is used to add an entry to the end of a list. We
+ * simply call table_setEntry with the tbl->end+1 as the index. If
+ * this is a sorted list, table_setEntry will set the TABLE_SORT
+ * magic flag so that the table will get sorted prior to get access.
+ *
+ *--------------------------------------------------------------------------*/
+
+Status
+table_addEntry(
+ Table *tbl,
+ char *row,
+ int size)
+{
+
+ if (!VALID_TABLE(tbl))
+ return Failure;
+
+ if (tbl->end+1 >= tbl->last) /* Is the table large enough? */
+ if (table_extend(tbl, tbl->end+1) == Failure) { /* No, extend it. */
+ DMSG("table", printf("table_addEntry: TableExtend failed.\n"));
+ return Failure; /* Oops, alloc failed*/
+ }
+ return table_setEntry(tbl, ++tbl->end, row, size);
+}
+
+Status
+table_addValue(
+ Table *tbl,
+ int value)
+{
+ void *row;
+ int size;
+
+ if (!VALID_TABLE(tbl))
+ return Failure;
+
+ row = (void *)&value;
+ size = sizeof(int);
+
+ if (++tbl->end >= tbl->limit)
+ if (tbl->magic == TABLE_BUFFER)
+ bcopyLongs(tbl->data + 4, tbl->data, tbl->end--);
+
+ return table_setEntry(tbl, tbl->end, row, size);
+}
+
+Status
+table_removeEntry(
+ Table *tbl,
+ int row)
+{
+
+ if (!VALID_TABLE(tbl))
+ return Failure;
+
+ if ((row < 0) || (row > tbl->end)) {
+ tbl->status = Failure;
+ return Failure;
+ }
+
+ if (row == tbl->end) { /* Is this the last item in the table ? */
+ tbl->end--; /* Yes, just reduce the end pointer to */
+ tbl->status = Success; /* eliminate the item. */
+ return Success;
+ }
+
+ tbl->index = row;
+ bcopy(tbl->data+((row+1)*tbl->size), tbl->data+(row*tbl->size), (tbl->end+1-row)*tbl->size);
+
+ tbl->end--;
+ tbl->status = Success;
+
+ return Success;
+}
+
+Status
+table_buffer(
+ Table *tbl,
+ int rows)
+{
+
+ if (!VALID_TABLE(tbl))
+ return Failure;
+
+ tbl->magic = TABLE_BUFFER;
+ tbl->end = -1;
+ tbl->insert = -1;
+ tbl->limit = rows;
+
+ DMSG("table", printf("table_buffer('0x%x', %d) end= %d\n", (int)tbl, rows, tbl->end) );
+
+ return Success;
+}
+
+/*--------------------------------------------------------------------------
+ *
+ * table_extend Extend the size of a table.
+ *
+ * err = table_extend(tbl, rows)
+ * Table *tbl; * Pointer to a table.
+ * int rows; * Maximum number of rows to accomidate
+ *
+ * Return:
+ * Success = the table is large enough to handle the desired # of rows
+ * Failure = invalid table pointer was passed or we could not assign
+ * enough memory with malloc or realloc to extend the table.
+ *
+ * This function is used to extent the table to accomidate a certain
+ * number of entries. This function can be used to pre-allocate a large
+ * table. The table is normally extended in small chunks to accomidate
+ * new entries. For example, if the table has 10 entries in it and the
+ * 11th entry is referenced, the table may be extended to accomidate 20
+ * entries. Since the table itself must be contiguous, realloc() is called
+ * to allocate additional memory space which could cause a bcopy() to
+ * be performed. If the table is not very big, this processing is not
+ * significant and can be ignored. However, if the table has thousands
+ * of entries in it, the overhead can be reduced by simply extending the
+ * table to the maximum size in a single operation.
+ *
+ *--------------------------------------------------------------------------*/
+
+Status
+table_extend(
+ Table *tbl, /* Pointer to the table. */
+ int rows) /* Maximum rows to accomidate. */
+{
+ int bytes;
+ char *buf;
+
+ if (!VALID_TABLE(tbl))
+ return Failure;
+
+ if (tbl->limit && (rows > tbl->limit))
+ return Failure;
+
+ DMSG("table", printf("table_extend('0x%x', %d), last= %d\n", (int)tbl, rows, tbl->last) );
+
+ if ((bytes = CHUNK(rows)) > tbl->last) {
+ bytes *= tbl->size; /* How much memory is really needed? */
+ if ((buf = (char *) (tbl->data ? realloc(tbl->data, bytes)
+ : malloc(bytes)))) {
+ tbl->data = buf;
+ memset(buf+(tbl->last*tbl->size), 0, bytes-(tbl->last*tbl->size));
+ tbl->last = CHUNK(rows);
+ DMSG("table", printf("table_extend: tbl->data='0x%08x', tbl->last=%d\n", (int)buf, tbl->last));
+ } else {
+ DMSG("table", printf("table_extend: alloc failed!!! tbl->data='0x%08x', tbl->last=%d\n", (int)buf, tbl->last));
+ tbl->status = Failure; /* Oops, alloc failed*/
+ return Failure;
+ }
+ }
+ tbl->status = Success; /* Mark this operation as successful.*/
+ return Success;
+}
+
+/*--------------------------------------------------------------------------
+ *
+ * table_limit Limit the growth of a table.
+ *
+ * err = table_limit(tbl, rows)
+ * Table *tbl;
+ * int rows;
+ *
+ * Return:
+ * Success = table limit was set.
+ * Failure = invalid table pointer was passed.
+ *
+ * This function is used to limit the size of a table. The functions
+ * table_getRow() and table_setEntry() automatically extend the tables
+ * as needed to accomidate the entry that is being referenced. This is
+ * used to specify the absolute limit that the table may grow to. If no
+ * limit is specified, the table will be allowed to grow as needed.
+ *
+ *--------------------------------------------------------------------------*/
+
+Status
+table_limit(
+ Table *tbl,
+ int rows)
+{
+
+ if (!VALID_TABLE(tbl))
+ return Failure;
+
+ table_extend(tbl, rows); /* First extend the table. */
+ tbl->limit = rows; /* Limit the table from further growth */
+ tbl->end = rows;
+ tbl->status = Success; /* Mark this operation as successful */
+
+ DMSG("table", printf("table_limit('0x%x', %d) end= %d\n", (int)tbl, rows, tbl->end) );
+
+ return Success;
+}
+
+
+/*--------------------------------------------------------------------------
+ *
+ * table_status Return the status of the last table operation.
+ *
+ * err = table_status(tbl)
+ * Table *tbl; * Pointer to a table.
+ *
+ * This function is used to return the status of the last operation on
+ * the particular table. A number of routines return a pointer to the
+ * entry or a NULL in the event of an error. This can be used to identify
+ * the particular error. For example, if table_getNext(tbl) returned a
+ * NULL entry, it could be because it was passed an invalid table pointer
+ * or because it ran out of entries to return. This can be used to see
+ * the precise error in such a case.
+ *
+ *--------------------------------------------------------------------------*/
+
+Status
+table_status(
+ Table *tbl)
+{
+
+ if (!VALID_TABLE(tbl))
+ return Failure;
+
+ return (tbl->status);
+}
+
+/*--------------------------------------------------------------------------
+ *
+ * table_size Return the size of an entry in the table.
+ *
+ * size = table_size(tbl)
+ * Table *tbl; * Pointer to a table.
+ *
+ * This function is used to return the size of the entries in the table
+ * or the width of the rows of the table. This value is normally set
+ * when the table is created.
+ *
+ *--------------------------------------------------------------------------*/
+
+int
+table_size(
+ Table *tbl)
+{
+
+ if (!VALID_TABLE(tbl))
+ return Failure;
+
+ return (tbl->size);
+}
+
+/*--------------------------------------------------------------------------
+ *
+ * table_end Return the end (last item) of the table.
+ *
+ * lastItem = table_end(tbl)
+ * Table *tbl; * Pointer to a table.
+ *
+ * This function is used to return the last item in the table. This
+ * can be used to find the number of items in the table.
+ *
+ *--------------------------------------------------------------------------*/
+int
+table_end(
+ Table *tbl)
+{
+
+ if (!VALID_TABLE(tbl))
+ return Failure;
+
+ return (tbl->end);
+}
+
+/*--------------------------------------------------------------------------
+ *
+ * table_sort Specify a qsort procedure for a table.
+ *
+ * size = table_sort(tbl, proc)
+ * Table *tbl; * Pointer to a table.
+ * void *proc(); * Qsort process.
+ *
+ * This function is used to set the qsort proc for a table. All we have
+ * to do is store the proc handle in the table header and set the magic
+ * flag to TABLE_SORT. This indicates that the table needs to be sorted
+ * prior to getValue returning an item.
+ *
+ *--------------------------------------------------------------------------*/
+
+Status
+table_sort(
+ Table *tbl,
+ int (*sort)(const void *, const void *))
+{
+
+ if (!VALID_TABLE(tbl))
+ return Failure;
+
+ tbl->sort = sort; /* Save the sort procedure. */
+ tbl->magic = TABLE_SORT; /* Trigger the initial sort. */
+ tbl->status = Success; /* Mark this operation as successful */
+ return Success;
+}
+
+/*--------------------------------------------------------------------------
+ *
+ * table_find Find an entry in a table.
+ *
+ * addr = table_find(tbl, test, arg)
+ * addr = table_find_next(tbl, test, arg)
+ * Table *tbl; * Pointer to a table.
+ * void (*test)(void*, void*); * Qsort like test process.
+ * void *arg; * Item we are looking for.
+ *
+ * This function is used to set the qsort proc for a table. All we have
+ * to do is store the proc handle in the table header and set the magic
+ * flag to TABLE_SORT. This indicates that the table needs to be sorted
+ * prior to getValue returning an item.
+ *
+ *--------------------------------------------------------------------------*/
+
+void *
+table_find(
+ Table *tbl,
+ int (*test)(const void *,const void *),
+ void *arg)
+{
+ if (!VALID_TABLE(tbl))
+ return Failure;
+
+ tbl->index = -1; /* Start at the top of the table. */
+ return table_find_next(tbl, test, arg);
+}
+
+void *
+table_find_next(
+ Table *tbl,
+ int (*test)(const void *, const void *),
+ void *arg)
+{
+#if LATER
+ void *addr, *tst;
+ int i, beg, end, t;
+#else
+ void *addr;
+ int i;
+#endif
+
+ if (!VALID_TABLE(tbl))
+ return Failure;
+
+ if (!tbl || !((tbl->magic == TABLE_VALID) ||
+ (tbl->magic == TABLE_SORT)))
+ return Failure;
+
+ if (tbl->sort && (tbl->magic == TABLE_SORT)) {
+ qsort(tbl->data, tbl->end+1, tbl->size, tbl->sort);
+ tbl->magic = TABLE_VALID;
+ }
+
+#if LATER
+ if (tbl->sort) { /* Is this a sorted table ? */
+ beg = i = tbl->index; /* Yes, we can do a binary */
+ end = tbl->end; /* search on the data. */
+ while (beg < end) {
+ addr = (void *) ((int)tbl->data + (i * tbl->size));
+ t = (*test)(arg, addr);
+ DMSG("table", printf("table_find(): testing item %d, beg %d, end %d, t %d\n",
+ i, beg, end, t) );
+ if (t == 0) {
+ /* Exact Match. Well almost, there can be duplicate
+ * entries in a sorted table. If this is the case,
+ * then we need to back up in the list to the first
+ * instance of this entry.
+ * Note: the beg index has been moved. tbl->index
+ * contains the start of the table segment
+ * we are searching. */
+
+ while (i > tbl->index) {
+ tst = (void *) ((int)tbl->data + ((i-1) * tbl->size));
+ if ((*test)(arg, tst))
+ break; /* This index is ok. */
+ addr = tst; /* This is a duplicate index*/
+ i--; /* go back one item and test*/
+ DMSG("table", printf(" duplicate detected. backing up to item %d\n", i));
+ } /* again to the top of segmt*/
+ tbl->index = i; /* Make this the current item. */
+ tbl->status = Success;
+ DMSG("table", printf(" found item %d\n", i));
+ return addr;
+
+ } else if (t > 0) {
+ /* What we are testing for (arg) is less than the
+ * item (addr) that we are considering. We need to
+ * look further in the table for a match. */
+
+ beg = i;
+ i += ((end-beg)+1)/2;
+
+ } else if (t < 0) {
+ /* What we are testing for (arg) is greater than the
+ * item (addr) that we are considering. We need to
+ * look earlier in the table for a match. */
+
+ end = i;
+ i -= ((end-beg)+1)/2;
+ }
+ }
+ } else {
+#else
+ {
+#endif
+ i = tbl->index; /* The table is not sorted. */
+ while (++i <= tbl->end) { /* We have to scan each item*/
+ addr = (void *) ((int)tbl->data + (i * tbl->size));
+ if ((*test)(arg, addr) == 0) {
+ tbl->index = i;
+ tbl->status = Success;
+ return addr;
+ }
+ }
+ }
+ tbl->index = tbl->end;
+ tbl->status = Failure;
+ return Failure;
+}
+
+/*------------------------------------------------------------------------
+ *
+ * debug.c Simple handling of debugging messages.
+ *
+ * These routines are used to manage simple outputing of messages
+ * based on a key. The user can dynamically enable or disable the
+ * printing of messages with the use of the debug_print("type") and
+ * debug_stop("type") routines. This works in conjunction with the
+ * DMSG("type", <statment>)); macros which can be sprinkled through
+ * the code. When the particular "type" catagory has been enabled,
+ * the statment will be executed. Typically, this is printf or a
+ * call to a debugging or other logging routine. When the DEBUG
+ * flag is not defined, to reduce the program size, these statments
+ * do not get reduced to code.
+ *
+ *------------------------------------------------------------------------*/
+
+
+#define True 1
+#define False 0
+#define DebugTblSize 20
+
+char *debugTypesEnabled[DebugTblSize];
+
+typedef struct DebugCatalog_t {
+ char tag[20];
+ char file[20];
+ int line;
+ int count;
+} DebugCatalog;
+
+Table *debugCatalog;
+
+int
+dmsg(
+ char *typ)
+{
+ if (!typ)
+ debug_print();
+ else debug_msg(typ);
+ return 0;
+}
+
+int
+dstop(
+ char *typ)
+{
+ debug_stop(typ);
+ return 0;
+}
+
+int
+dindex()
+{
+ debug_index();
+ return 0;
+}
+
+int
+dprint()
+{
+ debug_print();
+ return 0;
+}
+
+void
+debug_msg(
+ char *typ)
+{
+ int argc, i;
+ char c, *tok, *t, *argv[20], buf[80];
+
+ tok = buf; /* Tokenize the input */
+ argv[argc = 0] = tok;
+ while ((c = *tok++ = *typ++))
+ if ((c == ' ') || (c == ' ')) {
+ *--tok = 0;
+ argv[++argc] = ++tok;
+ }
+ argv[++argc] = 0;
+
+ /* Now put them on the Types Enabled list. */
+ argc = -1;
+next: while ((tok = argv[++argc])) {
+ i = -1;
+ while ((t = debugTypesEnabled[++i]))
+ if (!strncmp(tok, t, strlen(tok)))
+ goto next;
+ debugTypesEnabled[i] = strdup(tok);
+ }
+}
+
+void
+debug_stop(
+ char *typ)
+{
+ int argc, i, j;
+ char c, *tok, *t, *argv[20], buf[80];
+
+ tok = buf; /* Tokenize the input */
+ argv[argc = 0] = tok;
+ while ((c = *tok++ = *typ++))
+ if ((c == ' ') || (c == ' ')) {
+ *--tok = 0;
+ argv[++argc] = ++tok;
+ }
+ argv[++argc] = 0;
+
+ /* Now remove them from the Types Enabled list. */
+ argc = -1;
+ while ((tok = argv[++argc])) {
+ i = -1;
+ while (++i < DebugTblSize)
+ if ((t = debugTypesEnabled[i]) && !strncasecmp(tok, t, strlen(t))) {
+ free(debugTypesEnabled[i]); /* Free the strdup memory */
+ j = i;
+ while (++j < DebugTblSize)
+ debugTypesEnabled[j-1] = debugTypesEnabled[j];
+ debugTypesEnabled[j] = 0;
+ }
+ }
+}
+
+
+int
+debug_print()
+{
+ int i;
+ char *tok;
+
+ printf("The following categories are enabled:\n");
+ i = -1;
+ while ((tok = debugTypesEnabled[++i]))
+ printf("%d: '%s'\n", i, tok);
+ printf("-----\n");
+ return 0;
+}
+
+int
+debug_test(
+ char *typ,
+ char *file,
+ int line)
+{
+ int argc, i;
+ char c, *t, *tok, *argv[20], buf[80];
+
+
+ tok = buf; /* Tokenize the input */
+ argv[argc = 0] = tok;
+ while ((c = *tok++ = *typ++))
+ if ((c == ' ') || (c == ' ')) {
+ *--tok = 0;
+ argv[++argc] = ++tok;
+ }
+ argv[++argc] = 0;
+
+#if 0
+ if (debugCatalog) /* Should we catalog this message? */
+ debug_catalog(typ, file, line);
+#endif
+
+ /* Now look for them on the Types Enabled list. */
+ argc = -1;
+ while ((tok = argv[++argc])) {
+ i = -1;
+ while (++i < DebugTblSize)
+ if ((t = debugTypesEnabled[i]) && !strncasecmp(tok, t, strlen(tok)))
+ return True;
+ }
+ return False;
+}
+
+void
+debug_catalog(
+ char *typ,
+ char *file,
+ int line)
+{
+ Table *cat;
+ DebugCatalog *itm, tst;
+
+ if (!(cat = debugCatalog))
+ return;
+
+ strcpy(tst.tag, typ);
+ strcpy(tst.file, file);
+ tst.line = line;
+ if ((itm = table_find(cat, debug_catalogFind, (void *)&tst)))
+ itm->count++;
+ else {
+ itm = calloc(1, sizeof(DebugCatalog));
+ strcpy(itm->file, file);
+ strcpy(itm->tag, typ);
+ itm->line = line;
+ table_addEntry(cat, (void *)itm, sizeof(DebugCatalog));
+ }
+}
+
+void
+debug_index()
+{
+ Table *cat;
+ int i;
+ DebugCatalog *itm;
+
+ if (!(cat = debugCatalog)) {
+ debugCatalog = table_create(sizeof(DebugCatalog));
+ table_sort(debugCatalog, debug_catalogFind);
+ printf("Accumulating index of DMSG statments\n");
+ } else {
+ printf("DMSG was called with the following tags:\n\n");
+ i = -1;
+ while (++i < table_end(cat))
+ if ((itm = table_getRow(cat, i)))
+ printf("%12s %d (%s:%d)\n", itm->tag, itm->count, itm->file, itm->line);
+ }
+}
+
+
+/*
+ * This function is used as a qsort process to sort tables based on the tags.
+ * We are passed pointers to DebugCatalog types. Since we want to keep a detailed
+ * entry based on file / line, we keep concantinate all the items to a string and
+ * then do the compare.
+ */
+
+int
+debug_catalogFind(
+ const void *arg1,
+ const void *arg2)
+{
+ DebugCatalog *itm1 = (DebugCatalog *)arg1;
+ DebugCatalog *itm2 = (DebugCatalog *)arg2;
+ char buf1[40], buf2[40];
+
+ sprintf(buf1, "%s%s%d", itm1->tag, itm1->file, itm1->line);
+ sprintf(buf2, "%s%s%d", itm2->tag, itm2->file, itm2->line);
+ return strcasecmp (buf1, buf2);
+}
+
+int
+strncasecmp(
+ char *s1,
+ char *s2,
+ int n)
+{
+
+
+ if (!s1 || !s2)
+ return False;
+#if 0
+ printf("StrCaseNCmp(0x%x='%s', 0x%x='%s', %d)\n", (int)s1, s1, (int)s2, s2, n);
+#endif
+ while (*s1 && *s2 && (n-- > 0))
+ if ((*s1 == '*') || (*s2 == '*'))
+ return 0;
+ else if ((*s1++ | ' ') != (*s2++ | ' '))
+ return *--s1 - *--s2;
+ return (n && (*s1 || *s2)) ? 1 : 0;
+}
+
+int
+strcasecmp(
+ char *s1,
+ char *s2)
+{
+ if (!s1 || !s2)
+ return False;
+
+#if 0
+ printf("StrCaseCmp(0x%x='%s', 0x%x='%s')\n", (int)s1, s1, (int)s2, s2);
+#endif
+ while (*s1 && *s2)
+#if 0
+ if ((*s1 == '*') || (*s2 == '*'))
+ return 0;
+ else
+#endif
+ if ((*s1++ | ' ') != (*s2++ | ' '))
+ return *--s1 - *--s2;
+
+ return (*s1 || *s2) ? 1 : 0;
+}
+
+char *
+strdup(
+ char *str)
+{
+ int i;
+ char *cpy;
+
+ if (!str)
+ return False;
+ i = strlen(str);
+ if ((cpy = malloc(i+1)))
+ strcpy(cpy, str);
+ return cpy;
+}
diff --git a/data/mnet/Common/snmp/src/vipermib.c b/data/mnet/Common/snmp/src/vipermib.c
new file mode 100644
index 0000000..e52c498
--- /dev/null
+++ b/data/mnet/Common/snmp/src/vipermib.c
@@ -0,0 +1,1768 @@
+/*********************************************************************/
+/* */
+/* (c) Copyright Cisco 2000 */
+/* All Rights Reserved */
+/* */
+/*********************************************************************/
+
+/*********************************************************************
+**
+** FILE NAME: vipermib.c
+**
+** DESCRIPTION: This file contains snmp get/set/next/test methods
+**
+** COMPONENTS:
+**
+**
+** NOTES:
+**
+** REVISION HISTORY
+** __________________________________________________________________
+** ----------+--------+----------------------------------------------
+** Name | Date | Reason
+** ----------+--------+----------------------------------------------
+** Bhawani |03/02/01| Modified original file and resturctured to use
+** | | common vob and clean up the code. Separated
+** | | file I/O in a separated file.
+** Bhawani |03/16/01| Added SnmpMibLookup routines
+** ----------+--------+----------------------------------------------
+**********************************************************************
+*/
+
+
+/*
+**********************************************************************
+** Include Files.
+**********************************************************************
+*/
+
+#ifdef DEBUG
+#define PARANOID /* Full debugging */
+#endif
+
+#include <vxWorks.h>
+#include <mib.h>
+#include <snmpdefs.h>
+#include <snmpdLib.h>
+#include <ioLib.h>
+#include <fioLib.h>
+#include <sysLib.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <memLib.h>
+#include <hostLib.h>
+#include <time.h>
+#include <timers.h>
+#include <inetLib.h>
+#include <ctype.h>
+
+#include "vipermib.h"
+#include "vipertbl.h"
+#include "oam_api.h"
+#include "snmp/include/version.h"
+
+/********************************************************************
+* Defined used in this file
+*********************************************************************/
+#define LOCAL_MEM_LOCAL_ADRS 0x00000000 /* Base of RAM */
+#define BOOT_LINE_OFFSET 0x4200
+#define BOOT_LINE_ADRS ((char *) (LOCAL_MEM_LOCAL_ADRS+BOOT_LINE_OFFSET))
+#define BOOT_LINE_SIZE 255 /* use 255 bytes for bootline */
+#define MAX_PATH_NAME 256
+
+/********************************************************************
+* Global variables
+*********************************************************************/
+char SnmpDefaultMibFileName[MAX_PATH_NAME];
+int SnmpTimerRebootLongDelay = 30;
+int SnmpTimerRebootShortDelay = 5;
+int SnmpTimerRebootDelay = 0;
+
+int SnmpTimerMibFlushDelay = 5; /* default in seconds */
+int SnmpTimerMibFlushMinFileIo = 5*60; /* 5 minutes */
+int SnmpTimerMibFlushMinDelay = 2; /* 2 seconds */
+
+
+extern char *snmp_tagName( MibTag );
+extern void snmp_printPDU(SNMP_PKT_T *, char *);
+extern char *snmp_printPduType(int);
+
+int SnmpMibLoadCount = 0;
+int SnmpMibSaveCount = 0;
+int SnmpMibSetCount = 0;
+int SnmpMibGetCount = 0;
+
+int mibInitialized = False;
+int snmpInitialized = False;
+int SnmpPostSetEnabled = False;
+
+char *mibVersionId = VIPERCELL_EXTERNAL_VERSION_NO;
+char *mibBuildId = VIPERCELL_INTERNAL_BUILD_ID;
+char *mibDate = __DATE__;
+char *mibTime = __TIME__;
+char *mibCrypto = VIPERCELL_CRYPTO_INFO;
+
+FILE *logFS;
+char logBuf[256];
+
+
+/* forward declaration */
+extern void snmpLocalIoInit();
+extern void snmpLocalInitCommunityNames();
+extern STATUS snmp_postLoadMibHandler();
+
+
+
+/* convert unsigned int to dotted IP string */
+char* int2ip(UINT32 nIp)
+{
+ UINT8* pIp = (UINT8*) &nIp;
+ static char pszIp[16];
+ sprintf(pszIp, "%u.%u.%u.%u", pIp[0], pIp[1], pIp[2], pIp[3]);
+ return pszIp;
+}
+
+void SnmpStatusShow()
+{
+ printf("Snmp default Mib file: '%s'\n", SnmpDefaultMibFileName);
+ printf("Snmp MIB Flush Delay Timer: %d\n", SnmpTimerMibFlushDelay);
+ printf("Mib File Load Count: %d\n", SnmpMibLoadCount);
+ printf("Mib File Save Count: %d\n", SnmpMibSaveCount);
+ printf("Mib File Set Count: %d\n", SnmpMibSetCount);
+ printf("Mib File Get Count: %d\n", SnmpMibGetCount);
+
+}
+
+void snmp_oamCmdStrSet(char *str)
+{
+ snmp_setEntry(MIB_oamCommandLastError, 0, str, strlen(str));
+
+}
+
+
+void snmp_initializeMib()
+
+{
+ int i, j, end, tag;
+ void **addr;
+ Table *tbl;
+
+
+ if (snmpInitialized == True) /* This code is a one-shot. */
+ return;
+ snmpInitialized = True;
+ mibInitialized = True;
+
+ snmp_mibTimerInit();
+
+ /* This speeds up the data validation routines. By defining this
+ ** Table header and associating the data type array and a sort proc
+ ** with the table, we can use the table_find() routine to do a binary
+ ** search of this table. Since the data validation routines expect
+ ** this to be setup, do it first. */
+
+ mnetMibDataTypeTable = table_create(sizeof(MnetMibDataType));
+ mnetMibDataTypeTable->data = (char *)mnetMibDataType;
+ i = -1;
+ while (mnetMibDataType[++i].tag);
+ mnetMibDataTypeTable->last = i;
+ mnetMibDataTypeTable->end = i;
+
+ /* Part of the MIB is a statically allocated in the MnetMib structure.
+ ** This contains all of the base packages. The tables and string buffers are
+ ** allocated at runtime with malloc. The following loop will allocate the
+ ** dynamic part of the MIB: */
+
+ i = -1;
+ while ((tag = mnetMibIndex[++i].tag))
+ {
+ if (NULL == mnetMibIndex[i].addr)
+ {
+ if (MIB_TYP(tag) == MTYPE_STRING)
+ {
+ mnetMibIndex[i].addr = (void *)calloc(1, mnetMibIndex[i].size+1);
+ }
+ else
+ {
+ mnetMibIndex[i].addr = addr = (void *)table_create(mnetMibIndex[i].size);
+ table_limit((Table *)addr, mnetMibIndex[i].limit);
+ snmp_fixupTable((Table *)addr); /* Add an index to the tables. */
+ }
+ }
+ if (!((MIB_TYP(tag) == MTYPE_STRUCT) && (MIB_ITM(tag) == 0)))
+ {
+ addr = (void**)snmp_getAddress(tag); /* Were this tag resolves to. */
+ *addr = mnetMibIndex[i].addr; /* Store the real address away. */
+ DMSG("fixup mib", printf("snmp_initMib(): Fixup loading '%s' @%x = '0x%08x'.\n",
+ snmp_tagName(tag), (int) addr, (int)mnetMibIndex[i].addr));
+ } /* Can't use snmp_setValue since */
+ } /* it would copy the string, not */
+ /* just set the address. */
+
+ /* Now we can load the default values in the MIB structure. */
+ /* Setup the COMPLEX number callbacks as well. */
+ i = -1;
+ while ((tag = mnetMibDataType[++i].tag))
+ {
+ if (mnetMibDataType[i].value)
+ {
+ if (MTYPE_IS_TABLE(MIB_TYP(tag)))
+ {
+ if ((tbl = snmp_getTableAddress(tag)))
+ {
+ end = table_end(tbl);
+ for (j=0; j < end; j++)
+ {
+ snmp_setEntry(tag, j, (void *) mnetMibDataType[i].value, 4);
+ }
+ }
+ }
+ else
+ {
+ snmp_setEntry(tag, 0, (void *) mnetMibDataType[i].value, 4);
+ }
+ } /* Value not zero */
+ }
+
+ /* Now that the internal structure is setup, we can load in the
+ * real MIB. However, we should wait until the date has been set
+ * in the startup script. Also, there is a MNET_BASE flag
+ * that point to where the MIB files should be put. Thus, we set
+ * a flag saying we are not intialized yet. The following routine
+ * gets executed from the startup script. It loads the MIB and then
+ * clears the flag allowing access.
+ */
+
+ mibInitialized = False;
+}
+
+/* Aug 23, 2000 Modified this function to fix AR 1216 - Bhawani*/
+int snmp_initialize(char *name)
+{
+ char *str;
+ char *vcBase;
+ int versionFd;
+ int snmpLocalIP;
+ char localhostname[MAXHOSTNAMELEN];
+ char versionFileName[MAXHOSTNAMELEN];
+ char verBuf[64];
+ char buildBuf[64];
+ char timeBuf[32];
+ char dateBuf[32];
+ char cryptoBuf[32];
+ char tmpBuf[128];
+ char buf[512];
+ int charsRead;
+
+ gethostname(localhostname, MAXHOSTNAMELEN);
+ snmpLocalIP = hostGetByName(localhostname);
+
+
+
+ /* first initialize mib and create table etc. */
+ snmp_initializeMib();
+
+
+ /* Initialize IO Task */
+ snmp_initIoTask();
+
+ /* Initialize Local IO first */
+ snmpLocalIoInit();
+
+ /* check if this function is called multiple times */
+ if (mibInitialized == True)
+ return OK;
+
+ snmp_log(False, "\nSnmp Initialize", "SNMP agent is booting up");
+
+ /* Get the value of the MNET_BASE environment variable. */
+ vcBase = getenv( "MNET_BASE" );
+ if( vcBase == NULL )
+ {
+ snmp_log(True, "snmp_initialize", "SNMP initialization failure because environment variable \"MNET_BASE\" could not be found.");
+ return ERROR;
+ }
+
+ /* Set the Mib file name*/
+ sprintf(SnmpDefaultMibFileName, "%s/mib/mib.txt", vcBase);
+
+ mibInitialized = True; /* allow MIB access in snmp_loadMib */
+
+ /* Call product specific pre loadMib handler */
+ snmp_initDefaultMib();
+
+ /* Overwrite the default value with the one specified in the MIB file */
+ if (snmp_loadMib(SnmpDefaultMibFileName) == Success)
+ {
+ snmp_log(True, "Snmp Initialize", "SNMP MIB was successfully loaded from file %s.", SnmpDefaultMibFileName);
+ }
+ else
+ {
+ snmp_saveMib(SnmpDefaultMibFileName);
+ snmp_log(True, "Snmp Initialize", "SNMP mib could not be loaded from %s: %s", SnmpDefaultMibFileName, strerror(errno));
+ }
+
+ /* Access control status enabled */
+ snmp_setValue(MIB_mibAccessControlFlag, True);
+
+ /* Clear the OAM command last error */
+ snmp_oamCmdStrSet("");
+
+ /* Initialize Element IP Address */
+ snmp_setValue(MIB_mnetIpAddress, snmpLocalIP);
+
+ /* Initialize Software build */
+ if ((str = (char *)snmp_getValue(MIB_mnetSoftwareBuild)))
+ {
+ /* Open file version.txt and try to read the version and build number */
+ sprintf(versionFileName, "%s/version.txt", vcBase);
+
+ printf("Version file %s ", versionFileName);
+ if ((versionFd = open (versionFileName, O_RDONLY, 0)) != ERROR)
+ {
+ printf("will be used to set Version and Build Id\n");
+ while (fioRdString(versionFd, buf, 512) != EOF)
+ {
+ sscanf(buf, "%s", tmpBuf);
+ if (strcmp(tmpBuf, "[BUILDID]") == 0)
+ {
+ charsRead = fioRdString(versionFd, buildBuf, 63);
+ buildBuf[charsRead] = 0;
+ mibBuildId = buildBuf;
+ }
+ if (strcmp(tmpBuf, "[VERSION]") == 0)
+ {
+ charsRead = fioRdString(versionFd, verBuf, 63);
+ verBuf[charsRead] = 0;
+ mibVersionId = verBuf;
+ }
+ if (strcmp(tmpBuf, "[DATE]") == 0)
+ {
+ charsRead = fioRdString(versionFd, dateBuf, 31);
+ dateBuf[charsRead] = 0;
+ mibDate = dateBuf;
+ }
+ if (strcmp(tmpBuf, "[TIME]") == 0)
+ {
+ charsRead = fioRdString(versionFd, timeBuf, 31);
+ timeBuf[charsRead] = 0;
+ mibTime = timeBuf;
+ }
+ if (strcmp(tmpBuf, "[CRYPTO]") == 0)
+ {
+ charsRead = fioRdString(versionFd, cryptoBuf, 31);
+ cryptoBuf[charsRead] = 0;
+ mibCrypto = cryptoBuf;
+ }
+
+ }
+ close(versionFd);
+ }
+ else
+ {
+ printf("not found...using default Version and Build Id\n");
+ }
+
+ sprintf(str, "%s %s %s %s %s %s %s %s %s",
+ VERSION_PREFIX, mibVersionId,
+ DATE_AND_TIME_PREFIX, mibDate, mibTime,
+ BUILD_PREFIX, mibBuildId,
+ CRYPTO_PREFIX, mibCrypto);
+ }
+
+ /* Call product specific post loadMib handler */
+ snmp_postLoadMibHandler();
+
+
+ /* initialize community names */
+ snmpLocalInitCommunityNames();
+
+ /* finally here we go */
+ snmp_log(False, "snmp_initialize", "Snmp initialized successfully");
+ SnmpPostSetEnabled = True;
+ return OK;
+}
+
+
+/* Aug 23, 2000 modified snmp_log() to localize logFileName - Bhawani*/
+void snmp_log(int flag, char *fname, char *spec, ...)
+{
+ char *str;
+ time_t stamp;
+ FILE *logFS;
+ va_list arg_list;
+ static char logFileName[PATH_MAX] = "";
+ static char logstr[SIZE_DisplayString+1];
+ int pos;
+
+ if (logFileName[0] == 0)
+ {
+ /* Get the value of the MNET_BASE environment variable. */
+ str = getenv( "MNET_BASE" );
+ if( str == NULL )
+ {
+ return;
+ }
+ /* Set the log file path */
+ sprintf(logFileName, "%s/mib/snmp.log", str);
+
+ }
+
+ if ((logFS = fopen(logFileName, "a")) == NULL)
+ {
+ sprintf(logstr, "Unable to open logfile %s: (%d) '%s'", logFileName, errno, strerror(errno));
+ snmp_oamCmdStrSet(logstr);
+ return;
+ }
+
+ va_start(arg_list, spec);
+ time(&stamp);
+ str = ctime(&stamp);
+ str[24] = ','; /* Zap the annoying newline. */
+
+ pos = sprintf(logstr, "%s %s, ", str, fname);
+ pos += vsprintf(logstr+pos, spec, arg_list);
+ if (flag == True)
+ {
+ snmp_oamCmdStrSet(logstr); /* a copy to Snmp Last error Mib variable */
+ }
+ fprintf(logFS, "%s\n", logstr); /* a copy to snmp log file */
+ printf("%s\n", logstr); /* a copy to the console */
+ fclose(logFS);
+ va_end(arg_list);
+ return;
+}
+
+void snmp_fixupTable(Table *tbl)
+{
+ int i;
+ int *addr;
+
+ if (!VALID_TABLE(tbl))
+ {
+ DMSG("fixup", printf("snmp_fixupTable passed an invalid table pointer 0x%x\n", (int)tbl));
+ return; /* We do not have a valid table header! */
+ }
+ DMSG("fixup", printf("snmp_fixupTable is fixing up table indicies for tbl at 0x%x\n", (int)tbl));
+
+ for (i=0; i<tbl->end; i++)
+ {
+ addr = (int *)((int)tbl->data + (i*tbl->size));
+ *addr = i;
+ }
+
+}
+
+int snmp_operation(int op)
+{
+ char *name;
+ int status;
+
+ if (op == 0)
+ {
+ return OK;
+ }
+
+ snmp_setValue(MIB_oamCommandExecutionStatus, VAL_oamCommandExecutionStatus_inProgress);
+
+ status = VAL_oamCommandExecutionStatus_failed;
+ DMSG("oam operation", printf("snmp_operation(%d) called\n", op));
+
+ switch (op)
+ {
+
+ case VAL_oamCommand_reloadMib:
+ if (snmp_loadMib(SnmpDefaultMibFileName) == Success)
+ {
+ snmp_log(False, "snmp_operation", "Reload Mib request was successful.");
+ status = VAL_oamCommandExecutionStatus_sucessful;
+ }
+ break;
+
+
+ case VAL_oamCommand_flushMib:
+
+ if (snmpMibWriteDelayTimeoutHandler((int) SnmpDefaultMibFileName) == OK)
+ {
+ snmp_log(False, "snmp_operation", "Flush Mib request was successful.");
+ status = VAL_oamCommandExecutionStatus_sucessful;
+ }
+ break;
+
+
+
+ case VAL_oamCommand_loadMibFromAltFile:
+ name = (char *) snmp_getValue(MIB_oamAlternateMibFileName);
+ if (name)
+ {
+
+ if (snmp_loadMib(name) == Success)
+ {
+ snmp_log(False, "snmp_operation", "Load from alternate Mib file request was successful.");
+ status = VAL_oamCommandExecutionStatus_sucessful;
+ }
+ }
+ break;
+
+ case VAL_oamCommand_saveMibToAltFile:
+ name = (char *) snmp_getValue(MIB_oamAlternateMibFileName);
+ if (name)
+ {
+ if (snmpMibWriteDelayTimeoutHandler((int) name) == Success)
+ {
+ snmp_log(False, "snmp_operation", "Save Mib to alternate file request was successful.");
+ status = VAL_oamCommandExecutionStatus_inProgress;
+ }
+ }
+ break;
+
+ case VAL_oamCommand_saveMibMinDelay:
+ SnmpTimerMibFlushDelay = SnmpTimerMibFlushMinDelay;
+ status = VAL_oamCommandExecutionStatus_sucessful;
+ snmp_log(False, "snmp_operation", "SNMP flush mode set to minimum.");
+ break;
+
+ case VAL_oamCommand_saveMibMinFileIo:
+ SnmpTimerMibFlushDelay = SnmpTimerMibFlushMinFileIo;
+ status = VAL_oamCommandExecutionStatus_sucessful;
+ snmp_log(False, "snmp_operation", "SNMP flush mode set to minimum File I/O.");
+ break;
+
+
+ case VAL_oamCommand_reboot:
+ status = VAL_oamCommandExecutionStatus_inProgress;
+ snmp_reboot(SnmpTimerRebootShortDelay); /* Give a couple of seconds so */
+ /* we can respond to the PDU. */
+ snmp_log(False, "snmp_operation", "Network element reboot request is submitted.");
+ break;
+
+ case VAL_oamCommand_delayedReboot:
+ status = VAL_oamCommandExecutionStatus_inProgress;
+ snmp_reboot(SnmpTimerRebootLongDelay);
+ snmp_log(False, "snmp_operation", "Network element reboot in 30 second request is submitted.");
+ break;
+
+ default:
+ snmp_log(False, "snmp_operation", "Not recognized Oam command (%d)", op);
+ status = VAL_oamCommandExecutionStatus_failed;
+ }
+
+ if (op != VAL_oamCommand_none)
+ {
+ snmp_setValue(MIB_oamCommand, VAL_oamCommand_none);
+ }
+
+ snmp_setValue(MIB_oamCommandExecutionStatus, status);
+
+ return status == VAL_oamCommandExecutionStatus_failed ? Failure : Success;
+}
+
+
+void snmp_postSet(MibTag tag)
+{
+ if (MIB_TBL(tag) == MIBL_mnetErrorInfoMib)
+ {
+ /* This is error event and need to send trap on this one */
+ snmp_trapBroadcast(tag);
+ return;
+ }
+
+ if (True == SnmpPostSetEnabled)
+ {
+ switch(tag)
+ {
+ case MIB_oamCommand:
+ snmp_operation(snmp_getValue(MIB_oamCommand));
+ break;
+
+ default:
+ snmp_mibTimerSet(SnmpDefaultMibFileName);
+ break;
+ }
+ }
+}
+
+
+/* int * = snmp_getAddress(tag, [idx]);
+*
+* This routine is foundation of the snmp_get... and snmp_set... functions.
+* This provides the basic translation from a MIB_TAG into a pointer to the
+* data item in the MIB.
+*/
+
+void * snmp_getAddress( MibTag tag, ...)
+{
+ int typ = MIB_TYP(tag);
+ int col = MIB_SIZ(tag);
+ int idx = MIB_TBL(tag);
+ int itm = MIB_ITM(tag);
+
+ int row = 0;
+ void *addr;
+ Table *tbl;
+ va_list argn;
+
+ if (mibInitialized == False)
+ {
+ return NULL;
+ }
+
+ addr = (void *)((int)mnetMibIndex[idx].addr + ( itm * sizeof(int)));
+
+ if (MTYPE_IS_TABLE(typ))
+ {
+ /* first get the index for the table */
+ va_start(argn, tag);
+ row = va_arg(argn, int);
+ va_end(argn);
+
+ tbl = (Table *) *(void **)addr;
+
+ if ((row < 0) || (row >= table_end(tbl)))
+ {
+ DMSG("address", printf("snmp_getAddress: Invalid row of table %s(tag = %#x, row=%d)\n",
+ snmp_tagName(tag), tag, row));
+ return NULL;
+ }
+ addr = table_getRow(tbl, row); /* Get the address of the table entry. */
+
+ if (typ != MTYPE_TENTRY)
+ {
+ addr = (void *)((int)addr + ( (col-1) * sizeof(int)));
+ }
+ }
+ DMSG("address", printf("snmp_getAddress: Address of %s(tag=%#x,row=%d)=%#x\n",
+ snmp_tagName(tag), tag, row, addr));
+
+ return addr;
+}
+
+
+
+/* snmp_getTableAddress
+*
+* This is a specialized form of the getAddress function. From a MIB tag, we verify
+* this is a table element and then we return the address of the table pointer. This
+* is useful to recover items like the length of the table (ie. the maximum instance
+* of a column in the table).
+*/
+
+Table * snmp_getTableAddress(MibTag tag)
+{
+ int typ = MIB_TYP(tag);
+ int idx = MIB_TBL(tag);
+ int itm = MIB_ITM(tag);
+ void *addr;
+ Table *tbl;
+
+ if (mibInitialized == False)
+ return False;
+
+ if (snmp_validTag(tag) == False)
+ {
+ DMSG("get address", printf("snmp_getTableAddress for tag 0x%x '%s' faild. Invalid tag.\n", tag, snmp_tagName(tag)));
+ return Failure;
+ }
+
+ if (!MTYPE_IS_TABLE(typ)) /* If this is not a table, there is no address. */
+ return Failure;
+
+ addr = (void *)((int)mnetMibIndex[idx].addr + ( itm * sizeof(int)));
+ tbl = (Table *)*((void **)addr); /* This is a pointer to a table. It could */
+ if (!VALID_TABLE(tbl))
+ {
+ DMSG("get address", printf("snmp_getTableAddress: Invalid Table address for %s (tag=%#x, Addr=%#x)\n", snmp_tagName(tag), tag, tbl ));
+ return Failure;
+ }
+ DMSG("address table", printf("snmp_getTableAddress: Address for table %s(tag = %#x) = %#x\n",
+ snmp_tagName(tag), tag, tbl));
+ return tbl;
+}
+
+
+/* int = snmp_getValue (tag, [idx]);
+*
+* This routine is used to retrieve a value from SNMP. It is passed the
+* MIB tag which identifies the particular MIB variable to retrieve. If
+* the MIB tag is one for a table, (MIBT_...) then one needs to specify
+* the optional index of the table element. In SNMP all table items are
+* addressed by item within the row. The index gets appended to the oid
+* for the item. Thus, val = snmp_getValue(MIB_sdcchSAPI0); returns the
+* sdcchSAPIO timer MIB value. val = snmp_getValue(MIBT_channelID_1, 5);
+* return the ChannelID for the fifth channel on transmitter 1.
+*/
+
+int snmp_getValue( MibTag tag, ...)
+{
+ int idx = 0;
+ int val = 0;
+ int value = 0;
+ void *addr;
+
+ va_list argn;
+
+ if (MTYPE_IS_TABLE(MIB_TYP(tag)))
+ {
+ va_start(argn, tag);
+ idx = va_arg(argn, int); /* Table items use an index as well. */
+ va_end(argn);
+ }
+
+
+ DMSG("get", printf("snmp_getValue: %s (tag=%#x, row=%d)\n", snmp_tagName(tag), tag, idx));
+
+ if ((addr = snmp_getAddress(tag, idx)))
+ {
+
+ if (! ( ((MIB_TYP(tag) == MTYPE_STRUCT) && (MIB_ITM(tag) == 0)) || (MIB_TYP(tag) == MTYPE_TENTRY)))
+ {
+ addr = (void *)*((void **)addr); /* Value returns the contents of addr. */
+ }
+ }
+ else
+ {
+ DMSG("get", printf("snmp_getValue: Value of %s, (tag=%#x, row=%d) = %d (0x%08x)\n", snmp_tagName(tag), tag, idx, (int)addr, (int)addr));
+ }
+ SnmpMibGetCount++;
+ return (int) addr;
+}
+
+
+
+/* status = snmp_getEntry(tag, [idx], &value, size);
+*
+* This is similar to snmp_getValue, except that instead of returning
+* the value, it is copied into a data buffer. This can be used to copy
+* the entire contents of one of the MIB tables if desired. Like the
+* snmp_getValue routine, there is an optional index if the mib variable
+* is part of a table. (This is indicated by MIBT_...).
+*/
+
+Status snmp_getEntry(MibTag tag, ...)
+{
+ void *addr, *buf;
+ int size, max, idx = 0;
+ int val = 0, value = 0;
+
+ va_list argn;
+ va_start(argn, tag); /* first unwind the arguments */
+
+ if (MTYPE_IS_TABLE(MIB_TYP(tag)))
+ {
+ idx = va_arg(argn, int); /* Table items use an index as well. */
+ }
+
+ buf = va_arg(argn, void *);
+ size = va_arg(argn, int);
+ va_end(argn);
+
+ if (NULL == buf)
+ {
+ return Failure;
+ }
+
+ addr = snmp_getAddress(tag, idx);
+
+ if (NULL != addr)
+ {
+ switch (MIB_TYP(tag))
+ {
+ case MTYPE_STRING:
+ case MTYPE_STRUCT:
+ case MTYPE_TENTRY:
+ max = MIB_SIZ(tag);
+ break;
+
+ case MTYPE_TSTRING:
+ max = SIZE_DisplayString;
+ break;
+
+ case MTYPE_NUMBER:
+ case MTYPE_TNUMBER:
+ case MTYPE_IPADDR:
+ case MTYPE_TIPADDR:
+ max = 4;
+ break;
+ default:
+ DMSG("get", printf("snmp_getEntry: Invalid tag (%s, %d)\n", snmp_tagName(tag), idx));
+ return Failure;
+ }
+ }
+ memcpy(buf, addr, min(max,size));
+ return Success;
+}
+
+/* status = snmp_setValue(tag, [idx], value);
+*
+* This routine is used to set a value in the MIB structures. The value
+* that the variable is to be set to is passed as an argument. This is
+* the compliment of the snmp_getValue routine.
+*/
+
+Status snmp_setValue( MibTag tag, ...)
+{
+ int value;
+ int idx = 0;
+ va_list argn;
+
+
+ va_start(argn, tag); /* first unwind the arguments */
+
+ if (MTYPE_IS_TABLE(MIB_TYP(tag)))
+ {
+ idx = va_arg(argn, int); /* Table items use an index as well. */
+ }
+ value = va_arg(argn, int);
+ va_end(argn);
+ return snmp_setEntry(tag, idx, (void *) value, 0);
+}
+
+
+/* status = snmp_setEntry(tag, [idx], &value, size);
+*
+* This routine is used to set a value in the MIB structures. A pointer
+* to the variable and its size are passed as arguments. This is the
+* compliment of the snmp_getEntry routine and is used to set entire
+* structures of information at a time.
+*/
+Status
+snmp_setEntry
+(
+ MibTag tag,
+ int idx,
+ void* value,
+ int sz
+)
+{
+ void* addr;
+ char *src, **pDst;
+ int size;
+ Status status = Success;
+
+
+ addr = snmp_getAddress(tag, idx);
+
+ if (NULL == addr)
+ {
+ /* Verify & get addrs for memcpy. */
+ return Failure;
+ }
+
+ /* Single access here to prevent any race condition */
+ snmp_lockMib(True);
+ switch(MIB_TYP(tag))
+ {
+ case MTYPE_STRING:
+ case MTYPE_TSTRING:
+ pDst = (char **) addr;
+ src = (char *) value;
+
+ if (NULL == src)
+ {
+ sz = 0;
+ }
+
+ if (MIB_TYP(tag) == MTYPE_TSTRING)
+ {
+ size = min (sz, SIZE_DisplayString);
+ if (*pDst == NULL)
+ {
+ *pDst = malloc(SIZE_DisplayString+1);
+ (*pDst)[SIZE_DisplayString] = 0;
+ }
+
+ memset(*pDst+size, 0, SIZE_DisplayString-size);
+ }
+ else
+ {
+ if (*pDst == NULL)
+ {
+ /* to prevent error string problem */
+ return Failure;
+ }
+ size = min(sz, MIB_SIZ(tag));
+ memset(*pDst+size, 0, MIB_SIZ(tag)-size);
+ }
+ strncpy(*pDst, src, size);
+ DMSG("set", printf("snmp_setEntry: Set string %s.%d = %s\n", snmp_tagName(tag), idx, *pDst));
+ break;
+
+ case MTYPE_NUMBER:
+ case MTYPE_TNUMBER:
+ *(INTEGER *)addr = (INTEGER)value;
+ DMSG("set", printf("snmp_setEntry: Set number %s.%d = %d (%#x)\n", snmp_tagName(tag), idx, value, value));
+ break;
+
+ case MTYPE_IPADDR:
+ case MTYPE_TIPADDR:
+ *(INTEGER *)addr = (INTEGER)value;
+ DMSG("set", printf("snmp_setEntry: Set IP %s.%d = %s\n", snmp_tagName(tag), idx, int2ip((UINT32)value)));
+ break;
+
+ case MTYPE_STRUCT:
+ case MTYPE_TENTRY:
+ size = MIB_SIZ(tag);
+ memcpy(addr, value, size); /* rather than *(void **)addr = (void *)value; */
+ DMSG("set", printf("snmp_setEntry struct %s.%d\n", snmp_tagName(tag), idx));
+ break;
+
+ default:
+ DMSG("set", printf("snmp_setEntry: Invalid Tag type (%s, %#x, %d)\n", snmp_tagName(tag), tag, (MIB_TYP(tag))));
+ status = Failure;
+ break;
+ }
+ snmp_lockMib(False);
+
+ if (status == Success)
+ {
+ snmp_postSet(tag);
+ }
+ SnmpMibSetCount++;
+ return status;
+}
+
+
+ /* snmp_findTag() Qsort style function to find a particular tag.
+ *
+ * This function is used as a qsort process to sort tables based on the tags.
+ * It is assumed that the first entry in the table is the tag to look for.
+ * This can be used for the table_find process as well if we emulate the
+ * the qsort style of argument passing, that is a pointer to the argument
+ * is passed.
+ */
+
+ int snmp_findTag( const void *arg1, const void *arg2)
+ {
+
+ return (*(int*)arg1-*(int*)arg2);
+ }
+
+
+ SEM_ID mibLock = 0;
+
+ Status snmp_lockMib(int lock)
+ {
+
+ if (!mibLock)
+ {
+ mibLock = semBCreate(SEM_Q_PRIORITY, SEM_FULL);
+ }
+
+ if (lock)
+ {
+ semTake(mibLock, WAIT_FOREVER);
+ }
+ else
+ {
+ semGive(mibLock);
+ }
+ return Success;
+ }
+
+ /* Status = snmp_validTag(tag);
+ *
+ * This routine is used to validate the mib tags. We look at each field
+ * make sure that it is within range. This will insure that the address
+ * that is calculated is contained within the actual MIB structures.
+ */
+
+ Status snmp_validTag(MibTag tag)
+ {
+ int typ = MIB_TYP(tag);
+ int siz = MIB_SIZ(tag);
+ int tbl = MIB_TBL(tag);
+ int itm = MIB_ITM(tag);
+ int i;
+ static int strStartIdx = 0;
+
+
+ DMSG("validate", printf("snmp_validTag: Tag %s(tag=%#x,typ=%d,sz=%d,tbl=%d,itm=%d)\n",
+ snmp_tagName(tag), tag, typ, siz, tbl, itm));
+
+
+ if ((tbl < 0) || (tbl > MTBL_last))
+ {
+ return False;
+ }
+
+ if (itm > mnetMibIndex[tbl].size/4)
+ {
+ return False;
+ }
+
+ if (strStartIdx == 0)
+ {
+ strStartIdx = MTBL_last;
+ tag = mnetMibIndex[++strStartIdx].tag;
+
+ while (tag && (MIB_TYP(tag) != MTYPE_STRING))
+ {
+ tag = mnetMibIndex[++strStartIdx].tag;
+ }
+ }
+
+ switch (typ)
+ {
+ case MTYPE_STRUCT:
+ if (itm || (siz != mnetMibIndex[tbl].size))
+ {
+ return False;
+ }
+ break;
+
+ case MTYPE_NUMBER:
+ case MTYPE_IPADDR:
+ if (siz != 4)
+ {
+ return False;
+ }
+ break;
+
+ case MTYPE_STRING:
+ for ( i = strStartIdx; mnetMibIndex[i].tag != 0; i++)
+ {
+ if (tag == mnetMibIndex[i].tag)
+ {
+ return True;
+ }
+ }
+ return False;
+
+
+ case MTYPE_TENTRY:
+ case MTYPE_TNUMBER:
+ case MTYPE_TIPADDR:
+ case MTYPE_TSTRING:
+ tag = MIB_TABLE(tbl, itm); /* create table tag first */
+ case MTYPE_TABLE:
+
+ for ( i = MTBL_last+1; i < strStartIdx; i++)
+ {
+ if ( tag == mnetMibIndex[i].tag)
+ {
+ return True;
+ }
+ }
+ return False;
+
+ default:
+ return False;
+ }
+ return True;
+ }
+
+ void snmp_getPdu(SNMP_PKT_T *pktp, VB_T *vbp, int value)
+ {
+ int size;
+ char* str;
+
+ switch (VB_TYPE(vbp))
+ {
+ case MTYPE_STRING:
+ case MTYPE_TSTRING:
+ str = (char *) value;
+ if (str == NULL)
+ {
+ size = 0;
+ }
+ else
+ {
+ size = min (strlen(str), SIZE_DisplayString);
+ }
+ getproc_got_string(pktp, vbp, size , str, 0, VT_STRING);
+ break;
+
+ case MTYPE_IPADDR:
+ case MTYPE_TIPADDR:
+ getproc_got_ip_address(pktp, vbp, value);
+ break;
+
+ case MTYPE_NUMBER:
+ case MTYPE_TNUMBER:
+ getproc_got_int32(pktp, vbp, value);
+ break;
+
+ default:
+ getproc_error(pktp, vbp, INCONSISTENT_NAME);
+ DMSG("get method", printf("snmp_getPdu: 6: Bad tag!!! Setting getproc_error(..., INCONSISTENT_NAME)\n"));
+ return;
+
+ } /* switch */
+
+ getproc_good(pktp, vbp);
+ DMSG("get method", printf("snmp_getPdu: 7: setting getproc_good(...)\n"));
+
+ }
+
+
+ /* SNMP PDU Processing method routines.
+ *
+ * These routines are used by the SNMP agent to retrieve values from the
+ * MIB. The started from the -skel output from MIBCOMP. The are used to
+ * implement the Get/Set processing of the PDU's. There are 4 basic method
+ * routines that we implement.
+ *
+ * snmp_getMethod() Used to get an item from the MIB
+ * snmp_setMethod() USed to set an item in the MIB
+ * snmp_testMethod() Used to test the value of a MIB variable.
+ * snmp_nextMethod() Used to get the next item from the MIB
+ */
+
+
+
+ void snmp_getMethod (
+ OIDC_T lastmatch,
+ int compc,
+ OIDC_T *compl,
+ SNMP_PKT_T *pktp,
+ VB_T *vbp)
+
+ {
+ int tag, ttag, value, idx = 0;
+ Table *tbl;
+
+ /* The get method routine is called to retrieve the current item. The
+ * processing here is very similar to the next method, except that we
+ * don't need to set the next instance information.
+ */
+
+ /* Although I have never seen it happen, the varbind list may have
+ * multiple data items to process. Do them all.
+ */
+
+ for (snmpdGroupByGetprocAndInstance(pktp, vbp, compc, compl);
+ vbp; vbp = vbp->vb_link) {
+ tag = VB_TAG(vbp);
+ DMSG("get method", printf("snmp_getMethod: Processing varbind for item %s\n", snmp_tagName(tag)));
+
+ if (mibInitialized == False)
+ {
+ getproc_error(pktp, vbp, RESOURCE_UNAVAILABLE);
+ DMSG("get method", printf("snmp_getMethod: MIB not initialized!!! Setting getproc_error(..., RESOURCE_UNAVAILABLE)\n"));
+ continue;
+ }
+ if (compc && MTYPE_IS_SCALAR(VB_TYPE(vbp)))
+ {
+ /* Scalar */
+
+ if (*compl)
+ { /* Scalars can only be single instances. */
+ getproc_nosuchins(pktp, vbp);
+ DMSG("get method", printf("snmp_getMethod: 2: setting nextproc_nosuchins(...)\n"));
+ continue; /* are in the MIB. */
+ }
+ }
+ else if (compc)
+ { /* Tabular entry ? */
+ idx = *compl;
+ ttag = MIB_TABLE(VB_TBL(vbp), VB_ITM(vbp)); /* Get the table pointer. */
+ tbl = (Table *)snmp_getValue(ttag); /* So that we can tell if */
+ if (!VALID_TABLE(tbl))
+ {
+ DMSG("get method", printf("WARNING!! Invalid table pointer!!\n"));
+ getproc_nosuchins(pktp, vbp); /* nope. */
+ DMSG("get method", printf("snmp_getMethod: 3: Setting getproc_nosuchins(...)\n"));
+ continue;
+ }
+
+ if (idx >= table_end(tbl))
+ { /* Is entry there? */
+ DMSG("get method", printf("snmp_getMethod: Instance %d too big. Table has %d entries.\n", idx, table_end(tbl)));
+ getproc_nosuchins(pktp, vbp); /* nope. */
+ DMSG("get method", printf("snmp_getMethod: 4: Setting getproc_nosuchins(...)\n"));
+ continue;
+ }
+ }
+ else
+ { /* Scalar entry with compc = 0 */
+ getproc_nosuchins(pktp, vbp);
+ DMSG("get method", printf("snmp_getMethod: 5: Setting getproc_nosuchins(...)\n"));
+ continue;
+ }
+
+ if (snmp_validTag(tag) == False)
+ {
+ getproc_error(pktp, vbp, NO_SUCH_NAME);
+ DMSG("get method", printf("snmp_getMethod: 6: Bad tag!!! Setting getproc_error(..., NON_SUCH_NAME)\n"));
+ continue;
+ }
+ value = snmp_getValue(tag, idx);
+ DMSG("get method", printf("snmp_getMethod: Value of %s(tag=%#x,row=%d)=%d (%#x)\n", snmp_tagName(tag), tag, idx, value, value));
+ snmp_getPdu(pktp, vbp, value);
+ }
+ }
+
+ void snmp_setMethod(
+ OIDC_T lastmatch,
+ int compc,
+ OIDC_T* compl,
+ SNMP_PKT_T* pktp,
+ VB_T* vbp)
+ {
+ int tag, ttag, value, old, idx = 0;
+ Table *tbl;
+ EBUFFER_T *ebuf;
+ char *str;
+ ValueType typ = VT_VALUE;
+ static int* pAccessFlag = NULL;
+
+ if (pAccessFlag == NULL)
+ {
+ if (NULL==(pAccessFlag = snmp_getAddress(MIB_mibAccessControlFlag)))
+ return;
+ }
+
+ /* The set method routine is called to store a value for the current item.
+ * The processing here is very similar to the get method, except that we
+ * store data rather than retrieve it.
+ */
+
+ /* Although I have never seen it happen, the varbind list may have
+ * multiple data items to process. Do them all.
+ */
+
+ for (snmpdGroupByGetprocAndInstance(pktp, vbp, compc, compl); vbp; vbp = vbp->vb_link)
+ {
+ tag = VB_TAG(vbp);
+ DMSG("set method", printf("snmp_setMethod: %s(tag=%#x)\n", snmp_tagName(tag), tag));
+
+ if (mibInitialized == False)
+ {
+ setproc_error(pktp, vbp, RESOURCE_UNAVAILABLE);
+ DMSG("set method", printf("snmp_setMethod: 1a: MIB not initialized!!! Setting setproc_error(..., RESOURCE_UNAVAILABLE)\n"));
+ continue;
+ /* Note: This is temporary. Later we will add a value to the OAM table. */
+ }
+
+ if ((*pAccessFlag == VAL_mibAccessControlFlag_false) && (tag != MIB_mibAccessControlFlag))
+ {
+ setproc_error(pktp, vbp, NO_ACCESS);
+ DMSG("set method", printf("snmp_setMethod: MIB not enabled!!! Setting setproc_error(..., NO_ACCESS)\n"));
+ continue;
+ }
+
+ if (compc && MTYPE_IS_SCALAR(VB_TYPE(vbp)))
+ {
+ if (*compl) { /* Scalar entry ? */
+ setproc_error(pktp, vbp, NO_SUCH_NAME); /* Yes, only single instances */
+ DMSG("set method", printf("snmp_setMethod: 2: setting settproc_error(..., NO_SUCH_NAME)\n"));
+ continue; /* are in the MIB. */
+ }
+ }
+ else if (compc)
+ { /* Tabular entry ? */
+ idx = *compl;
+ ttag = MIB_TABLE(VB_TBL(vbp), VB_ITM(vbp)); /* Set the table pointer. */
+ tbl = (Table *)snmp_getValue(ttag); /* So that we can tell if */
+
+ if (!VALID_TABLE(tbl))
+ {
+ DMSG("set method", printf("WARNING!! Invalid table pointer!!\n"));
+ setproc_error(pktp, vbp, INCONSISTENT_NAME); /* nope. */
+ DMSG("set method", printf("snmp_setMethod: 3a: Setting setproc_error(..., INCONSISTENT_NAME)\n"));
+ continue;
+ }
+
+ if (idx >= table_end(tbl))
+ { /* Is entry there? */
+ DMSG("set method", printf("snmp_setMethod: 3b: Instance %d too big. Table has %d entries.\n", idx, table_end(tbl)));
+ setproc_error(pktp, vbp, NO_SUCH_NAME); /* nope. */
+ DMSG("set method", printf("snmp_setMethod: 4: Setting setproc_error(..., NO_SUCH_NAME)\n"));
+ continue;
+ }
+
+ }
+ else
+ { /* Scalar entry with compc = 0 */
+ setproc_error(pktp, vbp, NO_SUCH_NAME);
+ DMSG("set method", printf("snmp_setMethod: 5: Setting setproc_error(..., NO_SUCH_NAME)\n"));
+ continue;
+ }
+
+ if (snmp_validTag(tag) == False) {
+ setproc_error(pktp, vbp, NO_SUCH_NAME);
+ DMSG("set method", printf("snmp_setMethod: 6: Bad tag!!! Setting setproc_error(..., NON_SUCH_NAME)\n"));
+ continue;
+ }
+
+ switch (VB_TYPE(vbp))
+ {
+ case MTYPE_TNUMBER:
+ case MTYPE_TIPADDR:
+
+ typ = VT_TABLE;
+
+ case MTYPE_NUMBER:
+ case MTYPE_IPADDR:
+
+
+ old = snmp_getValue(tag, idx);
+ value = (int) VB_GET_INT32(vbp);
+
+ if (value == old)
+ { /* Same as old value, say set was good, but bypass actual saving */
+ DMSG("set method", printf("snmp_setMethod: 6a: Suppressing set for '%s'. Old value = %d, New value = %d\n",
+ snmp_tagName(tag), old, value));
+ setproc_good(pktp, vbp);
+ continue;
+ }
+ else
+ {
+ DMSG("set method", printf("snmp_setMethod: 7: Setting number %s(%d) = %d (%#x)\n", snmp_tagName(tag), idx, value, value));
+
+ snmp_setEntry(tag, idx, (void *) value, 4);
+ setproc_good(pktp, vbp);
+ }
+ break;
+
+ case MTYPE_STRING:
+ case MTYPE_TSTRING:
+
+ ebuf = VB_GET_STRING(vbp);
+ str = (char *) EBufferStart(ebuf);
+ snmp_setEntry(tag, idx, str, EBufferUsed(ebuf));
+ typ = VT_ADDRESS; /* Setup for the processTrap call below */
+ value = (int)snmp_getValue(tag, idx);
+ DMSG("set method", printf("snmp_setMethod: 8a: Setting string %s(%d) ='%s'\n", snmp_tagName(tag), idx, (char *)value));
+ break;
+
+
+ default: /* Only structural elements are left.. The manager can't write them. */
+ setproc_error(pktp, vbp, NOT_WRITABLE);
+ DMSG("set method", printf("snmp_setMethod: 10: Bad tag!!! Setting setproc_error(..., NOT_WRITABLE)\n"));
+ continue;
+
+ } /* Switch */
+ DMSG("set method", printf("snmp_setMethod: 11: setting setproc_good(...)\n"));
+ setproc_good(pktp, vbp);
+
+ DMSG("set method", printf("snmp_setMethod: 12: calling processTrap(%d, %s, %d, %d)\n",
+ SNMP_AGENT_MODULE_ID, snmp_tagName(tag), typ, value));
+ oam_processTrap(SNMP_AGENT_MODULE_ID, tag, typ, value, idx);
+ } /* for */
+}
+
+
+
+void snmp_nextMethod (
+ OIDC_T lastmatch,
+ int compc,
+ OIDC_T *compl,
+ SNMP_PKT_T *pktp,
+ VB_T *vbp)
+{
+ OIDC_T next = 0;
+ int tag, ttag, value, idx = 0;
+ Table *tbl;
+
+
+ /* The next method routine is called to retrieve the current item
+ * and to set inforamation necessary to this routine the next time.
+ * We are passed the OID of the last thing that was recovered. We
+ * step to the next instance of the variable and return it.
+ */
+ /* Although I have never seen it happen, the varbind list may have
+ * multiple data items to gather. Process all of them.
+ */
+ for (snmpdGroupByGetprocAndInstance(pktp, vbp, compc, compl); vbp; vbp = vbp->vb_link)
+ {
+ tag = VB_TAG(vbp);
+ DMSG("next method", printf("snmp_nextMethod: Processing varbind for item %s\n", snmp_tagName(tag)));
+
+
+ if (mibInitialized == False)
+ {
+ nextproc_error(pktp, vbp, RESOURCE_UNAVAILABLE);
+ DMSG("next method", printf("snmp_getMethod: 1: MIB not initialized!!! Setting getproc_error(..., RESOURCE_UNAVAILABLE)\n"));
+ continue;
+ }
+ if (compc)
+ {
+ if (MTYPE_IS_SCALAR(VB_TYPE(vbp)))
+ {
+ /* compc != 0 and scalar */
+ /* If this is a scalar type, then */
+ /* there are no OID.n type of entries */
+ nextproc_no_next(pktp, vbp);
+ DMSG("next method", printf("snmp_nextMethod: 1: setting nextproc_no_next(...)\n"));
+ continue;
+ }
+ else
+ {
+ /* compc != 0 and tabular */
+
+ idx = *compl+1; /* Step to the next entry. */
+table_entry:
+ ttag = MIB_TABLE(VB_TBL(vbp), VB_ITM(vbp)); /* Get the table pointer. */
+ tbl = (Table *)snmp_getValue(ttag); /* So that we can tell if */
+ DMSG("next method", printf("snmp_getValue returned 0x%x\n",(int)tbl));
+ if (!VALID_TABLE(tbl))
+ {
+ DMSG("next method", printf("WARNING!! Invalid table pointer\n"));
+ }
+ else
+ {
+ DMSG("next method", printf("Found valid table pointer\n"));
+ }
+
+ if (idx >= table_end(tbl))
+ { /* Is this item there? */
+ DMSG("next method", printf("snmp_nextMethod: 2: Instance %d too big. Table has %d entries.\n", idx, table_end(tbl)));
+ nextproc_no_next(pktp, vbp);
+ DMSG("next method", printf("snmp_nextMethod: 3: setting nextproc_no_next(...)\n"));
+ continue;
+ }
+ next = idx;
+ nextproc_next_instance(pktp, vbp, 1, &next);
+ DMSG("next method", printf("snmp_nextMethod: 4: Setting nextproc_next_instance(..., %d)\n", (int)next));
+ }
+ }
+ else
+ {
+ if (MTYPE_IS_TABLE(VB_TYPE(vbp)))
+ {
+ /* compc == 0, tabular entry */
+ DMSG("next method", printf("snmp_nextMethod: 5: Tabular entry with compc == 0. Processing....\n"));
+ idx = 0;
+ goto table_entry; /* Yes, handle it. */
+ }
+ else
+ {
+ /* compc == 0, scalar entry */
+ next = 0;
+ nextproc_next_instance(pktp, vbp, 1, &next);
+ DMSG("next method", printf("snmp_nextMethod: 6: setting nextproc_next_instance(..., %d)\n", (int)next));
+ }
+ }
+
+ if (snmp_validTag(tag) == False)
+ {
+ nextproc_error(pktp, vbp, NO_SUCH_NAME);
+ DMSG("next method", printf("snmp_nextMethod: 7: Bad tag!!! Setting nextproc_error(..., NO_SUCH_NAME)\n"));
+ }
+ else
+ {
+ value = snmp_getValue(tag, idx);
+ DMSG("next method", printf("snmp_nextMethod: 8: Getting value for tag '0x%08x' '%s'=%d\n", tag, snmp_tagName(tag), value));
+ snmp_getPdu(pktp, vbp, value);
+ }
+ } /* for */
+}
+
+
+char * snmp_tagName(MibTag tag)
+{
+ static char buf[20];
+
+ MnetMibDataType *dtype;
+
+ if (!(dtype = (MnetMibDataType *)table_find(mnetMibDataTypeTable, snmp_findTag, (void *)&tag))) {
+ sprintf(buf, "Tag '0x%08x'", tag);
+ return buf;
+ }
+ return dtype->name;
+
+}
+
+int snmp_nameToTag(char *name)
+{
+ char c, buf[80], tag1[80], tag2[80];
+ int i, tag;
+
+ /* Be a little clever about the name that is given. Copy it to the
+ * the data buffer and put it in the form that we can use. We change
+ * any - characters to the _ used in the MIB tag name. If the name
+ * does not start with MIB_, we prepend it. We use strcasecmp to do
+ * a case independent compare. Try to be as friendly as possible. */
+
+ i = -1;
+ while ((++i < 80) && (c = *name++))
+ {
+ if (c == '-') c = '_'; /* Convert the - to _. */
+ buf[i] = c; /* Store the character away. */
+ }
+ buf[i] = 0; /* Terminate the name. */
+
+ if (!strncmp(buf, "MIB", 3))
+ { /* already have MIB_ in the */
+ strcpy(tag1, buf); /* name ? If so, assume the */
+ tag2[0] = 0; /* user knew what they were */
+ }
+ else
+ { /* typing. If not, they get */
+ sprintf(tag1, "MIB_%s", buf); /* an error message.*/
+ sprintf(tag2, "MIBT_%s", buf); /* 2 possibilities. */
+ }
+
+ DMSG("get Item", printf("snmp_nameToTag: Serching tag names: %s and %s\n", tag1, tag2));
+ i = -1;
+ while (mnetMibDataType[++i].tag)
+ {
+ if (!strcasecmp(tag1, mnetMibDataType[i].name) ||
+ (*tag2 && !strcasecmp(tag2, mnetMibDataType[i].name)))
+ break;
+ }
+ tag = mnetMibDataType[i].tag;
+ return tag;
+}
+
+
+int SnmpMibGet(char *name, ...)
+{
+ int tag, value, idx = 0;
+ MibTableInfo *mib;
+ va_list argn;
+
+
+ if (tag = snmp_nameToTag(name))
+ {
+ if (MTYPE_IS_TABLE(MIB_TYP(tag)))
+ {
+ va_start(argn, name); /* Entry or an element out of the entry. */
+ idx = va_arg(argn, int);
+ va_end(argn);
+ }
+
+ value = snmp_getValue(tag, idx);
+ switch (MIB_TYP(tag))
+ {
+ case MTYPE_STRUCT:
+ mib = (MibTableInfo *)value;
+ printf("%s = (0x%08x). Size=%d, dirty=%s, lock=%s, set=%s, get=%s\n",
+ snmp_tagName(tag), value, MIB_SIZ(tag), mib->info.dirty?"True":"False", mib->info.lock ? "True":"False",
+ mib->info.getTrap?"True":"False", mib->info.setTrap?"True":"False");
+ break;
+
+ case MTYPE_NUMBER:
+ case MTYPE_TNUMBER:
+ printf("%s.%d = \"%d\" (0x%08x)\n", snmp_tagName(tag), idx, value, value);
+ break;
+
+ case MTYPE_STRING:
+ case MTYPE_TSTRING:
+ printf("%s.%d = \"%s\"\n", snmp_tagName(tag), idx, value, (char *)value);
+ break;
+
+ case MTYPE_IPADDR:
+ case MTYPE_TIPADDR:
+ printf("%s.%d = \"%s\" (%#x)\n", snmp_tagName(tag), idx, int2ip(value), value);
+ break;
+
+ case MTYPE_TENTRY:
+ printf("%s.%d = (0x%08x). Table entry is %d bytes long\n", snmp_tagName(tag), idx, value, MIB_SIZ(tag));
+ break;
+
+ default:
+ printf("Unknown Mib Type=%d\n", MIB_TYP(tag));
+
+ } /* switch */
+ }
+ else
+ {
+ printf("Unable to locate MIB tag from supplied mib string '%s'\n", name);
+ }
+ return 0;
+}
+
+int SnmpMibSet(char *name, ...)
+{
+ int tag, value, idx = 0;
+ char* str;
+ Status status = Failure;
+
+ va_list argn;
+ va_start(argn, name); /* Entry or an element out of the entry. */
+
+ if (tag = snmp_nameToTag(name))
+ {
+ if (MTYPE_IS_TABLE(MIB_TYP(tag)))
+ {
+ idx = va_arg(argn, int);
+ }
+
+ switch (MIB_TYP(tag))
+ {
+
+ case MTYPE_NUMBER:
+ case MTYPE_TNUMBER:
+ value = va_arg(argn, int);
+ status = snmp_setEntry(tag, idx, (void *) value, 4);
+ break;
+
+
+ case MTYPE_STRING:
+ case MTYPE_TSTRING:
+ str = va_arg(argn, char *);
+ status = snmp_setEntry(tag, idx, str, strlen(str));
+ break;
+
+ case MTYPE_IPADDR:
+ case MTYPE_TIPADDR:
+ str = va_arg(argn, char *);
+ status = snmp_setEntry(tag, idx, (void *) inet_addr(str), 4);
+ break;
+
+ default:
+ printf("Unknown or not allowed Mib Type=%d\n", MIB_TYP(tag));
+
+ } /* switch */
+ }
+ else
+ {
+ printf("Unable to locate MIB tag from supplied mib string '%s'\n", name);
+ }
+
+ if (Success == status)
+ {
+ printf("Snmp Set was successful\n");
+ }
+
+ va_end(argn);
+ return 0;
+}
+
+#define SIZE_MibTagName 128
+int SnmpMibLookup(char *name)
+{
+ char buf[SIZE_MibTagName+1];
+ char pszTagName[SIZE_MibTagName+1];
+ int i, j, k;
+ char c;
+
+ if (NULL == name)
+ {
+ return ERROR;
+ }
+
+ k = min (SIZE_MibTagName, strlen(name));
+
+ for (i=0; i <k; i++)
+ {
+ if (c == '-')
+ {
+ c = '_';
+ }
+ buf[i] = toupper(name[i]);
+ }
+ buf[k] = 0;
+
+ DMSG("lookup", printf("SnmpMibLookup: Case insensetive search \'%s\'\n", buf));
+
+ i = 0;
+ while (mnetMibDataType[i].tag)
+ {
+ k = min(SIZE_MibTagName, strlen(mnetMibDataType[i].name));
+
+ for (j=0; j< k; j++)
+ {
+ pszTagName[j] = toupper(mnetMibDataType[i].name[j]);
+ }
+ pszTagName[k] = 0;
+
+ if (strstr(pszTagName, buf))
+ {
+ printf("%s ( %#x = %d )\n", mnetMibDataType[i].name, mnetMibDataType[i].tag, mnetMibDataType[i].tag);
+ }
+ i++;
+ }
+ return 0;
+}
+
+
+
+
+#ifdef DEBUG
+void
+snmp_printPDU(
+ SNMP_PKT_T *pktp,
+ char *where)
+{
+ VB_T *vbp;
+ MIBLEAF_T *ml;
+ int i;
+
+#ifdef LONG_PDU_PRINTOUT
+ printf("PDU Type='%s', length=%d, view=%d, flags='%x', phase='%x', max pkt=%d\n", snmp_printPduType(pktp->pdu_type),
+ pktp->pdu_length, pktp->mib_view, pktp->flags, pktp->phase, pktp->maxpkt);
+ printf(" cookie='%x', version=%d, view idx=%d, ident=%d, request id=%d\n", pktp->async_cookie,
+ pktp->snmp_version, pktp->view_index, pktp->lcl_ident, pktp->pdu.std_pdu.request_id);
+ printf(" error status=%d, error index=%d, max reps=%d, non reps=%d\n",
+ pktp->pdu.std_pdu.error_status, pktp->pdu.std_pdu.error_index,
+ pktp->pdu.std_pdu.max_reps, pktp->pdu.std_pdu.non_reps);
+ printf(" Std VBL_T: length=%d, count=%d, VBL_S='%x'\n", pktp->pdu.std_pdu.std_vbl.vbl_length,
+ pktp->pdu.std_pdu.std_vbl.vbl_count, pktp->pdu.std_pdu.std_vbl.vblp);
+ vbp = pktp->pdu.std_pdu.std_vbl.vblist;
+ for (; vbp; vbp = vbp->vb_link) {
+ printf(" objid='%x', num components=%d, component list=[", vbp->vb_obj_id,
+ vbp->vb_obj_id.num_components);
+ i = -1;
+ while (++i < vbp->vb_obj_id.num_components)
+ printf(i?", %d":"%d", vbp->vb_obj_id.component_list[i]);
+ printf("]\n");
+
+ printf(" seq size=%d, data flags n type='%x', flags='%x', data length=%d\n",
+ vbp->vb_obj_id, vbp->vb_seq_size, vbp->vb_data_flags_n_type, vbp->vb_flags, vbp->vb_data_length);
+ ml = vbp->vb_ml.ml_leaf;
+ printf(" Mib Leaf for %s, view mask='%x', write mask='%x':\n", snmp_tagName((int)ml->user_cookie),
+ ml->view_mask, ml->write_mask);
+ printf(" expected tag=%d, access type=%d, cookie='%x', locator=%d\n",
+ ml->expected_tag, ml->access_type, ml->user_cookie, ml->locator);
+ printf(" testproc='%x', getproc='%x', setproc='%x', nextproc='%x'\n",
+ ml->testproc, ml->getproc, ml->setproc, ml->nextproc);
+ }
+ printf(" Saved VBL_T: length=%d, count=%d, VBL_S='%x'\n", pktp->pdu.std_pdu.saved_vbl.vbl_length,
+ pktp->pdu.std_pdu.saved_vbl.vbl_count, pktp->pdu.std_pdu.saved_vbl.vblp);
+ vbp = pktp->pdu.std_pdu.saved_vbl.vblist;
+ for (; vbp; vbp = vbp->vb_link) {
+ printf(" objid='%x' seq size=%d, data flags n type='%x', flags='%x', data length=%d\n",
+ vbp->vb_obj_id, vbp->vb_seq_size, vbp->vb_data_flags_n_type, vbp->vb_flags, vbp->vb_data_length);
+ ml = vbp->vb_ml.ml_leaf;
+ printf(" Mib Leaf for %s, view mask='%x', write mask='%x':\n", snmp_tagName(ml->user_cookie),
+ ml->view_mask, ml->write_mask);
+ printf(" expected tag=%d, access type=%d, cookie='%x', locator=%d\n",
+ ml->expected_tag, ml->access_type, ml->user_cookie, ml->locator);
+ printf(" testproc='%x', getproc='%x', setproc='%x', nextproc='%x'\n",
+ ml->testproc, ml->getproc, ml->setproc, ml->nextproc);
+ }
+#else
+ printf("%s: PDU Type='%s', length=%d, request id=%d, VBL_T length=%d, count=%d\n", where,
+ snmp_printPduType(pktp->pdu_type), pktp->pdu_length, (int)pktp->pdu.std_pdu.request_id,
+ pktp->pdu.std_pdu.std_vbl.vbl_length, pktp->pdu.std_pdu.std_vbl.vbl_count);
+ vbp = pktp->pdu.std_pdu.std_vbl.vblist;
+ if (pktp->pdu_length > 512 || pktp->pdu.std_pdu.std_vbl.vbl_count > 10)
+ return;
+ else for (; vbp; vbp = vbp->vb_link) {
+ ml = vbp->vb_ml.ml_leaf;
+ printf(" VB_T tag='0x%08x' %s, oid=", (int)ml->user_cookie, snmp_tagName((int)ml->user_cookie));
+ if (vbp->vb_obj_id.num_components < 20) {
+ i = -1;
+ while (++i < vbp->vb_obj_id.num_components)
+ printf(i?".%d":"%d", vbp->vb_obj_id.component_list[i]);
+ printf("\n");
+ } else printf("invalid OID contains %d components\n", vbp->vb_obj_id.num_components);
+ }
+#endif
+}
+
+char *
+snmp_printPduType(op)
+{
+ static char buf[20];
+
+ switch (op) {
+ case GET_REQUEST_PDU: return "GET_REQUEST";
+ case GET_NEXT_REQUEST_PDU: return "GET_NEXT_REQUEST";
+ case GET_RESPONSE_PDU: return "GET_RESPONSE";
+ case SET_REQUEST_PDU: return "SET_REQUEST";
+ case TRAP_PDU: return "TRAP";
+ case GET_BULK_REQUEST_PDU: return "GET_BULK_REQUEST";
+ case INFORM_REQUEST_PDU: return "INFORM_REQUEST";
+ case TRAP2_PDU: return "TRAP2";
+ case REPORT_PDU: return "REPORT";
+ default: sprintf(buf, "%d", op);
+ return buf;
+ }
+}
+
+#endif
diff --git a/data/mnet/Common/socket/Makefile b/data/mnet/Common/socket/Makefile
new file mode 100644
index 0000000..2466a80
--- /dev/null
+++ b/data/mnet/Common/socket/Makefile
@@ -0,0 +1,47 @@
+##########################################################
+#
+# (c) Copyright Cisco 2000
+# All Rights Reserved
+#
+# Use Examples:
+#
+# Case 1:
+# make all VOB=GP10 -
+# Places .out in VOB/bin directory
+#
+# Case 2:
+# make all VOB=GP10 APPDIR=Host\<Application Name>\<Source Directory> -
+# Places .o file(s) in VOB\$(APPDIR)\bin directory.
+#
+# <Application Name> = Name of Application directory
+# <Source Directory> = application sub directory where the calling
+# Makefile resides.
+#
+# Example: make all VOB=GP10 APPDIR=Host\vxTemplate\src
+#
+# (OPTIONAL) Append REPLACE - Replaces the List of directories
+# to be used in the SUBDIRS variable
+#
+# Example: make all VOB=GP10 APPDIR=Host\vxTemplate\src REPLACE="src_api src_debug"
+#
+# Note: This make file must reference a VOB that
+# has a defs.mk in the top level directory.
+#
+##########################################################
+
+SUBDIRS = src
+
+# TOP_OF_VOB must be defined before including l3defs.mk
+TOP_OF_VOB = ..
+
+VOBDIR = $(TOP_OF_VOB)/../$(VOB)
+
+# Allows a sub-set of the source code directories to be used
+
+ifneq ($(REPLACE),)
+ SUBDIRS = $(REPLACE)
+endif
+
+include $(VOBDIR)\l3defs.mk
+
+
diff --git a/data/mnet/Common/socket/include/CallBackSSL.h b/data/mnet/Common/socket/include/CallBackSSL.h
new file mode 100644
index 0000000..3d7b316
--- /dev/null
+++ b/data/mnet/Common/socket/include/CallBackSSL.h
@@ -0,0 +1,35 @@
+#ifndef __CALLBACKSSL_H__
+#define __CALLBACKSSL_H__
+
+//*******************************************************************
+//
+// (c) Copyright CISCO Systems Inc. 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// File : CallBackSSL.h
+// Author(s) : Igal Gutkin
+// Create Date : 5/22/01
+// Description : declaration of the service function required by the
+// SSL library
+//
+// *******************************************************************
+
+int verify_callback (int ok , X509_STORE_CTX *ctx);
+
+#if defined (_OPEN_SSL_LIB_)
+
+ int password_cb (char *buf, int num ,int rwflag, void *userdata);
+
+#elif defined (_RSA_SSL_LIB_)
+
+ int password_cb (char *buf, int num ,int rwflag);
+
+#endif
+
+
+#endif //__CALLBACKSSL_H__ \ No newline at end of file
diff --git a/data/mnet/Common/socket/src/GenClientSocket.cpp b/data/mnet/Common/socket/src/GenClientSocket.cpp
new file mode 100644
index 0000000..95fcc8a
--- /dev/null
+++ b/data/mnet/Common/socket/src/GenClientSocket.cpp
@@ -0,0 +1,236 @@
+// *******************************************************************
+//
+// (c) Copyright CISCO Systems, Inc 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// Status : Under development
+// File : GenClientSocket.cpp
+// Author(s) : Igal Gutkin
+// Create Date : 06/20/00
+// Description : implementation of the GenClientSocket class
+//
+// *******************************************************************
+
+
+#include "socket\GenClientSocket.h"
+
+//////////////////////////////////////////////////////////////////////
+// Static data members
+//////////////////////////////////////////////////////////////////////
+SSL_CTX *GenClientSocket::pCtx_ = NULL;
+
+
+//////////////////////////////////////////////////////////////////////
+// Construction/Destruction
+//////////////////////////////////////////////////////////////////////
+
+GenClientSocket::GenClientSocket()
+ : GenSocketSSL ()
+{
+ reset ();
+}
+
+
+GenClientSocket::GenClientSocket (int sndSize, int rcvSize)
+ : GenSocketSSL ()
+{
+ reset ();
+
+ sndBuffLen_ = sndSize;
+ rcvBuffLen_ = rcvSize;
+}
+
+
+GenClientSocket::GenClientSocket (bool bEnableSSL, bool bEnableEncryption)
+ : GenSocketSSL (bEnableSSL, bEnableEncryption)
+{
+ reset ();
+}
+
+
+GenClientSocket::GenClientSocket (int sndSize, int rcvSize, bool bEnableSSL, bool bEnableEncryption)
+ : GenSocketSSL (bEnableSSL, bEnableEncryption)
+{
+ reset ();
+
+ sndBuffLen_ = sndSize;
+ rcvBuffLen_ = rcvSize;
+}
+
+
+//////////////////////////////////////////////////////////////////////
+// Primary behaviour methods
+//////////////////////////////////////////////////////////////////////
+
+bool GenClientSocket::connectServer (ubyte4 ipAddr, ubyte2 tcpPort)
+{
+ bool retVal = false;
+
+ struct sockaddr_in remAddr;
+
+ AM_FUNC ("GenClientSocket::connectServer", SOC_LAYER_ID);
+ AM_ENTER ();
+
+ if (isConnected() != SOCKET_CONNECTED)
+ {
+ if (create ()) // Create a socket
+ {
+ srvPort_ = tcpPort;
+ srvAddr_ = ipAddr ;
+
+ memset (&remAddr, 0, sizeof(remAddr));
+
+ remAddr.sin_family = AF_INET ;
+ remAddr.sin_addr.s_addr = srvAddr_ ;
+ remAddr.sin_port = htons(srvPort_);
+
+ if ((connect (getSocket(), (struct sockaddr *)&remAddr, sizeof(remAddr))
+ != SOC_STATUS_ERROR) )
+ {
+ if (isEnableSSL())
+ {
+ if (connectSsl ())
+ {
+ retVal = true;
+ AM_TRACE (("SSL Client is connected to %s\n",
+ getIp (srvAddr_) ));
+ }
+ else
+ {
+ AM_WARNING (("SSL Client is unable to connect to %s\n",
+ getIp (srvAddr_) ));
+ }
+ }
+ else
+ {
+ retVal = true;
+ AM_TRACE (("TCP Client is connected to: %s,%u\n",
+ getIp(srvAddr_), srvPort_ ));
+ }
+ }
+ else
+ {
+ AM_WARNING (("Socket %u error (%s) on connecting to TCP Server %s\n",
+ getSocket(), strerror(ERROR_NUM), getIp(srvAddr_)));
+ }
+
+ if (!retVal)
+ { // release the socket if not connected
+ releaseSocket (true);
+ }
+ }
+ }
+ else
+ {
+ AM_TRACE (("Invalid attempt to reinitialize an active IP connection.\n"));
+ retVal = true;
+ }
+
+ AM_RETURN (retVal);
+}
+
+
+bool GenClientSocket::reconnect()
+{
+ bool retVal = false;
+
+ AM_FUNC ("GenClientSocket::reconnect", SOC_LAYER_ID);
+ AM_ENTER ();
+
+ releaseSocket (true);
+
+ retVal = connectServer (srvAddr_, srvPort_);
+
+ AM_RETURN (retVal);
+}
+
+
+bool GenClientSocket::create ()
+{
+ bool retVal = false;
+ int buffSize = 4 ;
+
+ AM_FUNC ("GenClientSocket::create", SOC_LAYER_ID);
+ AM_ENTER ();
+
+ if (GenSocket::create())
+ {
+ if (rcvBuffLen_ > 0)
+ if (setsockopt (getSocket() , SOL_SOCKET, SO_RCVBUF,
+ (char *)&rcvBuffLen_, buffSize ) == SOC_STATUS_ERROR)
+ {
+ AM_TRACE (("Unable to set SO_RCVBUF socket option\n"));
+ }
+
+ if (rcvBuffLen_ > 0)
+ if (setsockopt (getSocket() , SOL_SOCKET, SO_SNDBUF,
+ (char *)&sndBuffLen_, buffSize ) == SOC_STATUS_ERROR)
+ {
+ AM_TRACE (("Unable to set SO_SNDBUF socket option\n"));
+ }
+
+ if (setLinger_)
+ setsockopt (getSocket() , SOL_SOCKET, SO_LINGER,
+ (char *)&lingerVal_, sizeof(linger) );
+
+ retVal = true;
+ }
+
+ AM_RETURN (retVal);
+}
+
+
+bool GenClientSocket::isContext ()
+{
+ return (pCtx_ != NULL);
+}
+
+
+bool GenClientSocket::initSslContext (LPSTR lpPswd)
+{
+ return (isSupportSSL() ? GenSocketSSL::initSslContext (pCtx_, false, lpPswd)
+ : true );
+}
+
+
+SSL_CTX *GenClientSocket::getContext ()
+{
+ return (pCtx_);
+}
+
+
+void GenClientSocket::printInfo()
+{
+ GenSocketSSL::printInfo();
+
+ if (isConnected())
+ {
+ printf ("Client Socket Info: socket %u is connected to IP (%s,%d).\n",
+ getSocket(), getIp(srvAddr_), srvPort_);
+ }
+ else
+ {
+ printf ("Client Socket Info: socket is not connected to the server.\n");
+ }
+}
+
+
+//////////////////////////////////////////////////////////////////////
+// service methods
+//////////////////////////////////////////////////////////////////////
+
+
+void GenClientSocket::reset()
+{
+ srvPort_ = 0 ;
+ srvAddr_ = 0 ;
+ sndBuffLen_ = -1;
+ rcvBuffLen_ = -1;
+ setLinger_ = false;
+}
+
diff --git a/data/mnet/Common/socket/src/GenSecServerSocket.cpp b/data/mnet/Common/socket/src/GenSecServerSocket.cpp
new file mode 100644
index 0000000..36d468b
--- /dev/null
+++ b/data/mnet/Common/socket/src/GenSecServerSocket.cpp
@@ -0,0 +1,110 @@
+// *******************************************************************
+//
+// (c) Copyright CISCO Systems, Inc 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// Status : Under development
+// File : GenSecServerSocket.cpp
+// Author(s) : Igal Gutkin
+// Create Date : 06/20/00
+// Description : implementation of the GenSecServerSocket (secondary
+// server socket) class
+//
+// *******************************************************************
+
+#include "socket\GenSecServerSocket.h"
+
+//////////////////////////////////////////////////////////////////////
+// Constructors/Destructor
+//////////////////////////////////////////////////////////////////////
+
+/*
+ This class should be used ONLY to create "secondary" socket objects:
+ Those sockets are created when a server socket accepts a connection
+ fromt the client and assigns a new "secondary" socket to handle it.
+ Socket parameter should be a valid socket.
+*/
+
+GenSecServerSocket::GenSecServerSocket (OS_SPECIFIC_SOCKET_HANDLE socket)
+ : GenServerSocket ()
+{
+ reset (socket);
+}
+
+
+GenSecServerSocket::GenSecServerSocket (OS_SPECIFIC_SOCKET_HANDLE socket ,
+ bool enableSSL,
+ bool enableEncryption)
+ : GenServerSocket (enableSSL, enableEncryption)
+{
+ AM_FUNC ("GenSecServerSocket::GenSecServerSocket(SSL)", SOC_LAYER_ID);
+ AM_ENTER();
+
+ reset (socket);
+
+ if (isEnableSSL())
+ {
+ // blocking call to SSL API. USE only for dynamic object creation!!!
+ // 1. All the necessary validity checks are performed inside "acceptSsl"
+ // 2. will release a socket on error !!!
+ if (acceptSsl () == false)
+ {
+ AM_WARNING (("Server is unable to establish SSL connection with the client on %s\n",
+ getIp(getRemoteHostAddress()) ));
+ releaseSocket (true);
+ }
+ }
+
+ if (bMoreInfo_)
+ printInfo ();
+
+ AM_LEAVE();
+}
+
+
+GenSecServerSocket::~GenSecServerSocket()
+{
+ AM_FUNC ("GenSecServerSocket::~GenSecServerSocket", SOC_LAYER_ID);
+ AM_ENTER();
+
+ if (isValid())
+ {
+ AM_TRACE (("Disconnecting socket (%u) from the client IP(%s) \n",
+ getSocket(), getIp(getRemoteHostAddress()) ));
+ }
+
+ AM_LEAVE();
+}
+
+
+void GenSecServerSocket::reset (OS_SPECIFIC_SOCKET_HANDLE socket)
+{
+ AM_FUNC ("GenSecServerSocket::reset", SOC_LAYER_ID);
+ AM_ENTER();
+
+ if (setSocket (socket))
+ {
+ //Optional timer to keep alive the connection
+ char optVal = 1 ;
+ int rcvBuffLen = SOC_RCV_BUFF_LEN,
+ sndBuffLen = SOC_SND_BUFF_LEN;
+ // hard socket close mode
+ struct linger lingerVal = {1,0};
+
+ setsockopt (getSocket(), SOL_SOCKET, SO_KEEPALIVE, &optVal , sizeof(optVal) );
+ setsockopt (getSocket(), SOL_SOCKET, SO_RCVBUF , (char *)&rcvBuffLen, sizeof(rcvBuffLen));
+ setsockopt (getSocket(), SOL_SOCKET, SO_SNDBUF , (char *)&sndBuffLen, sizeof(sndBuffLen));
+ setsockopt (getSocket(), SOL_SOCKET, SO_LINGER , (char *)&lingerVal , sizeof(linger ));
+
+ AM_TRACE (("Open new socket %d to IP (%s)\n",
+ getSocket(), getIp(getRemoteHostAddress()) ));
+ }
+
+ AM_LEAVE();
+}
+
diff --git a/data/mnet/Common/socket/src/GenServerSocket.cpp b/data/mnet/Common/socket/src/GenServerSocket.cpp
new file mode 100644
index 0000000..d44a08e
--- /dev/null
+++ b/data/mnet/Common/socket/src/GenServerSocket.cpp
@@ -0,0 +1,210 @@
+// *******************************************************************
+//
+// (c) Copyright Cisco Systems, Inc 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 2.0
+// Status : Under development
+// File : GenServerSocket.cpp
+// Author(s) : Igal Gutkin
+// Create Date : 06/20/00
+// Description : implementation of the GenServerSocket class.
+//
+// *******************************************************************
+
+#include "socket\GenServerSocket.h"
+
+//////////////////////////////////////////////////////////////////////
+// Static data members
+//////////////////////////////////////////////////////////////////////
+SSL_CTX *GenServerSocket::pCtx_ = NULL;
+
+
+//////////////////////////////////////////////////////////////////////
+// Constructors/Destructor
+//////////////////////////////////////////////////////////////////////
+GenServerSocket::GenServerSocket (bool bEnableSSL, bool bEnableEncryption)
+ : GenSocketSSL (bEnableSSL, bEnableEncryption), port_(0)
+{
+ ;
+}
+
+
+GenServerSocket::~GenServerSocket()
+{
+ AM_FUNC ("GenServerSocket::~GenServerSocket", SOC_LAYER_ID);
+ AM_ENTER();
+
+ if (isValid())
+ {
+ AM_DEBUG (("Closing server socket (%d) on IP (%s,%u)\n",
+ getSocket(), getIp(getLocalHostAddress()), port_));
+ }
+
+ // should clean server SSL context once per host
+
+ AM_LEAVE();
+}
+
+
+///////////////////////////////////////////////////////////
+// primary methods
+///////////////////////////////////////////////////////////
+
+bool GenServerSocket::open (ubyte2 Port)
+{
+ AM_FUNC ("GenServerSocket::open", SOC_LAYER_ID);
+ AM_ENTER ();
+ bool retVal = true;
+
+ // hard socket close mode
+ struct linger lingerVal = {1,0};
+
+ if ((retVal = !isValid()) == false)
+ {
+ AM_WARNING (("GenServerSocket::open - Attempt to reopen socket (%d).\n",
+ getSocket() ));
+ }
+
+ // create socket
+ if (retVal)
+ retVal = create ();
+
+ // bind socket
+ if (retVal)
+ retVal = bind2Address (Port);
+
+ // wait for client connection requests
+ if (retVal)
+ {
+ if (listen (getSocket(), kTCP_LISTEN_BACKLOG) == 0)
+ {
+ int rcvBuffLen = SOC_MRCV_BUFF_LEN,
+ sndBuffLen = SOC_MSND_BUFF_LEN;
+
+ setPort (Port);
+
+ setsockopt (getSocket(), SOL_SOCKET, SO_RCVBUF, (char *)&rcvBuffLen, sizeof(rcvBuffLen));
+ setsockopt (getSocket(), SOL_SOCKET, SO_SNDBUF, (char *)&sndBuffLen, sizeof(sndBuffLen));
+ setsockopt (getSocket(), SOL_SOCKET, SO_LINGER, (char *)&lingerVal , sizeof(linger ));
+
+ if (!isEnableSSL () || initSsl ())
+ { // initiate SSL session on a valid socket
+ AM_TRACE (("Open main server socket (%d) on IP (%s,%u)\n",
+ getSocket(), getIp(getLocalHostAddress()), port_));
+ }
+ else
+ {
+ AM_TRACE (("Unable to initiate SSL session on a server socket\n"));
+ retVal = false;
+ }
+
+#ifdef _AM_DEBUG_
+ printInfo ();
+#endif // _AM_DEBUG_
+ }
+ else
+ {
+ AM_ERROR (("%s: %sd\n", "listen", strerror(ERROR_NUM)));
+ retVal = false;
+ }
+ }
+
+ AM_RETURN (retVal);
+}
+
+
+SSL_CTX *GenServerSocket::getContext ()
+{
+ return (pCtx_);
+}
+
+
+bool GenServerSocket::isContext ()
+{
+ return (pCtx_ != NULL);
+}
+
+
+bool GenServerSocket::initSslContext (LPSTR lpPswd)
+{
+ return (isSupportSSL() ? GenSocketSSL::initSslContext (pCtx_, false, lpPswd)
+ : true );
+}
+
+
+///////////////////////////////////////////////////////////
+// service methods
+///////////////////////////////////////////////////////////
+
+bool GenServerSocket::bind2Address (ubyte2 Port)
+{
+ AM_FUNC("GenServerSocket::bind2Address", SOC_LAYER_ID);
+ AM_ENTER();
+
+ struct sockaddr_in LocalAddr;
+ bool retVal = false;
+ u_long ulHostAddress;
+
+ if (!isValid())
+ AM_RETURN (false);
+
+ /* ask the system to allocate a port and bind to INADDR_ANY */
+ memset(&LocalAddr, 0x00, sizeof(LocalAddr));
+
+ if ((ulHostAddress = getLocalHostAddress()) == 0)
+ AM_RETURN (false);
+
+ /* get system to allocate a port number by binding a host address */
+ LocalAddr.sin_family = AF_INET;
+
+ /* allows connection on any local interface. Replace it with ulHostAddress
+ for multihomed machine compatibility */
+ LocalAddr.sin_addr.s_addr = htonl(INADDR_ANY);
+ LocalAddr.sin_port = htons(Port);
+
+ if (bind (getSocket(), (struct sockaddr *)&LocalAddr, sizeof(LocalAddr)) != 0)
+ {
+ AM_ERROR (("Unable to bind a socket to [%s:%u]\nAnother application using it\n",
+ getIp(getLocalHostAddress()),Port ));
+ }
+ else
+ retVal = true;
+
+ AM_RETURN (retVal);
+}
+
+
+bool GenServerSocket::acceptConnection (OS_SPECIFIC_SOCKET_HANDLE& accSoc)
+{
+ bool retVal = false;
+ char ClientAddr[MAX_PATH];
+ int iAddrLen;
+
+ AM_FUNC("GenServerSocket::acceptConnection", SOC_LAYER_ID);
+ AM_ENTER();
+
+ iAddrLen = sizeof(ClientAddr);
+ memset(&ClientAddr, 0x00, iAddrLen);
+
+ if ((accSoc = accept (getSocket(), (sockaddr FAR *)&ClientAddr, &iAddrLen))
+ != INVALID_SOCKET)
+ {
+ // Perform
+ retVal = true;
+ }
+ else
+ {
+ if (isValid())
+ {
+ AM_WARNING (("GenServerSocket::acceptConnection: %s\n", strerror(ERROR_NUM) ));
+ }
+ }
+
+ AM_RETURN (retVal);
+}
+
diff --git a/data/mnet/Common/socket/src/GenSocket.cpp b/data/mnet/Common/socket/src/GenSocket.cpp
new file mode 100644
index 0000000..33b7920
--- /dev/null
+++ b/data/mnet/Common/socket/src/GenSocket.cpp
@@ -0,0 +1,403 @@
+// *******************************************************************
+//
+// (c) Copyright Cisco Systems, Inc 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 2.0
+// Status : Under development
+// File : GenSocket.cpp
+// Author(s) : Igal Gutkin
+// Create Date : 06/20/00
+// Description : implementation of the GenSocket class.
+//
+// *******************************************************************
+
+#include "socdefs.h"
+#include "socket\GenSocket.h"
+
+
+
+//////////////////////////////////////////////////////////////////////
+// static data members
+//////////////////////////////////////////////////////////////////////
+IpAddrPool_t GenSocket::szIpAddr_;
+
+const struct timeval GenSocket::timeOut_ = {0, 0};
+
+bool GenSocket::bMoreInfo_ =
+#ifdef _AM_DEBUG_
+ true ;
+#else
+ false;
+#endif // _AM_DEBUG_
+
+//////////////////////////////////////////////////////////////////////
+// Construction/Destruction
+//////////////////////////////////////////////////////////////////////
+
+GenSocket::GenSocket()
+ : sock_ (INVALID_SOCKET)
+{
+ ;
+}
+
+
+GenSocket::~GenSocket()
+{
+ cleanup ();
+}
+
+
+
+//////////////////////////////////////////////////////////////////////
+// static methods
+//////////////////////////////////////////////////////////////////////
+
+// Retrives local host IP address
+ubyte4 GenSocket::getLocalHostAddress()
+{
+ ubyte4 ulHostAddr = 0;
+ sbyte szHostName[MAX_PATH];
+
+ AM_FUNC ("GenSocket::getLocalHostAddress", SOC_LAYER_ID);
+ AM_ENTER ();
+
+ // get local host name
+ if (gethostname (szHostName, sizeof(szHostName)) != SOC_STATUS_ERROR)
+ {
+ ulHostAddr = getHostAddress (szHostName);
+ }
+ else
+ {
+ AM_ERROR(("%s: %s\n", "GenSocket::getLocalHostAddress", strerror(ERROR_NUM) ));
+ }
+
+ AM_LEAVE();
+ return (ulHostAddr);
+}
+
+
+// Converts IP from HEX to dotted form
+const LPSTR GenSocket::getIp (ubyte4 ipAddr)
+{
+ memset (szIpAddr_, 0, sizeof szIpAddr_);
+
+ sprintf (szIpAddr_, "%d.%d.%d.%d", IP_BYTES (ipAddr));
+
+ return (szIpAddr_);
+}
+
+
+
+//////////////////////////////////////////////////////////////////////
+// service methods
+//////////////////////////////////////////////////////////////////////
+
+SocketState_t GenSocket::isConnected ()
+{
+ SocketState_t retVal = SOCKET_NOT_CONNECTED;
+ fd_set readFds ;
+ int tempVal ;
+ char tempBuff [32];
+
+ AM_FUNC ("GenSocket::isConnected", SOC_LAYER_ID);
+ AM_ENTER ();
+
+ if (isValid())
+ {
+ FD_ZERO (&readFds);
+ FD_SET (getSocket(), &readFds);
+
+ /*
+ Readability means that queued data is available for reading such
+ that a call to recv, WSARecv, WSARecvFrom, or recvfrom is
+ guaranteed not to block.
+ For connection-oriented sockets, readability can also indicate that
+ a request to close the socket has been received from the peer. If
+ the virtual circuit was closed gracefully, and all data was received,
+ then a recv will return immediately with zero bytes read. If the
+ virtual circuit was reset, then a recv will complete immediately with
+ an error code such as WSAECONNRESET. The presence of out-of-band data
+ will be checked if the socket option SO_OOBINLINE has been enabled.
+
+ 1. select returns -1, no connection
+ +2. select returns 0, socket isn't ready to read - connection is OK
+ 3. select returns > 0, socket is ready to read - check it with recv
+ 1. recv return 0 OR
+ recv return SOCKET_ERROR and errno != WSAEMSGSIZE
+ socket is closed.
+ 2. recv return SOCKET_ERROR and errno == WSAEMSGSIZE OR
+ recv return > 1, there is a data on the socket
+ If the data is unexpected, reset the socket to avoid
+ potential security violation in the child class.
+ */
+ tempVal = select (1, &readFds, NULL, NULL, (struct timeval *)&timeOut_);
+
+
+ switch (tempVal)
+ {
+ case SOC_STATUS_ERROR:
+ retVal = SOCKET_NOT_CONNECTED;
+ break;
+
+ case 0:
+ retVal = SOCKET_CONNECTED;
+ break;
+
+ default:
+ tempVal = recv (getSocket(), tempBuff, sizeof (tempBuff), MSG_PEEK);
+
+ retVal = (!tempVal || (tempVal == SOC_STATUS_ERROR && ERROR_NUM != WSAEMSGSIZE))
+ ? SOCKET_NOT_CONNECTED
+ : SOCKET_CONNECTED_READABLE;
+ break;
+ }
+ }
+
+ // AM_DEBUG (("Socket %u is %s connected.\n", getSocket(), retVal ? "" : " not"));
+
+ AM_LEAVE();
+ return (retVal);
+}
+
+
+bool GenSocket::create()
+{
+ bool retVal = false;
+ OS_SPECIFIC_SOCKET_HANDLE newSocket;
+
+ AM_FUNC ("GenSocket::create", SOC_LAYER_ID);
+ AM_ENTER ();
+
+ if (!isValid ())
+ {
+ if ((newSocket = socket(AF_INET, SOCK_STREAM, 0)) != INVALID_SOCKET)
+ {
+ retVal = setSocket (newSocket);
+ AM_DEBUG (("Open new socket %u\n", getSocket()));
+ }
+ else
+ {
+ AM_ERROR(("GenSocket::create: %s\n", strerror(ERROR_NUM) ));
+ }
+ }
+ else
+ {
+ retVal = true;
+ AM_WARNING (("Attempt to reinitialize socket.\n"));
+ }
+
+ AM_LEAVE();
+ return (retVal);
+}
+
+
+// Returns a host address by the host name
+ubyte4 GenSocket::getHostAddress (LPSTR HostName)
+{
+ ubyte4 ipAddr;
+
+#ifdef _WINDOWS_
+ struct hostent *pHostAddr;
+ pHostAddr = gethostbyname (HostName);
+ ipAddr = (pHostAddr) ? (*((ubyte4 *)pHostAddr->h_addr)) : 0;
+#else
+ ipAddr = hostGetByName (HostName);
+#endif
+
+ return (ipAddr);
+}
+
+
+// Returns remote (peer) host address
+ubyte4 GenSocket::getRemoteHostAddress ()
+{
+ sockaddr_in ClientAddr ;
+ ubyte4 remIpAddr = 0;
+ int iAddrLen = sizeof(ClientAddr);
+
+ AM_FUNC ("GenSocket::getRemoteHostAddress", SOC_LAYER_ID);
+ AM_ENTER ();
+
+ if (isValid ())
+ {
+ if (SOC_STATUS_OK == getpeername (getSocket(), (struct sockaddr *)&ClientAddr, &iAddrLen))
+ remIpAddr = ClientAddr.sin_addr.s_addr;
+ else
+ {
+ remIpAddr = 0;
+
+ AM_TRACE (("getpeername() error %s on socket %d\n",
+ strerror(ERROR_NUM), getSocket() ));
+ }
+ }
+
+ AM_LEAVE();
+ return (remIpAddr);
+}
+
+
+bool GenSocket::setSocket (OS_SPECIFIC_SOCKET_HANDLE Socket)
+{
+ bool retVal = false;
+
+ if (!isValid() && Socket != INVALID_SOCKET && Socket)
+ {
+ sock_ = Socket;
+ retVal = true ;
+ }
+
+ return (retVal);
+}
+
+
+int GenSocket::tcpReceive (sbyte *pBuf, int BufSize)
+{
+ int MsgLen = SOC_STATUS_ERROR;
+
+ AM_FUNC ("GenSocket::tcpReceive", SOC_LAYER_ID);
+ AM_ENTER ();
+
+ if (isValid())
+ {
+ MsgLen = recv (getSocket(), pBuf, BufSize, 0);
+
+ switch (MsgLen)
+ {
+ case 0:
+ AM_TRACE (("GenSocket::tcpReceive: Client closed connection on socket (%d)\n",
+ getSocket()));
+ break;
+
+ case SOC_STATUS_ERROR:
+ AM_TRACE (("GenSocket::tcpReceive: recv error %s on socket (%d)\n",
+ strerror(ERROR_NUM), getSocket() ));
+ break;
+
+ default:
+ AM_DEBUG (("GenSocket::tcpReceive: message received - total length (%d)\n", MsgLen));
+ AM_HEXDUMP ((ubyte *)pBuf, MsgLen);
+ break;
+ }
+ }
+
+ AM_LEAVE();
+ return (MsgLen);
+}
+
+
+int GenSocket::tcpSend (sbyte* pBuff, int inDataLen)
+{
+ AM_FUNC ("GenSocket::tcpSend", SOC_LAYER_ID);
+ AM_ENTER ();
+
+ int retVal = SOCKET_STATUS_FATAL_SOC_ERR;
+ int sentDataLen, socError;
+
+
+ if (isValid ())
+ {
+ sentDataLen = send (getSocket(), pBuff, inDataLen, 0);
+
+ if (sentDataLen != SOC_STATUS_ERROR)
+ {
+ /* Checks that ALL the data is sent.
+ If blocking mode is used all the data is sent.
+ For non-blocking mode it could be less. */
+ retVal = SOCKET_STATUS_OK;
+
+ AM_DEBUG (("tcpSend: Sent %d bytes to socket %d\n", sentDataLen,
+ getSocket()));
+ }
+ else
+ {
+ socError = ERROR_NUM;
+
+ switch (socError)
+ {
+ case WSAENOBUFS:
+ retVal = SOCKET_STATUS_TEMP_SOC_ERR;
+ break;
+
+ case WSAEMSGSIZE:
+ retVal = SOCKET_STATUS_MSG_TOO_LONG;
+ AM_TRACE (("tcpSend: Data length %u exciding maximum allowed by the network.\n",
+ inDataLen));
+ break;
+
+ default:
+ retVal = SOCKET_STATUS_FATAL_SOC_ERR; // fatal error, the connection is broken
+ }
+ }
+ }
+ else
+ {
+ AM_TRACE (("Socket is not connected. Send has failed.\n"));
+ }
+
+ AM_LEAVE();
+ return (retVal);
+}
+
+
+void GenSocket::releaseSocket (bool grace)
+{
+ AM_FUNC ("GenSocket::releaseSocket", SOC_LAYER_ID);
+ AM_ENTER ();
+
+ if (isValid())
+ {
+ if (grace)
+ {
+ // Optional "grace" closing of the socket will wait
+ // till all pending data is sent
+ shutdown (getSocket(), SD_BOTH);
+ }
+
+ AM_DEBUG (("Closing socket %u\n", getSocket()));
+
+ SysCloseSocket (getSocket());
+ // Put optional diagnostics here
+
+ resetSocket ();
+ }
+
+ AM_LEAVE();
+}
+
+
+void GenSocket::cleanup()
+{
+ releaseSocket (true);
+}
+
+
+void GenSocket::printInfo()
+{
+ if (isValid())
+ {
+ sbyte4 rcvBuffLen = 0,
+ sndBuffLen = 0;
+ int buffSize = 4;
+
+ printf ("Socket Info: socket %d.\n", getSocket());
+
+ if (bMoreInfo_)
+ {
+ getsockopt (getSocket(), SOL_SOCKET, SO_RCVBUF, (char *)&rcvBuffLen , &buffSize);
+ getsockopt (getSocket(), SOL_SOCKET, SO_SNDBUF, (char *)&sndBuffLen , &buffSize);
+
+ printf ("Socket receive buffer is %ld Byte, send buffer is %ld Byte\n",
+ rcvBuffLen, sndBuffLen );
+ }
+ }
+ else
+ {
+ printf ("Socket is not initialized\n");
+ }
+}
+
diff --git a/data/mnet/Common/socket/src/GenSocketSSL.cpp b/data/mnet/Common/socket/src/GenSocketSSL.cpp
new file mode 100644
index 0000000..d7da39d
--- /dev/null
+++ b/data/mnet/Common/socket/src/GenSocketSSL.cpp
@@ -0,0 +1,167 @@
+// *******************************************************************
+//
+// (c) Copyright CISCO Systems, Inc 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// File : GenSocketSSL.cpp
+// Author(s) : Igal Gutkin
+// Create Date : 05/17/01
+// Description : platform independent implementation of the GenSocketSSL class.
+//
+// *******************************************************************
+
+#include "socket\GenSocketSSL.h"
+
+
+//////////////////////////////////////////////////////////////////////
+// Static data members
+//////////////////////////////////////////////////////////////////////
+
+bool GenSocketSSL::bInitLib_ = false ;
+SslError_t GenSocketSSL::errorCode_= SSL_NO_ERROR;
+int GenSocketSSL::count_ = 0 ;
+char GenSocketSSL::szPswd_ [SSL_MAX_PASSWORD_LENGTH+2];
+
+LPCSTR GenSocketSSL::cipherSuite_ [] =
+{
+ "eNULL:DES-CBC3-SHA:RC4-SHA",
+ "DES-CBC3-SHA" ,
+ "eNULL"
+};
+
+// Full pathname storege of the SSL files
+char GenSocketSSL::szKeyFile_ [MAX_PATH]; // private key
+char GenSocketSSL::szCertFile_[MAX_PATH]; // certificate
+char GenSocketSSL::szCaFile_ [MAX_PATH]; // trusted CA List
+
+//////////////////////////////////////////////////////////////////////
+// Construction/Destruction
+//////////////////////////////////////////////////////////////////////
+
+
+//////////////////////////////////////////////////////////////////////
+// Primary methods
+//////////////////////////////////////////////////////////////////////
+
+int GenSocketSSL::tcpReceive (sbyte *pBuf, int BufSize)
+{
+ return ((bEnableSsl_ ? readSsl (pBuf, BufSize)
+ : GenSocket::tcpReceive (pBuf, BufSize)));
+}
+
+
+int GenSocketSSL::tcpSend (sbyte *pBuf, int BufSize)
+{
+ return ((bEnableSsl_ ? writeSsl (pBuf, BufSize)
+ : GenSocket::tcpSend (pBuf, BufSize)));
+}
+
+
+void GenSocketSSL::releaseSocket (bool grace)
+{
+ AM_FUNC ("GenSocketSSL::releaseSocket", SOC_LAYER_ID);
+ AM_ENTER ();
+
+ cleanSsl ();
+ // Context is not deleted upon release of the single socket
+ // High level application should take case
+
+ // for SSL socket: forcibly false so that shutdown is not called
+ // GenSocket::releaseSocket ((bEnableSsl_? false : grace));
+ GenSocket::releaseSocket (grace);
+
+ AM_LEAVE ();
+}
+
+
+void GenSocketSSL::printInfo ()
+{
+ GenSocket::printInfo ();
+
+ if (isSSL())
+ {
+ if (bEnableSsl_)
+ {
+ printf ("SSL is enabled on the socket, encryption is %s.\n",
+ (bEnableEncryption_ ? "enabled" : "disabled") );
+
+ if (bMoreInfo_)
+ {
+ printf ("SSL info: Context %p, BIO %p, connection %p\n",
+ getContext(), pSbio_, pSsl_);
+
+ if (pSsl_)
+ printSession ();
+ else
+ printf ("SSL Connection is not initialized.\n");
+ }
+ }
+ else
+ printf ("SSL is disabled on the socket.\n");
+ }
+}
+
+
+void GenSocketSSL::classPrintInfo ()
+{
+ printf ("SSL Socket class info:\n");
+ printf (" SSL is%s supported.\n", (isSSL()) ? "" : " not");
+
+ if (isSSL())
+ {
+ printf (" Total number of active SSL-enabled sockets = %u\n", count_);
+
+ if (errorCode_ != SSL_NO_ERROR)
+ printf ("Last SSL error recorded %d\n", errorCode_);
+
+#ifdef _AM_DEBUG_
+ if (bMoreInfo_)
+ printf (" Password \"%s\"\n",
+ (szPswd_ && strlen(szPswd_) <= SSL_MAX_PASSWORD_LENGTH)
+ ? szPswd_ : "INVALID");
+#endif // _AM_DEBUG_
+ }
+}
+
+
+// Set password only when it's NOT set and a new password is of valid length
+bool GenSocketSSL::setPassword (LPCSTR lpPswd)
+{
+ int length = (lpPswd) ? strlen (lpPswd) : 0;
+ bool retVal = false;
+
+ if (!isPswdSet() && length > 0 && length <= SSL_MAX_PASSWORD_LENGTH)
+ {
+ strcpy (szPswd_, lpPswd);
+ retVal = true;
+ }
+
+ return (retVal);
+}
+
+
+void GenSocketSSL::resetPassword ()
+{
+ memset (szPswd_, 0, sizeof(szPswd_)) ;
+}
+
+
+//////////////////////////////////////////////////////////////////////
+// Service methods
+//////////////////////////////////////////////////////////////////////
+
+
+//////////////////////////////////////////////////////////////////////
+// Shell Interface
+//////////////////////////////////////////////////////////////////////
+
+void SocDataPrint ()
+{
+ GenSocketSSL::classPrintInfo();
+}
+
diff --git a/data/mnet/Common/socket/src/Makefile b/data/mnet/Common/socket/src/Makefile
new file mode 100644
index 0000000..7dab74a
--- /dev/null
+++ b/data/mnet/Common/socket/src/Makefile
@@ -0,0 +1,61 @@
+##########################################################
+#
+# (c) Copyright Cisco 2000
+# All Rights Reserved
+#
+# Use Examples:
+#
+# Case 1:
+# make all VOB=GP10 -
+# Places .out in VOB/bin directory
+#
+# Case 2:
+# make all VOB=GP10 APPDIR=Host\<Application Name>\<Source Directory> -
+# Places .o file(s) in VOB\$(APPDIR)\bin directory.
+#
+# <Application Name> = Name of Application directory
+# <Source Directory> = application sub directory where the calling
+# Makefile resides.
+#
+# Example: make all VOB=GP10 APPDIR=Host\vxTemplate\src
+#
+#
+# Note: This make file must reference a VOB that
+# has a defs.mk in the top level directory.
+#
+##########################################################
+
+# TOP_OF_VOB must be defined before including l3defs.mk
+TOP_OF_VOB = ..\..
+
+# Name of this App's Directory
+THIS_APP_DIR = socket
+
+VOB2DIR = $(TOP_OF_VOB)\..\$(VOB)
+BINDIR = ..\bin
+
+ifeq ($(APPDIR),)
+ MY_OUTPUT = $(VOB2DIR)\bin\soc.out
+else
+ MY_OUTPUT = $(OBJDIR)\soc_com.out
+endif
+
+include $(VOB2DIR)\l3defs.mk
+
+
+all: $(MY_OUTPUT)
+
+$(MY_OUTPUT): $(MODULE_OBJS)
+ $(LD) -r -o $@.tmp $(MODULE_OBJS)
+ $(NM) $@.tmp | munch > _ctdt.c
+ $(CC) -traditional $(CC_ARCH_SPEC) -c _ctdt.c
+ $(LD) -r -o $@ _ctdt.o $@.tmp
+ $(RM)$(subst /,$(DIRCHAR), _ctdt.c _ctdt.o $@.tmp)
+
+cleanall:
+ @for %f in ($(notdir $(MODULE_OBJS))) do \
+ $(RM) ..\bin\%f
+
+ $(RM) $(MY_OUTPUT)
+
+
diff --git a/data/mnet/Common/socket/src_ssl/GenSocketSSL_lib.cpp b/data/mnet/Common/socket/src_ssl/GenSocketSSL_lib.cpp
new file mode 100644
index 0000000..e29a333
--- /dev/null
+++ b/data/mnet/Common/socket/src_ssl/GenSocketSSL_lib.cpp
@@ -0,0 +1,968 @@
+// *******************************************************************
+//
+// (c) Copyright Cisco Systems, Inc 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 2.0
+// Status : Under development
+// File : GenSocketSSL_lib.cpp
+// Author(s) : Igal Gutkin
+// Create Date : 06/20/00
+// Description : Implementation GenSocketSSL class methods
+//
+//
+// *******************************************************************
+
+#include "socket\GenSocketSSL.h"
+#include "CallBackSSL.h"
+
+// maximum depth of the certificates chain to explore
+#define MAX_ALLOWED_CERTIFICATE_DEPTH 10
+
+// the length of the generated RSA key
+#define RSA_KEY_LENGTH 1024
+
+
+// Base names fot the SSL files
+#define SSL_KEY_FILE "key.pem"
+#define SSL_CERT_FILE "cert.pem"
+#define SSL_CA_FILE "ca.pem"
+
+
+//////////////////////////////////////////////////////////////////////
+// Static data
+//////////////////////////////////////////////////////////////////////
+
+#if defined(__VXWORKS__) && defined (__USE_SSL_LOCK__)
+ #include "Os\JCMutex.h"
+ static JCMutex socMutex;
+#endif
+
+
+///////////////////////////////////////////////////////////
+// Constructors\destractor
+///////////////////////////////////////////////////////////
+
+
+///////////////////////////////////////////////////////////
+// SSL library setup functions
+///////////////////////////////////////////////////////////
+void GenSocketSSL::initSslLib ()
+{
+ AM_FUNC ("GenSocketSSL::initSslLib", SOC_LAYER_ID);
+ AM_ENTER ();
+
+ // Global system initialization one-per-application
+ if (isSupportSSL() && !bInitLib_)
+ {
+ char rand_seed [] = "this is to make him think that there is some randomness";
+ //int randStat;
+ LPSTR pRoot = NULL;
+ size_t length = 0 ;
+
+ SSL_library_init ();
+
+ RAND_seed ((unsigned char *)rand_seed, sizeof(rand_seed));
+
+ //randStat = RAND_status ();
+
+ // Construct full pathname for the SSL required files
+ pRoot = getenv ("MNET_BASE");
+
+ if (!pRoot || !*pRoot || (strlen (pRoot) > MAX_PATH - 10))
+ {
+ pRoot = DEF_ROOT_DIR;
+ AM_WARNING (("MNET root directory \"MNET_BASE\" is not specified or too long. Use default value.\n"));
+ }
+
+ if (pRoot)
+ length = strlen(pRoot);
+
+ sprintf (szKeyFile_ , "%s%c%s", pRoot, ((length) ? DIR_DELIMITER : '\0'), SSL_KEY_FILE );
+ sprintf (szCertFile_, "%s%c%s", pRoot, ((length) ? DIR_DELIMITER : '\0'), SSL_CERT_FILE);
+ sprintf (szCaFile_ , "%s%c%s", pRoot, ((length) ? DIR_DELIMITER : '\0'), SSL_CA_FILE );
+
+ bInitLib_ = true;
+ }
+
+ AM_LEAVE();
+}
+
+
+///////////////////////////////////////////////////////////
+// SSL context setup functions (one per server\client)
+///////////////////////////////////////////////////////////
+bool GenSocketSSL::initSslContext (SSL_CTX *& pCtx, bool bServer, LPSTR lpPswd)
+{
+ AM_FUNC ("GenSocketSSL::initSslContext", SOC_LAYER_ID);
+ AM_ENTER ();
+
+ if (pCtx)
+ { // already initialized
+ AM_RETURN (true);
+ }
+
+ if (!isSupportSSL())
+ {
+ AM_RETURN (true);
+ }
+
+ bool retVal = true;
+ int IDContext = 1 ;
+ int iRetVal ;
+ SSL_METHOD *meth ;
+
+ initSslLib ();
+
+#if defined(__VXWORKS__) && defined (__USE_SSL_LOCK__)
+ socMutex.take();
+#endif
+
+ if (lpPswd)
+ setPassword (lpPswd);
+
+ // Check that the password is set and of correct value
+ if (!isPswdSet())
+ {
+ setError (SSL_BAD_PASSWORD);
+ AM_WARNING (("initSslContext: bad or missing SSL password\n"));
+ retVal = false;
+ }
+
+ if (retVal)
+ {
+ //meth = (bServer) ? SSLv3_server_method () : SSLv3_client_method ();
+ meth = SSLv3_method ();
+
+ pCtx = SSL_CTX_new (meth);
+ SSL_CTX_set_verify_depth (pCtx, MAX_ALLOWED_CERTIFICATE_DEPTH);
+
+ /* Load the keys and certificates */
+ if (!(SSL_CTX_use_certificate_file (pCtx, (LPSTR)szCertFile_, SSL_FILETYPE_PEM)))
+ {
+ setError (SSL_BAD_USER_CERT);
+ AM_ERROR (("Unable to read certificate file %s\n", szCertFile_));
+ retVal = false;
+ }
+ }
+
+ if (retVal)
+ {
+ SSL_CTX_set_default_passwd_cb (pCtx,
+#ifdef _RSA_SSL_LIB_
+ (FUNCPTR)
+#endif // _RSA_SSL_LIB_
+ password_cb);
+
+ /* load the private key from the file */
+ if (SSL_CTX_use_PrivateKey_file (pCtx, (LPSTR)szKeyFile_, SSL_FILETYPE_PEM))
+ {
+ /* check that the certificate and private key match */
+ if (!SSL_CTX_check_private_key (pCtx))
+ {
+ setError (SSL_BAD_KEY);
+ AM_ERROR (("Private key does not match the user certificate\n"));
+ retVal = false;
+ }
+ }
+ else
+ {
+ setError (SSL_BAD_KEY);
+ AM_ERROR (("Unable to read SSL key file %s\n", szKeyFile_));
+ retVal = false;
+ }
+ }
+
+ if (retVal)
+ {
+ /* Load the CAs we trust*/
+ if (!(SSL_CTX_load_verify_locations (pCtx, (LPSTR)szCaFile_, 0)))
+ {
+ setError (SSL_BAD_CA_ERROR);
+ AM_ERROR (("Unable to read CA list from %s file\n", szCaFile_));
+ retVal = false;
+ }
+ }
+
+ if (retVal)
+ {
+#ifdef _OPEN_SSL_LIB_
+ // very useful
+ SSL_CTX_set_mode (pCtx, SSL_MODE_AUTO_RETRY);
+#endif _OPEN_SSL_LIB_
+
+ if (!(iRetVal = SSL_CTX_set_cipher_list (pCtx,(LPSTR)cipherSuite_[ALLSUITES])) )
+ {
+ setError (SSL_GENERIC_ERROR);
+ AM_ERROR (("Cipher setting failed for the context\n"));
+ retVal = false;
+ }
+ }
+
+#ifdef __SSL_USE_TEMP_KEY__
+ if (retVal && bServer)
+ {
+ // generate context key
+ pRsa_ = RSA_generate_key (RSA_KEY_LENGTH, RSA_F4, NULL, NULL);
+
+ if (pRsa_)
+ {
+ if (!SSL_CTX_set_tmp_rsa (pCtx, pRsa_))
+ {
+ AM_TRACE (("Unable to set temporary key\n"));
+ retVal = false;
+ }
+ }
+ else
+ {
+ AM_TRACE (("Unable to generate temporary key\n"));
+ retVal = false;
+ }
+
+ if (!retVal)
+ {
+ setError (SSL_GEN_ERROR);
+ retVal = false;
+ }
+ }
+#endif // __SSL_USE_TEMP_KEY__
+
+ if (retVal)
+ {
+ SSL_CTX_set_session_id_context (pCtx, (const unsigned char*)&IDContext,
+ sizeof(IDContext) );
+ retVal = true;
+
+ AM_TRACE (("SSL context is initialized\n"));
+ }
+
+ if (!retVal)
+ cleanSslContext (pCtx);
+
+#if defined(__VXWORKS__) && defined (__USE_SSL_LOCK__)
+ socMutex.give();
+#endif
+
+ AM_RETURN (retVal);
+}
+
+
+void GenSocketSSL::cleanSslContext (SSL_CTX *& pCtx)
+{
+ AM_FUNC ("GenSocketSSL::cleanSslContext", SOC_LAYER_ID);
+ AM_ENTER ();
+
+ if (isSupportSSL())
+ {
+ if (pCtx)
+ {
+#if defined(__VXWORKS__) && defined (__USE_SSL_LOCK__)
+ socMutex.take();
+#endif
+ SSL_CTX_free (pCtx);
+ pCtx = NULL;
+#if defined(__VXWORKS__) && defined (__USE_SSL_LOCK__)
+ socMutex.give();
+#endif
+ }
+
+#ifdef __SSL_USE_TEMP_KEY__
+ if (pRsa_)
+ RSA_free (pRsa_);
+#endif // __SSL_USE_TEMP_KEY__
+ }
+}
+
+
+///////////////////////////////////////////////////////////
+// SSL connection setup functions
+///////////////////////////////////////////////////////////
+
+bool GenSocketSSL::initSsl ()
+{
+ bool retVal = false;
+
+ AM_FUNC ("GenSocketSSL::initSsl", SOC_LAYER_ID);
+ AM_ENTER ();
+
+ if (!isEnableSSL())
+ {
+ retVal = true;
+ }
+ else if (isValid() && isContext())
+ { // Start it for a valid socket under initialized context
+ if (!pSbio_)
+ { // create new socket wrapper
+ AM_DEBUG (("Creating BIO for a socket\n"));
+ pSbio_ = BIO_new_socket (getSocket(), BIO_NOCLOSE);
+ }
+
+ if (pSbio_ && !pSsl_)
+ {
+ AM_DEBUG (("Creating new SSL connection\n"));
+
+#if defined(__VXWORKS__) && defined (__USE_SSL_LOCK__)
+ socMutex.take();
+#endif
+ if ((pSsl_ = SSL_new(getContext())) != NULL)
+ {
+ AM_DEBUG (("Set SSL session\n"));
+
+ if (SSL_set_session (pSsl_, NULL))
+ {
+ SSL_set_bio (pSsl_, pSbio_, pSbio_);
+ ++count_;
+ }
+ else
+ {
+ AM_TRACE (("Unable to set SSL session\n"));
+ cleanSsl ();
+ }
+ }
+
+#if defined(__VXWORKS__) && defined (__USE_SSL_LOCK__)
+ socMutex.give();
+#endif
+
+ }
+
+ if (pSsl_ && pSbio_)
+ retVal = true;
+ else
+ {
+ cleanSsl ();
+ AM_WARNING (("Unable to create SSL session\n"));
+ }
+ }
+ else
+ AM_WARNING (("Unable to start SSL handshake.\n"));
+
+ AM_RETURN (retVal);
+}
+
+
+void GenSocketSSL::cleanSsl ()
+{
+ AM_FUNC ("GenSocketSSL::cleanSsl", SOC_LAYER_ID);
+ AM_ENTER ();
+
+ if (isEnableSSL())
+ {
+ if (pSsl_)
+ {
+ SSL_shutdown (pSsl_);
+ SSL_clear (pSsl_);
+ SSL_free (pSsl_);
+ pSsl_ = NULL;
+ pSbio_ = NULL; // Released by the SSL_free() ???
+ --count_;
+ }
+
+ if (!pSbio_)
+ {
+ BIO_free (pSbio_);
+ pSbio_ = NULL;
+ }
+ }
+}
+
+
+
+///////////////////////////////////////////////////////////
+// SSL connect function
+///////////////////////////////////////////////////////////
+
+// SSL Client
+bool GenSocketSSL::connectSsl ()
+{
+ AM_FUNC ("GenSocketSSL::connectSsl", SOC_LAYER_ID);
+ AM_ENTER ();
+
+ bool retVal = false;
+ int stat ;
+ CipherSuite_t suiteType = (bEnableEncryption_ ? DESCBC3SHA : NOSSL);
+
+ if (isEnableSSL())
+ {
+ if (initSsl ())
+ {
+#ifdef _RSA_SSL_LIB_
+ // RSA lib requires to set state explicitly
+ SSL_set_connect_state (pSsl_);
+#endif // _RSA_SSL_LIB_
+
+ if (!SSL_set_cipher_list(pSsl_,(LPSTR)cipherSuite_[suiteType]) )
+ {
+ AM_ERROR (("Set cipher list for socket connection failed\n"));
+ AM_RETURN (retVal);
+ }
+
+ /* Check peer certificate against the local list here.
+ The chain length is automatically checked by SSL when we
+ set the verify depth in the ctx.
+ Check is stoped when trusted certificate is found or
+ when reachingthe maximum specified chain depth. */
+ SSL_CTX_set_verify (getContext() ,
+ SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT,
+#ifdef _RSA_SSL_LIB_
+ (FUNCPTR)
+#endif // _RSA_SSL_LIB_
+ verify_callback );
+
+ //This is where the handshake really occurs
+ if ((stat = SSL_connect(pSsl_)) > 0)
+ { // normal case
+ // sometimes certificate verificxation error does not prevent TSL session establishment
+ if (verifyCert (SSL_get_verify_result(pSsl_)) == false)
+ {
+ AM_ERROR (("Server [%s] certificate verification has failed\n Cause: %s\n",
+ getIp(getRemoteHostAddress()),
+ getCertError(SSL_get_verify_result(pSsl_)) ));
+ setError (SSL_BAD_PEER_CERT);
+ }
+ else
+ {
+ // connection is extablished, peer's certificate is verified
+ AM_TRACE (("SSL Connection is established to [%s] using ciphering %s\n",
+ getIp(getRemoteHostAddress()) ,
+ SSL_CIPHER_get_name(SSL_get_current_cipher(pSsl_)) ));
+ retVal = true;
+ }
+ }
+ else if (stat == 0)
+ {
+ AM_ERROR (("Server on [%s] closed connection on the socket %d\n",
+ getIp(getRemoteHostAddress()), getSocket() ));
+ }
+ else
+ { // (stat < 0)
+ // connection error. Can't continue anyway
+ switch (SSL_get_error(pSsl_,stat))
+ {
+ case SSL_ERROR_NONE:
+ AM_TRACE (("SSL connection is established on socket %u\n", getSocket() ));
+ retVal = true;
+ break;
+
+ case SSL_ERROR_ZERO_RETURN:
+ // peer shutdown connection
+ AM_ERROR (("Server on [%s] closed connection on the socket %d\n",
+ getIp(getRemoteHostAddress()), getSocket() ));
+ break;
+
+ case SSL_ERROR_WANT_READ:
+ AM_ERROR (("connectSsl: Data needs to be read, problem due to renegotiation\n"));
+ break;
+
+ case SSL_ERROR_WANT_WRITE:
+ AM_ERROR (("connectSsl: Data needs to be written, problem due to renegotiation\n"));
+ break;
+
+ case SSL_ERROR_WANT_X509_LOOKUP:
+ AM_TRACE (("connectSsl: The operation did not complete because an \
+application callback set by SSL_CTX_set_client_cert_cb() \
+has askedto be called again. The TLS/SSL I/O function \
+should becalled again later\n"));
+ break;
+
+ case SSL_ERROR_SYSCALL:
+ AM_TRACE (("SSL system call error on SSL_connect\n"));
+ break;
+
+ case SSL_ERROR_SSL:
+ // General error
+ // check if the peer's certificate is OK
+ // print verification error
+ if (verifyCert(SSL_get_verify_result(pSsl_)) == false)
+ {
+ AM_ERROR (("Server [%s] certificate verification has failed\n Cause: %s\n",
+ getIp(getRemoteHostAddress()),
+ getCertError(SSL_get_verify_result(pSsl_)) ));
+ setError (SSL_BAD_PEER_CERT);
+ }
+ else
+ {
+ AM_TRACE (("General SSL error during on SSL connect\n"));
+ }
+ break;
+
+ default:
+ AM_TRACE (("Unspecified SSL connect error %d\n", stat));
+ break;
+ }
+ }
+ }
+ }
+ else
+ { // SSL is disabled or not supported
+ retVal = true;
+ }
+
+ AM_RETURN (retVal);
+}
+
+
+// SSL server
+bool GenSocketSSL::acceptSsl ()
+{
+ int stat;
+ bool retVal = false;
+
+ AM_FUNC ("GenSocketSSL::acceptSsl", SOC_LAYER_ID);
+ AM_ENTER ();
+
+ if (!isEnableSSL())
+ {
+ retVal = true;
+ }
+ else if (initSsl ())
+ {
+#ifdef _RSA_SSL_LIB_
+ // SSL_set_accept_state (pSsl_);
+#endif // _RSA_SSL_LIB_
+
+ // accept state is the default one
+
+ /* Check peer certificate against the local list here.
+ The chain length is automatically checked by SSL when we
+ set the verify depth in the ctx.
+ Check is stoped when trusted certificate is found or
+ when reachingthe maximum specified chain depth. */
+ SSL_CTX_set_verify (getContext(), SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT,
+#ifdef _RSA_SSL_LIB_
+ (FUNCPTR)
+#endif // _RSA_SSL_LIB_
+ verify_callback);
+
+ //This is where the handshake really occurs
+ if ((stat = SSL_accept(pSsl_)) > 0)
+ {
+ if (verifyCert(SSL_get_verify_result(pSsl_)) == false)
+ {
+ AM_ERROR (("Client [%s] certificate verification has failed.\nCause: %s\n",
+ getIp (getRemoteHostAddress()),
+ getCertError (SSL_get_verify_result(pSsl_)) ));
+ setError (SSL_BAD_PEER_CERT);
+ }
+ else
+ {
+ // connection is extablished, peer's certificate is OK
+ AM_TRACE (("SSL Connection is accepted from [%s] using ciphering %s\n",
+ getIp(getRemoteHostAddress()) ,
+ SSL_CIPHER_get_name(SSL_get_current_cipher(pSsl_)) ));
+ retVal = true;
+ }
+ }
+ else if (stat == 0)
+ {
+ AM_ERROR (("Client on [%s] closed connection on the socket %d\n",
+ getIp(getRemoteHostAddress()), getSocket() ));
+ }
+ else if (stat < 0)
+ {
+ switch (SSL_get_error (pSsl_, stat) )
+ {
+ case SSL_ERROR_NONE:
+ AM_TRACE (("SSL connection is accepted on socket %u\n", getSocket() ));
+ retVal = true;
+ break;
+
+ case SSL_ERROR_ZERO_RETURN:
+ AM_ERROR (("Client on [%s] closed connection on the socket %d\n",
+ getIp(getRemoteHostAddress()), getSocket() ));
+ break;
+ break;
+
+ case SSL_ERROR_WANT_READ:
+ AM_ERROR (("acceptSsl: Data needs to be read, problem due to renegotiation\n"));
+ break;
+
+ case SSL_ERROR_WANT_WRITE:
+ AM_ERROR (("acceptSsl: Data needs to be written, problem due to renegotiation\n"));
+ break;
+
+ case SSL_ERROR_WANT_X509_LOOKUP:
+ AM_ERROR (("acceptSsl: The operation did not complete because an \
+application callback set by SSL_CTX_set_client_cert_cb() \
+has asked to be called again. The TLS/SSL I/O function \
+should be called again later\n"));
+ break;
+
+ case SSL_ERROR_SYSCALL:
+ AM_ERROR (("SSL system call error in SSL_accept\n"));
+ break;
+
+ case SSL_ERROR_SSL:
+ // General error
+ // check if the peer's certificate is OK
+ // print verification error
+ if (verifyCert(SSL_get_verify_result(pSsl_)) == false)
+ {
+ AM_ERROR (("Client [%s] certificate verification has failed.\nCause: %s\n",
+ getIp (getRemoteHostAddress()) ,
+ getCertError (SSL_get_verify_result(pSsl_)) ));
+ setError (SSL_BAD_PEER_CERT );
+ }
+ else
+ AM_ERROR (("General SSL error on SSL accept connection\n"));
+ break;
+
+ default:
+ AM_ERROR (("Unspecified SSL accept error %d\n", stat));
+ }
+ }
+ }
+
+ AM_RETURN (retVal);
+}
+
+
+///////////////////////////////////////////////////////////
+// SSL read\write functions
+///////////////////////////////////////////////////////////
+
+int GenSocketSSL::readSsl (sbyte *pBuf, int BufSize)
+{
+ AM_FUNC ("GenSocketSSL::readSsl", SOC_LAYER_ID);
+ AM_ENTER ();
+
+ int msgLen = SOC_STATUS_ERROR;
+ int errCode;
+
+ if (isInitSSL ())
+ {
+ msgLen = SSL_read (pSsl_, pBuf, BufSize);
+
+ if (msgLen <= 0 && (errCode = SSL_get_error(pSsl_,msgLen)) != SSL_ERROR_NONE )
+ {
+ msgLen = SOC_STATUS_ERROR;
+
+ switch (errCode)
+ {
+ case SSL_ERROR_NONE:
+ AM_DEBUG (("readSsl: message received - total length (%d)\n", msgLen));
+ msgLen = SOC_STATUS_OK;
+ break;
+
+ case SSL_ERROR_ZERO_RETURN:
+ AM_TRACE (("readSsl: Client closed connection on socket (%d)\n",
+ getSocket() ));
+ break;
+
+ case SSL_ERROR_SYSCALL:
+ AM_ERROR (("readSsl: Problem in SSL_read,system call error\n"));
+ break;
+
+ case SSL_ERROR_SSL:
+ AM_ERROR (("readSsl: general SSL library error\n"));
+ break;
+
+ case SSL_ERROR_WANT_X509_LOOKUP:
+ AM_ERROR(("readSsl: The operation did not complete because an \
+application callback set by SSL_CTX_set_client_cert_cb() \
+has asked to be called again. The TLS/SSL I/O function \
+should be called again later\n"));
+ break;
+
+ case SSL_ERROR_WANT_READ:
+ AM_ERROR(("readSsl: Data needs to be read, problem due to renegotiation\n"));
+ break;
+
+ default:
+ AM_ERROR (("readSsl: recv error %d on socket (%d)\n",
+ errCode, getSocket() ));
+ }
+ }
+ else
+ {
+ AM_DEBUG (("readSsl: received message [length=%d] on the socket %u\n",
+ msgLen, getSocket() ));
+ AM_HEXDUMP ((ubyte *)pBuf, msgLen);
+ }
+ }
+ else
+ AM_ERROR (("Attempt to read read from uninitialised SSL socket %u\n",
+ getSocket() ));
+
+ AM_RETURN (msgLen);
+}
+
+
+int GenSocketSSL::writeSsl (sbyte *pBuf, int BufSize)
+{
+ AM_FUNC ("GenSocketSSL::writeSsl", SOC_LAYER_ID);
+ AM_ENTER ();
+
+ int msgLen = SOCKET_STATUS_FATAL_SOC_ERR;
+ int errCode;
+
+ if (isInitSSL ())
+ {
+ msgLen = SSL_write (pSsl_, pBuf, BufSize);
+
+ if (msgLen <= 0 && (errCode = SSL_get_error(pSsl_,msgLen)) != SSL_ERROR_NONE)
+ {
+ msgLen = SOCKET_STATUS_FATAL_SOC_ERR;
+
+ switch (errCode)
+ {
+ case SSL_ERROR_NONE:
+ AM_DEBUG (("writeSsl: Sent %d bytes to socket %d\n", msgLen, getSocket() ));
+ msgLen = SOCKET_STATUS_OK;
+ break;
+
+ case SSL_ERROR_ZERO_RETURN:
+ AM_ERROR (("writeSsl: Peer closed connection on socket (%d)\n",
+ getSocket()));
+ break;
+
+ case SSL_ERROR_SYSCALL:
+ AM_ERROR (("writeSsl: System call error\n"));
+ ERR_print_errors_fp (stdout);
+ break;
+
+ case SSL_ERROR_SSL:
+ AM_ERROR (("writeSsl: general SSL library error\n"));
+ break;
+
+ case SSL_ERROR_WANT_X509_LOOKUP:
+ AM_ERROR (("writeSsl: The operation did not complete because an \
+application callback set by SSL_CTX_set_client_cert_cb() \
+has asked to be called again. The TLS/SSL I/O function \
+should be called again later\n"));
+ break;
+
+ case SSL_ERROR_WANT_WRITE:
+ AM_ERROR(("writeSsl: Data needs to be written, problem due to renegotiation\n"));
+ break;
+
+ default:
+ AM_TRACE (("writeSsl: error %d on socket (%d)\n",
+ errCode, getSocket() ));
+ break;
+ }
+ }
+ else
+ {
+ AM_DEBUG (("writeSsl: Sent %d bytes to socket %u\n", msgLen, getSocket() ));
+ msgLen = SOCKET_STATUS_OK;
+ }
+ }
+ else
+ AM_ERROR (("Attempt to read read from uninitialised SSL socket %u\n",
+ getSocket() ));
+
+ if (msgLen == SOCKET_STATUS_FATAL_SOC_ERR)
+ releaseSocket(true);
+
+ AM_RETURN (msgLen);
+}
+
+
+// Define here certificate verification policy
+bool GenSocketSSL::verifyCert (long code)
+{
+ bool retVal = false;
+
+ switch (code)
+ {
+ // no error
+ case X509_V_OK :
+ // minor verification errors
+ case X509_V_ERR_CERT_NOT_YET_VALID :
+ case X509_V_ERR_CERT_HAS_EXPIRED :
+ case X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD:
+ case X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD :
+ case X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD:
+ case X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD:
+ retVal = true;
+ break;
+
+#ifdef _OPEN_SSL_LIB_
+
+ // minor verification errors
+ case X509_V_ERR_INVALID_PURPOSE :
+ case X509_V_ERR_SUBJECT_ISSUER_MISMATCH :
+ case X509_V_ERR_AKID_SKID_MISMATCH :
+ case X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH:
+ case X509_V_ERR_KEYUSAGE_NO_CERTSIGN :
+ retVal = true;
+ break;
+
+ // The following errors considered as critical and will cause a link termination
+ case X509_V_ERR_PATH_LENGTH_EXCEEDED :
+ case X509_V_ERR_INVALID_CA :
+ case X509_V_ERR_CERT_UNTRUSTED :
+ break;
+
+#endif // _OPEN_SSL_LIB_
+
+ case X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT :
+ case X509_V_ERR_CERT_REVOKED :
+ case X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE :
+ case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT :
+ case X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN :
+ case X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE :
+ case X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY:
+ case X509_V_ERR_CERT_SIGNATURE_FAILURE :
+ case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY :
+ default :
+ break;
+ }
+
+ return (retVal);
+}
+
+// Define here certificate verification policy
+LPSTR GenSocketSSL::getCertError (long code)
+{
+
+ static LPSTR verificationErrorList [] =
+ {
+ "Certificate is OK" , // no error
+ "Minor certificate verification error" , // OPENSSL specific errors
+ "Unspecified verification error" ,
+
+ "Certificate is not valid yet" ,
+ "Certificate has expired" ,
+ "Certificate \"Not before\" field is not valid",
+ "Certificate \"Not After\" field is not valid" ,
+ "Certificate Last CRL update field is wrong" ,
+ "Certificate CRL next update field is wrong" ,
+ "Certificate the basic Constraints pathlength parameter has been exceeded",
+ "Certificate purpose invalid" ,
+ "The certificate is untrusted" ,
+ "Invalid CA detected" ,
+ "Certificate is self signed and cannot be found in the list of trusted certificates",
+ "The certificate has been revoked" ,
+ "No signatures could be verified because the chain contains only one certificate\n\
+and it is not self signed" ,
+ "Certificate: Unable to get issuer certificate",
+ "The certificate chain could be built up using the untrusted\n \
+certificates but the root could not be found locally",
+ "Unable to decrypt certificate\'s signature ",
+ "Unable to decode issuer public key ",
+ "Invalid signature found ",
+ "Unable to get issuer certificate locally ",
+ };
+
+ LPSTR retVal = NULL;
+
+ switch (code)
+ {
+ case X509_V_OK:
+ // no error
+ retVal = verificationErrorList[CertNoError];
+ break;
+
+ case X509_V_ERR_CERT_NOT_YET_VALID:
+ retVal = verificationErrorList[CertNotYetValid];
+ break;
+
+ case X509_V_ERR_CERT_HAS_EXPIRED:
+ retVal = verificationErrorList[CertExpired];
+ break;
+
+ case X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD:
+ retVal = verificationErrorList[CertNotBeforeError];
+ break;
+
+ case X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD:
+ retVal = verificationErrorList[CertNotAfterError];
+ break;
+
+ case X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD:
+ retVal = verificationErrorList[CertCrlLastUpdateError];
+ break;
+
+ case X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD:
+ retVal = verificationErrorList[CertCrlNextUpdateError];
+ break;
+
+#ifdef _OPEN_SSL_LIB_
+
+ case X509_V_ERR_PATH_LENGTH_EXCEEDED:
+ retVal = verificationErrorList[CertPathLengthExceed];
+ break;
+
+ case X509_V_ERR_INVALID_PURPOSE:
+ retVal = verificationErrorList[CertInvalidPurpose];
+ break;
+
+ case X509_V_ERR_CERT_UNTRUSTED:
+ retVal = verificationErrorList[CertUntrusted];
+ break;
+
+ case X509_V_ERR_SUBJECT_ISSUER_MISMATCH :
+ case X509_V_ERR_AKID_SKID_MISMATCH :
+ case X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH:
+ case X509_V_ERR_KEYUSAGE_NO_CERTSIGN :
+ // minor verification errors
+ retVal = verificationErrorList[CertMiscError];
+ break;
+
+// The following errors considered as critical and will cause a link termination
+
+ case X509_V_ERR_INVALID_CA:
+ retVal = verificationErrorList[CertInvalidCA];
+ break;
+
+#endif // _OPEN_SSL_LIB_
+
+ case X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT:
+ retVal = verificationErrorList[CertZeroSelfSigned];
+ break;
+
+ case X509_V_ERR_CERT_REVOKED:
+ retVal = verificationErrorList[CertRevoked];
+ break;
+
+ case X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE:
+ retVal = verificationErrorList[CertOneNotSelfSigned];
+ break;
+
+ case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT:
+ retVal = verificationErrorList[CertNoIssuer];
+ break;
+
+ case X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN:
+ retVal = verificationErrorList[CertUntrustedNoRoot];
+ break;
+
+ case X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE:
+ retVal = verificationErrorList[CertUnableDecryptSignature];
+ break;
+
+ case X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY:
+ retVal = verificationErrorList[CertUnableDecodeIssuerKey];
+ break;
+
+ case X509_V_ERR_CERT_SIGNATURE_FAILURE:
+ retVal = verificationErrorList[CertInvalidSignature];
+ break;
+
+ case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY:
+ retVal = verificationErrorList[CertNoIssuerCert];
+ break;
+
+ default:
+ retVal = verificationErrorList[CertUnspecifiedError];
+ break;
+ }
+
+ return (retVal);
+}
+
+
+void GenSocketSSL::printSession ()
+{
+ SSL_SESSION *pSession = SSL_get_session(pSsl_);
+
+ if (pSession)
+ SSL_SESSION_print_fp (stderr, pSession);
+}
+
diff --git a/data/mnet/Common/socket/src_ssl/Makefile b/data/mnet/Common/socket/src_ssl/Makefile
new file mode 100644
index 0000000..f1122b9
--- /dev/null
+++ b/data/mnet/Common/socket/src_ssl/Makefile
@@ -0,0 +1,61 @@
+##########################################################
+#
+# (c) Copyright Cisco 2000
+# All Rights Reserved
+#
+# Use Examples:
+#
+# Case 1:
+# make all VOB=GP10 -
+# Places .out in VOB/bin directory
+#
+# Case 2:
+# make all VOB=GP10 APPDIR=Host\<Application Name>\<Source Directory> -
+# Places .o file(s) in VOB\$(APPDIR)\bin directory.
+#
+# <Application Name> = Name of Application directory
+# <Source Directory> = application sub directory where the calling
+# Makefile resides.
+#
+# Example: make all VOB=GP10 APPDIR=Host\vxTemplate\src
+#
+#
+# Note: This make file must reference a VOB that
+# has a defs.mk in the top level directory.
+#
+##########################################################
+
+# TOP_OF_VOB must be defined before including l3defs.mk
+TOP_OF_VOB = ..\..
+
+# Name of this App's Directory
+THIS_APP_DIR = socket
+
+VOB2DIR = $(TOP_OF_VOB)\..\$(VOB)
+BINDIR = ..\bin
+
+ifeq ($(APPDIR),)
+ MY_OUTPUT = $(VOB2DIR)\bin\soc_ssl_lib.out
+else
+ MY_OUTPUT = $(OBJDIR)\soc_ssl_cmn.out
+endif
+
+include $(VOB2DIR)\l3defs.mk
+
+
+all: $(MY_OUTPUT)
+
+$(MY_OUTPUT): $(MODULE_OBJS)
+ $(LD) -r -o $@.tmp $(MODULE_OBJS)
+ $(NM) $@.tmp | munch > _ctdt.c
+ $(CC) -traditional $(CC_ARCH_SPEC) -c _ctdt.c
+ $(LD) -r -o $@ _ctdt.o $@.tmp
+ $(RM)$(subst /,$(DIRCHAR), _ctdt.c _ctdt.o $@.tmp)
+
+cleanall:
+ @for %f in ($(notdir $(MODULE_OBJS))) do \
+ $(RM) ..\bin\%f
+
+ $(RM) $(MY_OUTPUT)
+
+
diff --git a/data/mnet/Common/socket/src_ssl/ssl_intf.cpp b/data/mnet/Common/socket/src_ssl/ssl_intf.cpp
new file mode 100644
index 0000000..f969a8e
--- /dev/null
+++ b/data/mnet/Common/socket/src_ssl/ssl_intf.cpp
@@ -0,0 +1,235 @@
+// *******************************************************************
+//
+// (c) Copyright Cisco Systems, Inc 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 2.0
+// Status : Under development
+// File : ssl_intf.cpp
+// Author(s) : Igal Gutkin
+// Create Date : 06/20/00
+// Description : Implementation of the service functions required by
+// SSL library
+//
+// *******************************************************************
+
+#include "socket\GenSocketSSL.h"
+#include "CallBackSSL.h"
+
+
+// Global variables
+// random key data
+#define PASSWORD_KEY {0xA5,0x30,0x1F,0x3C,0x8D,0x1B,0x39,0xE5}
+
+////////////////////////////////////////////////////////////////
+// Open SSL support functions
+////////////////////////////////////////////////////////////////
+
+#ifdef _OPEN_SSL_LIB_
+// OpenSSL library does not have it
+int isSSL ()
+{
+ return (1);
+}
+#endif // _OPEN_SSL_LIB_
+
+
+// callback functions used by SSL library
+// note OpenSSL allows passing a void user data pointer,and can do a per session check
+// may need to modify RSA source to do that
+// We will use one password for all the sockets on the host
+int password_cb (char *buf, int bufSize, int rwflag
+#ifdef _OPEN_SSL_LIB_
+ , void *pData
+#endif // _OPEN_SSL_LIB_
+ )
+{
+ AM_FUNC ("password_cb", SOC_LAYER_ID);
+ AM_ENTER ();
+
+ int length = 0;
+ LPCSTR pPasswd = GenSocketSSL::getPassword();
+
+ if (pPasswd && (length = strlen(pPasswd)) <= bufSize)
+ strcpy (buf, pPasswd);
+
+ AM_RETURN (length);
+}
+
+
+int verify_callback (int ok, X509_STORE_CTX *pStoreCtx)
+{
+ AM_FUNC ("verify_callback", SOC_LAYER_ID);
+ AM_ENTER ();
+
+ char *s, buf[256] = "";
+
+ // read subject line from the certificate
+ s = X509_NAME_oneline (X509_get_subject_name(pStoreCtx->current_cert), buf, 256);
+
+ if (s == NULL)
+ {
+ if (ok)
+ {
+ AM_TRACE (("Certificate depth=%d %s\n",pStoreCtx->error_depth, buf));
+ }
+ else
+ {
+ AM_WARNING (("Certificate depth=%d error=%d %s\n",
+ pStoreCtx->error_depth, pStoreCtx->error,buf));
+ }
+ }
+
+ if (!ok)
+ { // Certificate got a problem, parse it and decide whether to continue
+ ok = GenSocketSSL::verifyCert (pStoreCtx->error);
+ }
+
+ AM_RETURN (ok);
+}
+
+
+// Encrypt and save password to the specified file
+bool encryptPassword (const char *pwd, const char *filename)
+{
+ int stat ;
+ unsigned idx ;
+ const unsigned blockNum = SSL_MAX_PASSWORD_LENGTH/LENGTH_OF_CBLOCK;
+ des_cblock out [blockNum];
+ des_key_schedule ks ;
+ FILE *fd = NULL;
+ bool retVal = false;
+
+ AM_FUNC ("SocLib: encryptPassword", SOC_LAYER_ID);
+ AM_ENTER ();
+
+ if (isSSL ())
+ {
+ const unsigned char key_data [] = PASSWORD_KEY;
+
+ // Always encode SSL_MAX_PASSWORD_LENGTH bytes
+ if (strlen (pwd) > SSL_MAX_PASSWORD_LENGTH)
+ {
+ AM_WARNING (("SocLib: Provided password is longer than allowed.\n Use first %u characters\n",
+ SSL_MAX_PASSWORD_LENGTH ));
+ }
+
+ if (fd = fopen (filename, "wb"))
+ {
+ memset (out, 0, sizeof(out));
+
+ for (idx = 0; idx < blockNum; idx++)
+ {
+ if ((stat = des_key_sched ((C_Block *)(key_data),ks)) != 0)
+ {
+ AM_TRACE (("SocLib: Key error %d\n", stat));
+ AM_RETURN (retVal);
+ }
+
+ des_ecb_encrypt ((C_Block *)(pwd+idx*LENGTH_OF_CBLOCK), // source
+ (C_Block *)out[idx] , // dest
+ ks, DES_ENCRYPT );
+ }
+
+ unsigned temp = 0;
+
+ if ((temp = fwrite (out, SSL_MAX_PASSWORD_LENGTH, 1, fd)) == 1)
+ {
+ retVal = true;
+ }
+ else
+ {
+ AM_TRACE (("SocLib: Unable to save password file %s\n", filename));
+ }
+
+ fclose (fd);
+ }
+ else
+ {
+ AM_TRACE (("SocLib: Unable to open password file %s\n", filename));
+ }
+ }
+
+ AM_RETURN (retVal);
+}
+
+
+bool decryptPassword (char *pwdout, const char *filename)
+{
+ int stat ,
+ idx ;
+ const unsigned blockNum= SSL_MAX_PASSWORD_LENGTH/LENGTH_OF_CBLOCK;
+ des_cblock in [blockNum];
+ des_key_schedule ks ;
+ FILE *fd = NULL ;
+ bool retVal = false;
+ char passwd [SSL_MAX_PASSWORD_LENGTH+2];
+
+ AM_FUNC ("decryptPassword", SOC_LAYER_ID);
+ AM_ENTER ();
+
+ if (isSSL ())
+ {
+ const unsigned char key_data [] = PASSWORD_KEY;
+
+ if (fd = fopen (filename, "rb"))
+ {
+ memset (passwd, 0, (SSL_MAX_PASSWORD_LENGTH+2));
+
+ // Always encode SSL_MAX_PASSWORD_LENGTH bytes
+ if (fread (in, SSL_MAX_PASSWORD_LENGTH, 1, fd) == 1)
+ {
+ for (idx = 0; idx < blockNum; idx++)
+ { // decrypt it
+ if ((stat = des_key_sched((C_Block *)(key_data), ks)) != 0)
+ {
+ AM_TRACE (("SocLib: Key error %d\n", stat));
+ AM_RETURN (retVal);
+ }
+
+ des_ecb_encrypt ((des_cblock *)in[idx], // source
+ (des_cblock *)(passwd + idx * LENGTH_OF_CBLOCK), // dest
+ ks, DES_DECRYPT );
+ }
+
+ // verify decrypted password
+ if ((stat = strlen (passwd)) != 0 && stat <= SSL_MAX_PASSWORD_LENGTH)
+ {
+ for (idx = 0; idx < stat; idx++)
+ {
+ if (!isprint(passwd[idx]))
+ break;
+ }
+
+ if (idx == stat)
+ { // Password is OK
+ strcpy (pwdout, passwd);
+ retVal = true;
+ }
+ }
+
+ fclose (fd);
+
+ if (!retVal)
+ {
+ AM_TRACE (("Password verification failed\n"));
+ }
+ }
+ else
+ {
+ AM_TRACE (("Invalid password file\n"));
+ }
+ }
+ else
+ {
+ AM_TRACE (("Unable to open password file %s.\n", filename));
+ }
+ }
+
+ AM_RETURN (retVal);
+}
+
diff --git a/data/mnet/Common/socket/src_stub/GenSocketSSL_stub.cpp b/data/mnet/Common/socket/src_stub/GenSocketSSL_stub.cpp
new file mode 100644
index 0000000..4c1c819
--- /dev/null
+++ b/data/mnet/Common/socket/src_stub/GenSocketSSL_stub.cpp
@@ -0,0 +1,95 @@
+// *******************************************************************
+//
+// (c) Copyright CISCO Systems, Inc 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// File : GenSocketSSL.cpp
+// Author(s) : Igal Gutkin
+// Create Date : 05/17/01
+// Description : stub implementation of the GenSocketSSL class methods
+//
+// *******************************************************************
+
+#include "socket\GenSocketSSL.h"
+
+//////////////////////////////////////////////////////////////////////
+// function stubs
+//////////////////////////////////////////////////////////////////////
+
+
+bool GenSocketSSL::initSslContext (SSL_CTX *& pCtx, bool bServer, LPSTR lpPswd)
+{
+ return (false);
+}
+
+
+void GenSocketSSL::cleanSslContext (SSL_CTX *& pCtx)
+{
+ return ;
+}
+
+
+bool GenSocketSSL::initSsl ()
+{
+ return (false);
+}
+
+void GenSocketSSL::cleanSsl ()
+{
+ pSsl_ = NULL;
+ pSbio_ = NULL;
+}
+
+
+bool GenSocketSSL::acceptSsl ()
+{
+ return (false);
+}
+
+
+bool GenSocketSSL::connectSsl ()
+{
+ return (false);
+}
+
+
+void GenSocketSSL::initSslLib ()
+{
+ return ;
+}
+
+
+int GenSocketSSL::readSsl (sbyte *pBuf, int BufSize)
+{
+ return (SOC_STATUS_ERROR);
+}
+
+
+int GenSocketSSL::writeSsl (sbyte *pBuf, int BufSize)
+{
+ return (SOC_STATUS_ERROR);
+}
+
+
+void GenSocketSSL::printSession ()
+{
+ ;
+}
+
+
+bool encryptPassword (const char *pwd, const char *filename)
+{
+ return (false);
+}
+
+
+bool decryptPassword (char *pwdout, const char *filename)
+{
+ return (false);
+}
+
diff --git a/data/mnet/Common/socket/src_stub/Makefile b/data/mnet/Common/socket/src_stub/Makefile
new file mode 100644
index 0000000..038097c
--- /dev/null
+++ b/data/mnet/Common/socket/src_stub/Makefile
@@ -0,0 +1,61 @@
+##########################################################
+#
+# (c) Copyright Cisco 2000
+# All Rights Reserved
+#
+# Use Examples:
+#
+# Case 1:
+# make all VOB=GP10 -
+# Places .out in VOB/bin directory
+#
+# Case 2:
+# make all VOB=GP10 APPDIR=Host\<Application Name>\<Source Directory> -
+# Places .o file(s) in VOB\$(APPDIR)\bin directory.
+#
+# <Application Name> = Name of Application directory
+# <Source Directory> = application sub directory where the calling
+# Makefile resides.
+#
+# Example: make all VOB=GP10 APPDIR=Host\vxTemplate\src
+#
+#
+# Note: This make file must reference a VOB that
+# has a defs.mk in the top level directory.
+#
+##########################################################
+
+# TOP_OF_VOB must be defined before including l3defs.mk
+TOP_OF_VOB = ..\..
+
+# Name of this App's Directory
+THIS_APP_DIR = socket
+
+VOB2DIR = $(TOP_OF_VOB)\..\$(VOB)
+BINDIR = ..\bin
+
+ifeq ($(APPDIR),)
+ MY_OUTPUT = $(VOB2DIR)\bin\soc_ssl.out
+else
+ MY_OUTPUT = $(OBJDIR)\soc_ssl_cmn.out
+endif
+
+include $(VOB2DIR)\l3defs.mk
+
+
+all: $(MY_OUTPUT)
+
+$(MY_OUTPUT): $(MODULE_OBJS)
+ $(LD) -r -o $@.tmp $(MODULE_OBJS)
+ $(NM) $@.tmp | munch > _ctdt.c
+ $(CC) -traditional $(CC_ARCH_SPEC) -c _ctdt.c
+ $(LD) -r -o $@ _ctdt.o $@.tmp
+ $(RM)$(subst /,$(DIRCHAR), _ctdt.c _ctdt.o $@.tmp)
+
+cleanall:
+ @for %f in ($(notdir $(MODULE_OBJS))) do \
+ $(RM) ..\bin\%f
+
+ $(RM) $(MY_OUTPUT)
+
+
diff --git a/data/mnet/Common/socket/src_stub/ssl_intf.cpp b/data/mnet/Common/socket/src_stub/ssl_intf.cpp
new file mode 100644
index 0000000..260cdae
--- /dev/null
+++ b/data/mnet/Common/socket/src_stub/ssl_intf.cpp
@@ -0,0 +1,23 @@
+// *******************************************************************
+//
+// (c) Copyright CISCO Systems, Inc 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// File : ssl_intf.cpp
+// Author(s) : Igal Gutkin
+// Create Date : 05/17/01
+// Description : SSL library interface module stub
+//
+// *******************************************************************
+
+#include "socket\SslIntf.h"
+
+int isSSL ()
+{
+ return (0);
+}
diff --git a/data/mnet/Common/subsc/Makefile b/data/mnet/Common/subsc/Makefile
new file mode 100644
index 0000000..bd4611d
--- /dev/null
+++ b/data/mnet/Common/subsc/Makefile
@@ -0,0 +1,47 @@
+##########################################################
+#
+# (c) Copyright Cisco 2000
+# All Rights Reserved
+#
+# Use Examples:
+#
+# Case 1:
+# make all VOB=GP10 -
+# Places .out in VOB/bin directory
+#
+# Case 2:
+# make all VOB=GP10 APPDIR=Host\<Application Name>\<Source Directory> -
+# Places .o file(s) in VOB\$(APPDIR)\bin directory.
+#
+# <Application Name> = Name of Application directory
+# <Source Directory> = application sub directory where the calling
+# Makefile resides.
+#
+# Example: make all VOB=GP10 APPDIR=Host\vxTemplate\src
+#
+# (OPTIONAL) Append REPLACE - Replaces the List of directories
+# to be used in the SUBDIRS variable
+#
+# Example: make all VOB=GP10 APPDIR=Host\vxTemplate\src REPLACE=src
+#
+# Note: This make file must reference a VOB that
+# has a defs.mk in the top level directory.
+#
+##########################################################
+
+SUBDIRS = src
+
+# TOP_OF_VOB must be defined before including l3defs.mk
+TOP_OF_VOB = ..\..
+
+VOBDIR = $(TOP_OF_VOB)\$(VOB)
+
+# Allows a sub-set of the source code directories to be used
+
+ifneq ($(REPLACE),)
+ SUBDIRS = $(REPLACE)
+endif
+
+include $(VOBDIR)\l3defs.mk
+
+
diff --git a/data/mnet/Common/subsc/src/Makefile b/data/mnet/Common/subsc/src/Makefile
new file mode 100644
index 0000000..b255dce
--- /dev/null
+++ b/data/mnet/Common/subsc/src/Makefile
@@ -0,0 +1,61 @@
+##########################################################
+#
+# (c) Copyright Cisco 2000
+# All Rights Reserved
+#
+# Use Examples:
+#
+# Case 1:
+# make all VOB=GP10 -
+# Places .out in VOB/bin directory
+#
+# Case 2:
+# make all VOB=GP10 APPDIR=Host\<Application Name>\<Source Directory> -
+# Places .o file(s) in VOB\$(APPDIR)\bin directory.
+#
+# <Application Name> = Name of Application directory
+# <Source Directory> = application sub directory where the calling
+# Makefile resides.
+#
+# Example: make all VOB=GP10 APPDIR=Host\vxTemplate\src
+#
+#
+# Note: This make file must reference a VOB that
+# has a defs.mk in the top level directory.
+#
+##########################################################
+
+# TOP_OF_VOB must be defined before including l3defs.mk
+TOP_OF_VOB = ..\..
+
+# Name of this App's Directory
+THIS_APP_DIR = subsc
+
+VOB2DIR = $(TOP_OF_VOB)\..\$(VOB)
+BINDIR = ..\bin
+
+ifeq ($(APPDIR),)
+ MY_OUTPUT = $(VOB2DIR)\bin\$(THIS_APP_DIR).out
+else
+ MY_OUTPUT = $(OBJDIR)\$(THIS_APP_DIR).out
+endif
+
+include $(VOB2DIR)\l3defs.mk
+
+
+all: $(MY_OUTPUT)
+
+$(MY_OUTPUT): $(MODULE_OBJS)
+ $(LD) -r -o $@.tmp $(MODULE_OBJS)
+ $(NM) $@.tmp | munch > _ctdt.c
+ $(CC) -traditional $(CC_ARCH_SPEC) -c _ctdt.c
+ $(LD) -r -o $@ _ctdt.o $@.tmp
+ $(RM)$(subst /,$(DIRCHAR), _ctdt.c _ctdt.o $@.tmp)
+
+cleanall:
+ @for %f in ($(notdir $(MODULE_OBJS))) do \
+ $(RM) ..\bin\%f
+
+ $(RM) $(MY_OUTPUT)
+
+
diff --git a/data/mnet/Common/subsc/src/SubscInfo.cpp b/data/mnet/Common/subsc/src/SubscInfo.cpp
new file mode 100644
index 0000000..2cc625c
--- /dev/null
+++ b/data/mnet/Common/subsc/src/SubscInfo.cpp
@@ -0,0 +1,200 @@
+// *******************************************************************
+//
+// (c) Copyright Cisco 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// Status : Under development
+// File : SubscInfo.cpp
+// Author(s) : Kevin Lim
+// Create Date : 06-16-99
+// Description : subscriber information structure and en/decoding function
+// for messages
+//
+// *******************************************************************
+#include "stdio.h"
+#include "string.h"
+#include "subsc/SubscInfoType.h"
+#include "subsc/SubscGPRSInfoType.h"
+
+char * getSubscInfoIETypeStr(T_SUBSC_INFO_IE_TYPE ie_type)
+{
+ switch(ie_type){
+ case SUBSC_INFO_IE_VERSION_NUMBER : return("VERSION_NUM ");
+ case SUBSC_INFO_IE_MOBILE_ID_IMSI : return("MOBILE_IMSI ");
+ case SUBSC_INFO_IE_ISDN : return("ISDN ");
+ case SUBSC_INFO_IE_SUBADDR : return("SUBADDR ");
+ case SUBSC_INFO_IE_PROVISION_BS : return("PROVISION_BS");
+ case SUBSC_INFO_IE_PROVISION_TS : return("PROVISION_TS");
+ case SUBSC_INFO_IE_PROVISION_SS : return("PROVISION_SS");
+ case SUBSC_INFO_IE_SUBSC_STATUS : return("SUBSC_STATUS");
+ case SUBSC_INFO_IE_ODB_DATA : return("ODB_DATA ");
+ case SUBSC_INFO_IE_SS_INFO_LIST : return("SS_INFO_LIST");
+ case SUBSC_INFO_IE_USER_INFO : return("USER_INFO ");
+ case SUBSC_INFO_IE_GPRS_DATA : return("GPRS_DATAT ");
+ default: return("Unknown IE Type");
+ }
+}
+
+char * getSubscInfoBSCodeStr(T_SUBSC_INFO_BEARER_SERVICE_CODE code)
+{
+ switch(code){
+ case ALL_BEARER_SERVICES : return("ALL_BEARER");
+
+ case ALL_DATA_CDA : return("ALL_DATA_CDA");
+ case DATA_CDA_300BPS : return("DATA_CDA_300");
+ case DATA_CDA_1200BPS : return("DATA_CDA_1200");
+ case DATA_CDA_1200_75BPS : return("DATA_CDA_1200_75");
+ case DATA_CDA_2400BPS : return("DATA_CDA_2400");
+ case DATA_CDA_4800BPS : return("DATA_CDA_4800");
+ case DATA_CDA_9600BPS : return("DATA_CDA_9600"); // supported by ViperCell
+ case DATA_CDA_14400BPS : return("DATA_CDA_14400"); // supported by ViperCell
+ case DATA_CDA_GENERAL : return("DATA_CDA_GENERAL");
+
+ case ALL_DATA_CDS : return("ALL_DATA_CDS");
+ case DATA_CDS_1200BPS : return("DATA_CDS_1200");
+ case DATA_CDS_2400BPS : return("DATA_CDS_2400");
+ case DATA_CDS_4800BPS : return("DATA_CDS_4800");
+ case DATA_CDS_9600BPS : return("DATA_CDS_9600");
+ case DATA_CDS_GENERAL : return("DATA_CDS_GENERAL");
+
+ case ALL_PAD_ACCESS_CA : return("ALL_PAD_ACCESS_CA");
+ case PAD_ACCESS_CA_300BPS : return("PAD_ACC_CA_300");
+ case PAD_ACCESS_CA_1200BPS : return("PAD_ACC_CA_1200");
+ case PAD_ACCESS_CA_1200_75BPS : return("PAD_ACC_CA_1200_75");
+ case PAD_ACCESS_CA_2400BPS : return("PAD_ACC_CA_2400");
+ case PAD_ACCESS_CA_4800BPS : return("PAD_ACC_CA_4800");
+ case PAD_ACCESS_CA_9600BPS : return("PAD_ACC_CA_9600");
+ case PAD_ACCESS_CA_GENERAL : return("PAD_ACC_CA_GENERAL");
+
+ case ALL_DATA_PDS : return("ALL_DATA_PDS");
+ case DATA_PDS_2400BPS : return("DATA_PDS_2400");
+ case DATA_PDS_4800BPS : return("DATA_PDS_4800");
+ case DATA_PDS_9600BPS : return("DATA_PDS_9600");
+ case DATA_PDS_GENERAL : return("DATA_PDS_GENERAL");
+
+ case ALL_ALT_SPEECH_DATA_CDA : return("ALL_ALT_SPCH_CDA");
+ case ALL_ALT_SPEECH_DATA_CDS : return("ALL_ALT_SPCH_CDS");
+ case ALL_SPEECH_FOLL_DATA_CDA : return("ALL_SPCH_FOLL_CDA");
+ case ALL_SPEECH_FOLL_DATA_CDS : return("ALL_SPCH_FOLL_CDS");
+
+ case ALL_PLMN_SPECIFIC_BS : return("ALL_PLMN_SPEC_BS");
+ case PLMN_SPECIFIC_BS_1 : return("PLMN_SPEC_BS_1");
+ case PLMN_SPECIFIC_BS_2 : return("PLMN_SPEC_BS_2");
+ case PLMN_SPECIFIC_BS_3 : return("PLMN_SPEC_BS_3");
+ case PLMN_SPECIFIC_BS_4 : return("PLMN_SPEC_BS_4");
+ case PLMN_SPECIFIC_BS_5 : return("PLMN_SPEC_BS_5");
+ case PLMN_SPECIFIC_BS_6 : return("PLMN_SPEC_BS_6");
+ case PLMN_SPECIFIC_BS_7 : return("PLMN_SPEC_BS_7");
+ case PLMN_SPECIFIC_BS_8 : return("PLMN_SPEC_BS_8");
+ case PLMN_SPECIFIC_BS_9 : return("PLMN_SPEC_BS_9");
+ case PLMN_SPECIFIC_BS_A : return("PLMN_SPEC_BS_A");
+ case PLMN_SPECIFIC_BS_B : return("PLMN_SPEC_BS_B");
+ case PLMN_SPECIFIC_BS_C : return("PLMN_SPEC_BS_C");
+ case PLMN_SPECIFIC_BS_D : return("PLMN_SPEC_BS_D");
+ case PLMN_SPECIFIC_BS_E : return("PLMN_SPEC_BS_E");
+ case PLMN_SPECIFIC_BS_F : return("PLMN_SPEC_BS_F");
+ default: return("Unknown BS Code");
+ }
+}
+
+char * getSubscInfoTSCodeStr(T_SUBSC_INFO_TELE_SERVICE_CODE code)
+{
+ switch(code){
+ case ALL_TELE_SERVICES : return("ALL_TELE");
+
+ case ALL_SPEECH_SERVICES : return("ALL_SPCH_SRVC");
+ case TELEPHONY_SERVICES : return("TELE_SRVC");
+ case EMERGENCY_CALLS : return("EMERGENCY");
+
+ case ALL_SMS : return("ALL_SMS");
+ case SMS_MT_PP : return("SMS_MT_PP");
+ case SMS_MO_PP : return("SMS_MO_PP");
+
+ case ALL_FACS : return("ALL_FACS");
+ case FACS_GRP3_ALT_SPEECH : return("FACS_GRP3_ALT_SPCH");
+ case AUTO_FACS_GRP3 : return("AUTO_FACS_GRP3");
+ case FACS_GRP4 : return("FACS_GRP4");
+
+ case ALL_VOICE_GROUP_CALL : return("ALL_VOICE_GROUP");
+ case VOICE_GROUP_CALL : return("VOICE_GROUP_CALL");
+ case VOICE_BROADCAST : return("VOICE_BROADCAST");
+
+ case ALL_PLMN_SPECIFIC_TS : return("ALL_PLMN_SPEC_TS");
+ case PLMN_SPECIFIC_TS_1 : return("PLMN_SPEC_TS_1");
+ case PLMN_SPECIFIC_TS_2 : return("PLMN_SPEC_TS_2");
+ case PLMN_SPECIFIC_TS_3 : return("PLMN_SPEC_TS_3");
+ case PLMN_SPECIFIC_TS_4 : return("PLMN_SPEC_TS_4");
+ case PLMN_SPECIFIC_TS_5 : return("PLMN_SPEC_TS_5");
+ case PLMN_SPECIFIC_TS_6 : return("PLMN_SPEC_TS_6");
+ case PLMN_SPECIFIC_TS_7 : return("PLMN_SPEC_TS_7");
+ case PLMN_SPECIFIC_TS_8 : return("PLMN_SPEC_TS_8");
+ case PLMN_SPECIFIC_TS_9 : return("PLMN_SPEC_TS_9");
+ case PLMN_SPECIFIC_TS_A : return("PLMN_SPEC_TS_A");
+ case PLMN_SPECIFIC_TS_B : return("PLMN_SPEC_TS_B");
+ case PLMN_SPECIFIC_TS_C : return("PLMN_SPEC_TS_C");
+ case PLMN_SPECIFIC_TS_D : return("PLMN_SPEC_TS_D");
+ case PLMN_SPECIFIC_TS_E : return("PLMN_SPEC_TS_E");
+ case PLMN_SPECIFIC_TS_F : return("PLMN_SPEC_TS_F");
+ default: return("Unknown TS Code");
+ }
+}
+
+char * getSubscInfoSSCodeStr(T_SUBSC_INFO_SUPP_SERVICE_CODE code)
+{
+ switch(code){
+ case SUPP_SERV_ALL_LI : return("ALL_LI");
+ case SUPP_SERV_CLIP : return("CLIP");
+ case SUPP_SERV_CLIR : return("CLIR");
+ case SUPP_SERV_COLP : return("COLP");
+ case SUPP_SERV_COLR : return("COLR");
+ case SUPP_SERV_ALL_FWD : return("ALL_FWD");
+ case SUPP_SERV_CFU : return("CFU");
+ case SUPP_SERV_CFB : return("CFB");
+ case SUPP_SERV_CFNRY : return("CFNRY");
+ case SUPP_SERV_CFNRC : return("CFNRC");
+ case SUPP_SERV_ALL_CO : return("ALL_CO");
+ case SUPP_SERV_ECT : return("ECT");
+ case SUPP_SERV_ALL_CC : return("ALL_CC");
+ case SUPP_SERV_CW : return("CW");
+ case SUPP_SERV_HOLD : return("HOLD");
+ case SUPP_SERV_ALL_MULT : return("ALL_MULT");
+ case SUPP_SERV_MPTY : return("MPTY");
+ case SUPP_SERV_ALL_BAR : return("ALL_BAR");
+ case SUPP_SERV_BAOC : return("BAOC");
+ case SUPP_SERV_BOIC : return("BOIC");
+ case SUPP_SERV_BOICE : return("BOICE");
+ case SUPP_SERV_BAIC : return("BAIC");
+ case SUPP_SERV_BIC_ROAM : return("BICRoam");
+ default: return("Unknown SS Code");
+ }
+}
+
+short checkSubscInfoIEType(unsigned char ie_type, T_SUBSC_INFO_IE_TYPE exp)
+{
+ if(ie_type != (unsigned char)exp){
+ printf("Expected SubscInfoIEType: %s\n",
+ getSubscInfoIETypeStr(exp));
+ printf("Encountered SubscInfoIEType: %s\n",
+ getSubscInfoIETypeStr((T_SUBSC_INFO_IE_TYPE)ie_type));
+ return 1;
+ }
+ else{
+ return 0;
+ }
+}
+
+void printSubscMsg(unsigned char *msg, short size)
+{
+ int i;
+ for(i=0; i<size; i++){
+ if(!(i%16)) printf("\n");
+ printf("%02x ", msg[i]);
+ }
+ printf("\n\n");
+}
+
diff --git a/data/mnet/Common/subsc/src/SubscInfoMsgDecoder.cpp b/data/mnet/Common/subsc/src/SubscInfoMsgDecoder.cpp
new file mode 100644
index 0000000..a75f07c
--- /dev/null
+++ b/data/mnet/Common/subsc/src/SubscInfoMsgDecoder.cpp
@@ -0,0 +1,610 @@
+// *******************************************************************
+//
+// (c) Copyright Cisco 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// Status : Under development
+// File : SubscInfoMsgDecoder.cpp
+// Author(s) : Kevin Lim
+// Create Date : 06-16-99
+// Description : subscriber information structure and decoding function
+// for messages
+//
+// Modification: 11-11-00
+// ccpentium compiler gives warning of
+// Warning: using `%eax' instead of `%ax' due to `l' suffix
+// if assigning character referenced value to short
+// kludge added to assign it to int and then assign it to short
+// *******************************************************************
+#include "stdio.h"
+#include "string.h"
+#include "subsc/SubscInfoType.h"
+#include "subsc/SubscInfoUtil.h"
+
+short isVerGE(T_SUBSC_VERSION v, int v0, int v1, int v2)
+{
+ int ver1 = v.v0 * 100 + v.v1 * 10 + v.v2;
+ int ver2 = v0 * 100 + v1 * 10 + v2;
+ if(ver1 >= ver2) return 1;
+ else return 0;
+}
+
+short DecodeVersionNumber(unsigned char *msg, short *i, T_SUBSC_VERSION *v)
+{
+ v->v0 = 0;
+ v->v1 = 0;
+ v->v2 = 0;
+ short ret = checkSubscInfoIEType(msg[(*i)], SUBSC_INFO_IE_VERSION_NUMBER);
+ if(ret){
+ ret = checkSubscInfoIEType(msg[(*i)], SUBSC_INFO_IE_MOBILE_ID_IMSI);
+ if(ret) return SUBSC_INFO_ERR_UNEXP_IE;
+ else return -1; // missing version number but has valid imsi field
+ }
+ else (*i)++;
+
+ int kludge;
+ v->v0 = kludge = msg[(*i)++];
+ v->v1 = kludge = msg[(*i)++];
+ v->v2 = kludge = msg[(*i)++];
+ if(v->v0 == SUBSC_ENC_VER0){
+ if(v->v1 == SUBSC_ENC_VER1){
+ if(v->v2 == SUBSC_ENC_VER2){
+ return 0;
+ }
+ }
+ }
+ return 1;
+}
+
+short DecodeMobileId1(unsigned char *msg, short *i, T_SUBSC_IE_MOBILE_ID_IMSI *imsi)
+{
+ int j;
+ short ret = checkSubscInfoIEType(msg[(*i)++], SUBSC_INFO_IE_MOBILE_ID_IMSI);
+ if(ret) return SUBSC_INFO_ERR_UNEXP_IE;
+
+ imsi->num_digit = SUBSC_MCC_LEN + SUBSC_MNC_LEN + SUBSC_MSIN_LEN;
+ for(j=0;j<imsi->num_digit;j++) imsi->imsi[j] = msg[(*i)++];
+ imsi->imsi[j] = '\0'; // null term
+ return 0;
+}
+
+short DecodeMobileId2(unsigned char *msg, short *i, T_SUBSC_IE_MOBILE_ID_IMSI *imsi)
+{
+ int j, num;
+ short ret = checkSubscInfoIEType(msg[(*i)++], SUBSC_INFO_IE_MOBILE_ID_IMSI);
+ if(ret) return SUBSC_INFO_ERR_UNEXP_IE;
+
+ num = imsi->num_digit = msg[(*i)++];
+ if(num > MAX_NUM_SUBSC_IMSI){
+ printf("Err. imsi num digit too large : %d\n", num);
+ printf("msg index value: %d\n", *i);
+ return SUBSC_INFO_ERR_IMSI_NUM_DIGIT;
+ }
+ for(j=0;j<num;j++) imsi->imsi[j] = msg[(*i)++];
+ imsi->imsi[j] = '\0'; // null term
+ return 0;
+}
+
+short DecodeISDN(unsigned char *msg, short *i, T_SUBSC_IE_ISDN *msisdn, T_SUBSC_VERSION *v)
+{
+ int j, num;
+ short ret = checkSubscInfoIEType(msg[(*i)++], SUBSC_INFO_IE_ISDN);
+ if(ret) return SUBSC_INFO_ERR_UNEXP_IE;
+
+ msisdn->num_digit = num = msg[(*i)++];
+ if(num > MAX_NUM_SUBSC_ISDN){
+ printf("Err. msisdn num digit too large : %d\n", num);
+ printf("msg index value: %d\n", *i);
+ return SUBSC_INFO_ERR_ISDN_NUM_DIGIT;
+ }
+ for(j=0;j<num;j++) msisdn->digits[j] = msg[(*i)++];
+ msisdn->digits[j] = '\0'; // null term
+
+ if(isVerGE(*v, 2, 0, 4)){ // version 2.0.4 up
+ for(j=0; j<NUM_PLAN_LEN; j++){
+ msisdn->num_plan[j] = msg[(*i)++];
+ }
+ }
+ return 0;
+}
+
+short DecodeSubAddr(unsigned char *msg, short *i, T_SUBSC_IE_SUBADDR *subaddr)
+{
+ int j, kludge;
+ short ret = checkSubscInfoIEType(msg[(*i)++], SUBSC_INFO_IE_SUBADDR);
+ if(ret) return SUBSC_INFO_ERR_UNEXP_IE;
+
+ subaddr->subaddr_type = kludge = msg[(*i)++];
+ for(j=0; j<NUM_SUBADDR_INFO; j++) subaddr->info[j] = msg[(*i)++];
+ return 0;
+}
+
+short DecodeProvisionBS(unsigned char *msg, short *i, T_SUBSC_IE_PROVISION_BS *bs)
+{
+ int j, num;
+ short ret = checkSubscInfoIEType(msg[(*i)++], SUBSC_INFO_IE_PROVISION_BS);
+ if(ret) return SUBSC_INFO_ERR_UNEXP_IE;
+
+ bs->num_srv = num = msg[(*i)++];
+ if(num > MAX_NUM_BEARER_SERVICE){
+ printf("Err. bearer service number too large : %d\n", num);
+ printf("msg index value: %d\n", *i);
+ return SUBSC_INFO_ERR_BS_NUM_SRV;
+ }
+ for(j=0;j<num;j++) bs->bs_code[j] = (T_SUBSC_INFO_BEARER_SERVICE_CODE)msg[(*i)++];
+ return 0;
+}
+
+short DecodeProvisionTS(unsigned char *msg, short *i, T_SUBSC_IE_PROVISION_TS *ts)
+{
+ int j, num;
+ short ret = checkSubscInfoIEType(msg[(*i)++], SUBSC_INFO_IE_PROVISION_TS);
+ if(ret) return SUBSC_INFO_ERR_UNEXP_IE;
+
+ ts->num_srv = num = msg[(*i)++];
+ if(num > MAX_NUM_TELE_SERVICE){
+ printf("Err. tele service number too large : %d\n", num);
+ printf("msg index value: %d\n", *i);
+ return SUBSC_INFO_ERR_TS_NUM_SRV;
+ }
+ for(j=0;j<num;j++) ts->ts_code[j] = (T_SUBSC_INFO_TELE_SERVICE_CODE)msg[(*i)++];
+ return 0;
+}
+
+short DecodeProvisionSS(unsigned char *msg, short *i, T_SUBSC_IE_PROVISION_SS *ss,
+ T_SUBSC_IE_SS_INFO_LIST *ss_info_list, T_SUBSC_VERSION *v)
+{
+ int j, num;
+ short ret = checkSubscInfoIEType(msg[(*i)++], SUBSC_INFO_IE_PROVISION_SS);
+ if(ret) return SUBSC_INFO_ERR_UNEXP_IE;
+
+ ss->num_srv = num = msg[(*i)++];
+ if(num > MAX_NUM_SUPP_SERVICE){
+ printf("Err. supp. service number too large : %d\n", num);
+ printf("msg index value: %d\n", *i);
+ return SUBSC_INFO_ERR_SS_NUM_SRV;
+ }
+ for(j=0;j<num;j++){
+ T_SUBSC_INFO_SUPP_SERVICE_CODE ss_code =
+ (T_SUBSC_INFO_SUPP_SERVICE_CODE)msg[(*i)++];
+
+ /* fix wrong code */
+ if(ss_code == 0x96) ss_code = SUPP_SERV_BAIC;
+ if(ss_code == 0x97) ss_code = SUPP_SERV_BIC_ROAM;
+
+ ss->ss_code[j] = ss_code;
+ if(!isVerGE(*v, 2, 0, 6)){
+ subscSetP(ss_info_list, ss_code, 1);
+ }
+ }
+ return 0;
+}
+
+short DecodeStatusFlag(unsigned char *msg, short *i, T_SUBSC_IE_SUBSC_STATUS *status)
+{
+ short ret = checkSubscInfoIEType(msg[(*i)++], SUBSC_INFO_IE_SUBSC_STATUS);
+ if(ret) return SUBSC_INFO_ERR_UNEXP_IE;
+
+ status->status = (T_SUBSC_STATUS_TYPE)msg[(*i)++];
+ return 0;
+}
+
+short DecodeODBData(unsigned char *msg, short *i, T_SUBSC_IE_ODB_DATA *odb_data)
+{
+ int temp;
+ short ret = checkSubscInfoIEType(msg[(*i)++], SUBSC_INFO_IE_ODB_DATA);
+ if(ret) return SUBSC_INFO_ERR_UNEXP_IE;
+
+ temp = msg[(*i)++]; // reserved
+ temp = msg[(*i)++]; // reserved
+ temp = msg[(*i)++];
+ odb_data->odb_general.multiple_ect_barred =
+ (temp >> ODB_GEN_BIT_MULTI_ECT) & 0x01;
+ odb_data->odb_general.double_chargeable_ect_barred =
+ (temp >> ODB_GEN_BIT_DBL_CHARGE_ECT) & 0x01;
+ odb_data->odb_general.intrz_ect_barred =
+ (temp >> ODB_GEN_BIT_INTRZ_ECT) & 0x01;
+ odb_data->odb_general.intrn_ect_barred =
+ (temp >> ODB_GEN_BIT_INTRN_ECT) & 0x01;
+ odb_data->odb_general.chargeable_ect_barred =
+ (temp >> ODB_GEN_BIT_CHARGE_ECT) & 0x01;
+ odb_data->odb_general.all_ect_barred =
+ (temp >> ODB_GEN_BIT_ALL_ECT) & 0x01;
+ odb_data->odb_general.intrz_intrn_og_not_hplmn_barred =
+ (temp >> ODB_GEN_BIT_INTRZ_INTRN_NOT_HPLMN) & 0x01;
+
+ temp = msg[(*i)++];
+ odb_data->odb_general.intrz_og_not_hplmn_barred =
+ (temp >> ODB_GEN_BIT_INTRZ_OG_NOT_HPLMN) & 0x01;
+ odb_data->odb_general.intrz_og_barred =
+ (temp >> ODB_GEN_BIT_INTRZ_OG) & 0x01;
+ odb_data->odb_general.ss_access_barred =
+ (temp >> ODB_GEN_BIT_SS_ACCESS) & 0x01;
+ odb_data->odb_general.premium_enter_og_barred =
+ (temp >> ODB_GEN_BIT_PREM_ENT) & 0x01;
+ odb_data->odb_general.premium_info_og_barred =
+ (temp >> ODB_GEN_BIT_PREM_INFO) & 0x01;
+ odb_data->odb_general.intrn_og_not_hplmn_barred =
+ (temp >> ODB_GEN_BIT_INTRN_OG_NOT_HPLMN) & 0x01;
+ odb_data->odb_general.intrn_og_barred =
+ (temp >> ODB_GEN_BIT_INTRN_OG) & 0x01;
+ odb_data->odb_general.all_og_barred =
+ (temp >> ODB_GEN_BIT_ALL_OG) & 0x01;
+
+ temp = msg[(*i)++]; // reserved
+ temp = msg[(*i)++]; // reserved
+ temp = msg[(*i)++]; // reserved
+ temp = msg[(*i)++];
+ odb_data->odb_plmn.plmn_specific_type4 = (temp >> ODB_HPLMN_BIT_TYPE_4) & 0x01;
+ odb_data->odb_plmn.plmn_specific_type3 = (temp >> ODB_HPLMN_BIT_TYPE_3) & 0x01;
+ odb_data->odb_plmn.plmn_specific_type2 = (temp >> ODB_HPLMN_BIT_TYPE_2) & 0x01;
+ odb_data->odb_plmn.plmn_specific_type1 = (temp >> ODB_HPLMN_BIT_TYPE_1) & 0x01;
+ return 0;
+}
+
+short DecodeBasicServiceCode(unsigned char *msg, short *i,
+ T_SUBSC_INFO_EXT_BASIC_SERVICE *basic_service)
+{
+ int j;
+ basic_service->service_type = (T_SUBSC_INFO_BASIC_SERVICE_TYPE)msg[(*i)++];
+ switch(basic_service->service_type){
+ case BEARER_SERVICE_TYPE:
+ for(j=0;j<5;j++) basic_service->ex_bs_code[j] = msg[(*i)++];
+ break;
+ case TELE_SERVICE_TYPE:
+ for(j=0;j<5;j++) basic_service->ex_ts_code[j] = msg[(*i)++];
+ break;
+ default:
+ printf("Unknown Basic Service Type :%d\n", basic_service->service_type);
+ return SUBSC_INFO_ERR_UNKNOWN_BASIC;
+ }
+ return 0;
+}
+
+short DecodeSSStatus(unsigned char *msg, short *i,
+ T_SS_STATUS_FLAG *ss_status)
+{
+ int temp = msg[(*i)++];
+ ss_status->ss_status_A = (temp >> SS_STATUS_A_BIT) & 0x01;
+ ss_status->ss_status_R = (temp >> SS_STATUS_R_BIT) & 0x01;
+ ss_status->ss_status_P = (temp >> SS_STATUS_P_BIT) & 0x01;
+ ss_status->ss_status_Q = (temp >> SS_STATUS_Q_BIT) & 0x01;
+ return 0;
+}
+
+short DecodeSSSubscOptionV210OrOlder(unsigned char *msg, short *i, T_SS_SUBSC_OPTION *ss_subsc_option) // 2.1.1
+{
+ ss_subsc_option->isPresent = true;
+ ss_subsc_option->option_type = SS_SUBSC_OPTION_CLIR_OPTION;
+ ss_subsc_option->clir_option = CLIR_PERMANENT;
+
+ return 0;
+}
+
+short DecodeSSSubscOptionV211OrLater(unsigned char *msg, short *i, T_SS_SUBSC_OPTION *ss_subsc_option) // 2.1.1
+{
+ ss_subsc_option->isPresent = (msg[(*i)++]==0)? false : true;
+
+ if (ss_subsc_option->isPresent==false) return 0;
+
+ ss_subsc_option->option_type = (T_SS_SUBSC_OPTION_TYPE) msg[(*i)++];
+
+ switch(ss_subsc_option->option_type)
+ {
+ case SS_SUBSC_OPTION_CLIR_OPTION:
+ ss_subsc_option->clir_option = (T_SS_SUBSC_CLIR_OPTION) msg[(*i)++];
+ break;
+
+ case SS_SUBSC_OPTION_OVERRIDE_CATEGORY:
+ ss_subsc_option->override_category = (T_SS_SUBSC_OVERRIDE_CATEGORY) msg[(*i)++];
+ break;
+
+ default:
+ printf("Unsupported SS Subscription Option Type : %d\n", ss_subsc_option->option_type);
+ printf("msg index value: %d\n", *i);
+ return SUBSC_INFO_ERR_SS_SUBSC_OPTION;
+ }
+
+ return 0;
+}
+
+short DecodeSSSubscOption(unsigned char *msg, short *i, T_SS_SUBSC_OPTION *ss_subsc_option, T_SUBSC_VERSION *v) // 2.1.1
+{
+ if (!isVerGE(*v,2,1,1))
+ {
+ return DecodeSSSubscOptionV210OrOlder(msg, i, ss_subsc_option);
+ }
+
+ return DecodeSSSubscOptionV211OrLater(msg, i, ss_subsc_option);
+}
+
+short DecodeForwOption(unsigned char *msg, short *i,
+ T_SS_FORW_OPTION *forw)
+{
+ int temp = msg[(*i)++];
+ forw->notify_forw_party = (T_NOTIFY_FORW_FLAG)
+ ((temp >> SS_NOTIFY_FORW_FLAG_BIT) & 0x01);
+ forw->notify_calling_party = (T_NOTIFY_CALLING_FLAG)
+ ((temp >> SS_NOTIFY_CALLING_FLAG_BIT) & 0x01);
+ forw->forw_reason = (T_FORW_REASON_FLAG)
+ ((temp >> SS_FORW_REASON_FLAG_BIT) & 0x03);
+ return 0;
+}
+
+short DecodeSSInfoForw(unsigned char *msg, short *i, T_SUBSC_IE_SS_INFO_FORW *forw, T_SUBSC_VERSION *v)
+{
+ int j, num, kludge;
+ forw->ss_code = (T_SUBSC_INFO_SUPP_SERVICE_CODE)msg[(*i)++];
+ forw->num_feature = num = msg[(*i)++];
+ if(num > MAX_NUM_EXT_FEATURE){
+ printf("Err. forw feature number too large : %d\n", num);
+ printf("msg index value: %d\n", *i);
+ return SUBSC_INFO_ERR_FORW_NUM_FEATURE;
+ }
+ for(j=0; j<num; j++){
+ DecodeBasicServiceCode(msg, i, &forw->list[j].basic_service);
+ DecodeSSStatus(msg, i, &forw->list[j].ss_status);
+ DecodeISDN(msg, i, &forw->list[j].forw_to_num, v);
+ DecodeSubAddr(msg, i, &forw->list[j].forw_to_sub);
+ DecodeForwOption(msg, i, &forw->list[j].forw_options);
+ forw->list[j].no_reply_cond_time = kludge = msg[(*i)++];
+ }
+ return 0;
+}
+
+short DecodeSSInfoBar(unsigned char *msg, short *i, T_SUBSC_IE_SS_INFO_BAR *bar, T_SUBSC_VERSION *v)
+{
+ int j, num;
+ bar->ss_code = (T_SUBSC_INFO_SUPP_SERVICE_CODE)msg[(*i)++];
+ /* fix wrong code */
+ if(bar->ss_code == 0x96) bar->ss_code = SUPP_SERV_BAIC;
+ if(bar->ss_code == 0x97) bar->ss_code = SUPP_SERV_BIC_ROAM;
+ bar->num_feature = num = msg[(*i)++];
+ if(num > MAX_NUM_EXT_FEATURE){
+ printf("Err. bar feature number too large : %d\n", num);
+ printf("msg index value: %d\n", *i);
+ return SUBSC_INFO_ERR_BAR_NUM_FEATURE;
+ }
+ for(j=0; j<num; j++){
+ DecodeBasicServiceCode(msg, i, &bar->list[j].basic_service);
+ DecodeSSStatus(msg, i, &bar->list[j].ss_status);
+ }
+ if(!isVerGE(*v, 2, 0, 8)){
+ bar->num_feature = 1;
+ bar->list[0].basic_service.service_type = TELE_SERVICE_TYPE;
+ }
+ return 0;
+}
+
+short DecodeSSInfoData(unsigned char *msg, short *i, T_SUBSC_IE_SS_INFO_DATA *data, T_SUBSC_VERSION *v) // 2.0.5
+{
+ data->ss_code = (T_SUBSC_INFO_SUPP_SERVICE_CODE)msg[(*i)++];
+ DecodeSSStatus(msg, i, &data->ss_status);
+ DecodeSSSubscOption(msg, i, &data->ss_subsc_option, v); // 2.1.1
+ return 0;
+}
+
+short DecodeSSInfo(unsigned char *msg, short *i, T_SUBSC_IE_SS_INFO *ss_info, T_SUBSC_VERSION *v)
+{
+ short ret = 0;
+ ss_info->info_type = (T_SUBSC_IE_SS_INFO_TYPE)msg[(*i)++];
+ switch(ss_info->info_type){
+ case SUBSC_IE_SS_INFO_FORW_TYPE:
+ DecodeSSInfoForw(msg, i, &ss_info->info_forw, v);
+ break;
+ case SUBSC_IE_SS_INFO_BARR_TYPE:
+ DecodeSSInfoBar(msg, i, &ss_info->info_bar, v);
+ break;
+ case SUBSC_IE_SS_INFO_DATA_TYPE: // 2.0.5
+ DecodeSSInfoData(msg, i, &ss_info->info_data, v); // 2.1.1
+ break;
+ default:
+ printf("Unsupported SS Info Type encountered :%d\n", ss_info->info_type);
+ printf("msg index value: %d\n", *i);
+ ret = SUBSC_INFO_ERR_SS_INFO_TYPE;
+ }
+ return ret;
+}
+
+short DecodeSSInfoList(unsigned char *msg, short *i, T_SUBSC_IE_SS_INFO_LIST *ss_info_list, T_SUBSC_VERSION *v)
+{
+ int j, num, ind;
+ short ret = checkSubscInfoIEType(msg[(*i)++], SUBSC_INFO_IE_SS_INFO_LIST);
+ if(ret) return SUBSC_INFO_ERR_UNEXP_IE;
+
+// num = ss_info_list->num_ss_info = msg[(*i)++];
+ num = msg[(*i)++];
+ if(num > MAX_NUM_SUPP_SERVICE){
+ printf("Err. ss info list number too large : %d\n", num);
+ printf("msg index value: %d\n", *i);
+ return SUBSC_INFO_ERR_SS_NUM_INFO;
+ }
+ for(j=0; j<num; j++){
+ switch(msg[(*i)++]){
+ case SUBSC_IE_SS_INFO_FORW_TYPE:
+ ind = subscGetSSInfoForwInd((T_SUBSC_INFO_SUPP_SERVICE_CODE)msg[*i]);
+ if(ind == -1) return SUBSC_INFO_ERR_SS_INFO_TYPE;
+ DecodeSSInfoForw(msg, i, &ss_info_list->ss_info_forw[ind], v);
+ break;
+ case SUBSC_IE_SS_INFO_DATA_TYPE:
+ ind = subscGetSSInfoDataInd((T_SUBSC_INFO_SUPP_SERVICE_CODE)msg[*i]);
+ if(ind == -1) return SUBSC_INFO_ERR_SS_INFO_TYPE;
+ DecodeSSInfoData(msg, i, &ss_info_list->ss_info_data[ind], v); // 2.1.1
+ break;
+ case SUBSC_IE_SS_INFO_BARR_TYPE:
+ ind = subscGetSSInfoBarInd((T_SUBSC_INFO_SUPP_SERVICE_CODE)msg[*i]);
+ if(ind == -1) return SUBSC_INFO_ERR_SS_INFO_TYPE;
+ DecodeSSInfoBar(msg, i, &ss_info_list->ss_info_bar[ind], v);
+ break;
+ }
+ }
+ return 0;
+}
+
+short DecodeUserInfo(unsigned char *msg, short *i, T_SUBSC_IE_USER_INFO *user)
+{
+ int j, num;
+ short ret = checkSubscInfoIEType(msg[(*i)++], SUBSC_INFO_IE_USER_INFO);
+ if(ret) return SUBSC_INFO_ERR_UNEXP_IE;
+
+ user->len = num = msg[(*i)++];
+ if(num > MAX_NUM_USER_INFO){
+ printf("Err. user info too large : %d\n", num);
+ printf("msg index value: %d\n", *i);
+ return SUBSC_INFO_ERR_USER_INFO;
+ }
+ for(j=0; j<num; j++){
+ user->name[j] = msg[(*i)++];
+ }
+ user->name[j] = '\0'; // null term
+ return 0;
+}
+
+short DecodeGPRSData(unsigned char *msg, short *i, T_SUBSC_GPRS_DATA *data)
+{
+ int j, num;
+
+ data->pdpContextId = msg[(*i)++];
+ data->pdpType = (CNI_RIL3_PDP_ADDRESS_TYPE)msg[(*i)++];
+ for(j=0; j<MAX_LEN_SUBSC_PDP_ADDR; j++)
+ data->pdpAddress[j] = msg[(*i)++];
+ data->qosSubscribed.delay_class = (CNI_RIL3_QOS_DELAY_CLASS)msg[(*i)++];
+ data->qosSubscribed.reliability_class = (CNI_RIL3_QOS_RELIABILITY_CLASS)msg[(*i)++];
+ data->qosSubscribed.precedence_class = (CNI_RIL3_QOS_PRECEDENCE_CLASS)msg[(*i)++];
+ data->qosSubscribed.peak_throughput = (CNI_RIL3_QOS_PEAK_THROUGHPUT)msg[(*i)++];
+ data->qosSubscribed.mean_throughput = (CNI_RIL3_QOS_MEAN_THROUGHPUT)msg[(*i)++];
+ data->vplmnAddressAllowed = msg[(*i)++];
+ data->apn_length = num = msg[(*i)++];
+ if(num > MAX_LEN_SUBSC_APN){
+ printf("Err. apn length too large : %d\n", num);
+ printf("msg index value: %d\n", *i);
+ return SUBSC_INFO_ERR_APN_LEN;
+ }
+ for(j=0; j<num; j++){
+ data->apn[j] = msg[(*i)++];
+ }
+ data->apn[j] = '\0'; // null term
+ return 0;
+}
+
+short DecodeGPRSDataInfo(unsigned char *msg, short *i, T_SUBSC_IE_GPRS_DATA_INFO *gprs_data, T_SUBSC_VERSION *v)
+{
+ int j, num;
+ short ret;
+
+ if(!isVerGE(*v, 2, 1, 0)){
+ gprs_data->num_data = 0;
+ return 0;
+ }
+
+ ret = checkSubscInfoIEType(msg[(*i)++], SUBSC_INFO_IE_GPRS_DATA);
+ num = gprs_data->num_data = msg[(*i)++];
+ if(num > MAX_NUM_SUBSC_GPRS_DATA){
+ printf("Err. gprs data too many : %d\n", num);
+ printf("msg index value: %d\n", *i);
+ return SUBSC_INFO_ERR_GPRS_DATA_LEN;
+ }
+ for(j=0; j<num; j++){
+ ret = DecodeGPRSData(msg, i, &gprs_data->data[j]);
+ if(ret) return ret;
+ }
+ return 0;
+}
+
+// Decode SubscInfo from Message Buffer to the structure.
+// size - size of message in msg buffer
+bool dbgDecodeSubscInfoFlag = false;
+
+extern "C" void dbgDecodeSubscInfoFlagToggle(void)
+{
+ dbgDecodeSubscInfoFlag = !dbgDecodeSubscInfoFlag;
+ printf("[dbgDecodeSubscInfoFlagToggle] debugging is %s\n",
+ (dbgDecodeSubscInfoFlag)? "enabled" : "disabled");
+}
+
+short DecodeSubscInfo(unsigned char *msg,
+ short size,
+ T_SUBSC_INFO *subsc)
+{
+ short i = 0;
+ short ret;
+ T_SUBSC_VERSION v;
+
+ memset(subsc, 0, sizeof(T_SUBSC_INFO)); // 2.1.2
+
+ ret = DecodeVersionNumber(msg, &i, &v);
+ if(ret == -1){
+ printf("decoding older version subsc info\n");
+ if(ret = DecodeMobileId1(msg, &i, &subsc->imsi)) return ret;
+ }
+ else{
+ if(ret = DecodeMobileId2(msg, &i, &subsc->imsi)) return ret;
+ }
+ if(ret = DecodeISDN(msg, &i, &subsc->msisdn, &v)) return ret;
+ if(ret = DecodeProvisionBS(msg, &i, &subsc->prov_bs)) return ret;
+ if(ret = DecodeProvisionTS(msg, &i, &subsc->prov_ts)) return ret;
+ subscSSInfoListClear(&subsc->ss_info_list); // 2.0.6
+ if(ret = DecodeProvisionSS(msg, &i, &subsc->prov_ss,
+ &subsc->ss_info_list, &v)) return ret;
+ if(ret = DecodeStatusFlag(msg, &i, &subsc->status)) return ret;
+ if(ret = DecodeODBData(msg, &i, &subsc->odb_data)) return ret;
+ if(ret = DecodeSSInfoList(msg, &i, &subsc->ss_info_list, &v)) return ret;
+ if(ret = DecodeUserInfo(msg, &i, &subsc->user)) return ret;
+ if(ret = DecodeGPRSDataInfo(msg, &i, &subsc->gprs_data, &v)) return ret;
+
+ if (dbgDecodeSubscInfoFlag)
+ {
+ printf("[DecodeSubscInfo] \n");
+ subscPrintInfo(subsc);
+ }
+
+ return 0;
+}
+
+short DecodeAuthTriplet(unsigned char *msg, short *i, T_AUTH_TRIPLET *triplet)
+{
+ int j;
+
+ for(j=0;j<3;j++) triplet->RAND[j] = msg[(*i)++];
+ for(j=0;j<2;j++) triplet->SRES[j] = msg[(*i)++];
+ for(j=0;j<10;j++) triplet->Kc[j] = msg[(*i)++];
+ return 0;
+}
+
+short DecodeAuthList(unsigned char *msg, short *i, T_SEC_IE_AUTH_LIST *auth_set)
+{
+ int j, num;
+ short ret = checkSubscInfoIEType(msg[(*i)++], SUBSC_INFO_IE_AUTH_LIST);
+ if(ret) return SUBSC_INFO_ERR_UNEXP_IE;
+
+ auth_set->num_set = num = msg[(*i)++];
+ if(num > SEC_MAX_TRIPLET){
+ printf("Err. auth triplet list number too large : %d\n", num);
+ printf("msg index value: %d\n", *i);
+ return SUBSC_INFO_ERR_AUTH_NUM_LIST;
+ }
+ for(j=0; j<num; j++){
+ ret = DecodeAuthTriplet(msg, i, &auth_set->triplet[j]);
+ if(ret) return ret;
+ }
+ return 0;
+}
+
+// Decode SecInfo from Message Buffer to the structure.
+// size - size of message in msg buffer
+short DecodeSecInfo(unsigned char *msg,
+ short size,
+ T_SEC_INFO *sec)
+{
+ short i = 0;
+ short ret;
+
+ if((ret = DecodeMobileId2(msg, &i, &sec->imsi))) return ret;
+ if((ret = DecodeAuthList(msg, &i, &sec->auth_set))) return ret;
+ return 0;
+}
diff --git a/data/mnet/Common/subsc/src/SubscInfoMsgEncoder.cpp b/data/mnet/Common/subsc/src/SubscInfoMsgEncoder.cpp
new file mode 100644
index 0000000..d9d5170
--- /dev/null
+++ b/data/mnet/Common/subsc/src/SubscInfoMsgEncoder.cpp
@@ -0,0 +1,459 @@
+// *******************************************************************
+//
+// (c) Copyright Cisco 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// Status : Under development
+// File : SubscInfoMsgEncoder.cpp
+// Author(s) : Kevin Lim
+// Create Date : 06-16-99
+// Description : subscriber information structure and encoding function
+// for messages
+//
+// *******************************************************************
+#include "stdio.h"
+#include "subsc/SubscInfoType.h"
+#include "subsc/SubscInfoUtil.h"
+
+short EncodeVersionNumber(unsigned char *msg, short *i)
+{
+ msg[(*i)++] = SUBSC_INFO_IE_VERSION_NUMBER;
+ msg[(*i)++] = SUBSC_ENC_VER0;
+ msg[(*i)++] = SUBSC_ENC_VER1;
+ msg[(*i)++] = SUBSC_ENC_VER2;
+ return 0;
+}
+
+short EncodeMobileId(unsigned char *msg, short *i, T_SUBSC_IE_MOBILE_ID_IMSI *imsi)
+{
+ int j, num;
+ msg[(*i)++] = SUBSC_INFO_IE_MOBILE_ID_IMSI;
+ num = msg[(*i)++] = (unsigned char)imsi->num_digit;
+ if(num > MAX_NUM_SUBSC_IMSI){
+ printf("Err. mobile id too large : %d\n", num);
+ return SUBSC_INFO_ERR_IMSI_NUM_DIGIT;
+ }
+ for(j=0;j<num;j++) msg[(*i)++] = imsi->imsi[j];
+ return 0;
+}
+
+short EncodeISDN(unsigned char *msg, short *i, T_SUBSC_IE_ISDN *msisdn)
+{
+ int j, num;
+ msg[(*i)++] = SUBSC_INFO_IE_ISDN;
+ num = msg[(*i)++] = (unsigned char)msisdn->num_digit;
+ if(num > MAX_NUM_SUBSC_ISDN){
+ printf("Err. msisdn num digit too large : %d\n", num);
+ return SUBSC_INFO_ERR_ISDN_NUM_DIGIT;
+ }
+ for(j=0;j<num;j++) msg[(*i)++] = msisdn->digits[j];
+ for(j=0;j<NUM_PLAN_LEN;j++) msg[(*i)++] = msisdn->num_plan[j];
+ return 0;
+}
+
+short EncodeSubAddr(unsigned char *msg, short *i, T_SUBSC_IE_SUBADDR *subaddr)
+{
+ int j;
+ msg[(*i)++] = SUBSC_INFO_IE_SUBADDR;
+ msg[(*i)++] = (unsigned char)subaddr->subaddr_type;
+ for(j=0;j<NUM_SUBADDR_INFO;j++) msg[(*i)++] = subaddr->info[j];
+ return 0;
+}
+
+short EncodeProvisionBS(unsigned char *msg, short *i, T_SUBSC_IE_PROVISION_BS *bs)
+{
+ int j, num;
+ msg[(*i)++] = SUBSC_INFO_IE_PROVISION_BS;
+ num = msg[(*i)++] = (unsigned char)bs->num_srv;
+ if(num > MAX_NUM_BEARER_SERVICE){
+ printf("Err. bearer service number too large : %d\n", num);
+ return SUBSC_INFO_ERR_BS_NUM_SRV;
+ }
+ for(j=0;j<num;j++) msg[(*i)++] = bs->bs_code[j];
+ return 0;
+}
+
+short EncodeProvisionTS(unsigned char *msg, short *i, T_SUBSC_IE_PROVISION_TS *ts)
+{
+ int j, num;
+ msg[(*i)++] = SUBSC_INFO_IE_PROVISION_TS;
+ num = msg[(*i)++] = (unsigned char)ts->num_srv;
+ if(num > MAX_NUM_TELE_SERVICE){
+ printf("Err. tele service number too large : %d\n", num);
+ return SUBSC_INFO_ERR_TS_NUM_SRV;
+ }
+ for(j=0;j<num;j++) msg[(*i)++] = ts->ts_code[j];
+ return 0;
+}
+
+short EncodeProvisionSS(unsigned char *msg, short *i, T_SUBSC_IE_PROVISION_SS *ss)
+{
+ int j, num;
+ msg[(*i)++] = SUBSC_INFO_IE_PROVISION_SS;
+ num = msg[(*i)++] = (unsigned char)ss->num_srv;
+ if(num > MAX_NUM_SUPP_SERVICE){
+ printf("Err. supp service number too large : %d\n", num);
+ return SUBSC_INFO_ERR_SS_NUM_SRV;
+ }
+ for(j=0;j<num;j++) msg[(*i)++] = ss->ss_code[j];
+ return 0;
+}
+
+short EncodeStatusFlag(unsigned char *msg, short *i, T_SUBSC_IE_SUBSC_STATUS *status)
+{
+ msg[(*i)++] = SUBSC_INFO_IE_SUBSC_STATUS;
+ msg[(*i)++] = (unsigned char)status->status;
+ return 0;
+}
+
+short EncodeODBData(unsigned char *msg, short *i, T_SUBSC_IE_ODB_DATA *odb_data)
+{
+ msg[(*i)++] = SUBSC_INFO_IE_ODB_DATA;
+ msg[(*i)++] = 0; // reserved
+ msg[(*i)++] = 0; // reserved
+ msg[(*i)++] = 0 |
+ ((odb_data->odb_general.multiple_ect_barred & 0x01) << ODB_GEN_BIT_MULTI_ECT) |
+ ((odb_data->odb_general.double_chargeable_ect_barred & 0x01) << ODB_GEN_BIT_DBL_CHARGE_ECT) |
+ ((odb_data->odb_general.intrz_ect_barred & 0x01) << ODB_GEN_BIT_INTRZ_ECT) |
+ ((odb_data->odb_general.intrn_ect_barred & 0x01) << ODB_GEN_BIT_INTRN_ECT) |
+ ((odb_data->odb_general.chargeable_ect_barred & 0x01) << ODB_GEN_BIT_CHARGE_ECT) |
+ ((odb_data->odb_general.all_ect_barred & 0x01) << ODB_GEN_BIT_ALL_ECT) |
+ ((odb_data->odb_general.intrz_intrn_og_not_hplmn_barred & 0x01) << ODB_GEN_BIT_INTRZ_INTRN_NOT_HPLMN);
+
+ msg[(*i)++] = 0 |
+ ((odb_data->odb_general.intrz_og_not_hplmn_barred & 0x01) << ODB_GEN_BIT_INTRZ_OG_NOT_HPLMN) |
+ ((odb_data->odb_general.intrz_og_barred & 0x01) << ODB_GEN_BIT_INTRZ_OG) |
+ ((odb_data->odb_general.ss_access_barred & 0x01) << ODB_GEN_BIT_SS_ACCESS) |
+ ((odb_data->odb_general.premium_enter_og_barred & 0x01) << ODB_GEN_BIT_PREM_ENT) |
+ ((odb_data->odb_general.premium_info_og_barred & 0x01) << ODB_GEN_BIT_PREM_INFO) |
+ ((odb_data->odb_general.intrn_og_not_hplmn_barred & 0x01) << ODB_GEN_BIT_INTRN_OG_NOT_HPLMN) |
+ ((odb_data->odb_general.intrn_og_barred & 0x01) << ODB_GEN_BIT_INTRN_OG) |
+ ((odb_data->odb_general.all_og_barred & 0x01) << ODB_GEN_BIT_ALL_OG);
+
+ msg[(*i)++] = 0; // reserved
+ msg[(*i)++] = 0; // reserved
+ msg[(*i)++] = 0; // reserved
+ msg[(*i)++] = 0 |
+ ((odb_data->odb_plmn.plmn_specific_type4 & 0x01) << ODB_HPLMN_BIT_TYPE_4) |
+ ((odb_data->odb_plmn.plmn_specific_type3 & 0x01) << ODB_HPLMN_BIT_TYPE_3) |
+ ((odb_data->odb_plmn.plmn_specific_type2 & 0x01) << ODB_HPLMN_BIT_TYPE_2) |
+ ((odb_data->odb_plmn.plmn_specific_type1 & 0x01) << ODB_HPLMN_BIT_TYPE_1);
+
+ return 0;
+}
+
+short EncodeBasicServiceCode(unsigned char *msg, short *i,
+ T_SUBSC_INFO_EXT_BASIC_SERVICE *basic_service)
+{
+ int j;
+ msg[(*i)++] = basic_service->service_type;
+ switch(basic_service->service_type){
+ case BEARER_SERVICE_TYPE:
+ for(j=0;j<5;j++) msg[(*i)++] = basic_service->ex_bs_code[j];
+ break;
+ case TELE_SERVICE_TYPE:
+ for(j=0;j<5;j++) msg[(*i)++] = basic_service->ex_ts_code[j];
+ break;
+ default:
+ printf("Unknown Basic Service Type :%d\n", basic_service->service_type);
+ return SUBSC_INFO_ERR_UNKNOWN_BASIC;
+ }
+ return 0;
+}
+
+short EncodeSSStatus(unsigned char *msg, short *i,
+ T_SS_STATUS_FLAG *ss_status)
+{
+ msg[(*i)++] = 0 |
+ ((ss_status->ss_status_A & 0x01) << SS_STATUS_A_BIT) |
+ ((ss_status->ss_status_R & 0x01) << SS_STATUS_R_BIT) |
+ ((ss_status->ss_status_P & 0x01) << SS_STATUS_P_BIT) |
+ ((ss_status->ss_status_Q & 0x01) << SS_STATUS_Q_BIT);
+ return 0;
+}
+
+short EncodeSSSubscOption(unsigned char *msg, short *i, T_SS_SUBSC_OPTION *ss_subsc_option) // 2.1.1
+{
+ if (ss_subsc_option->isPresent==false)
+ {
+ msg[(*i)++] = 0;
+ return 0;
+ }
+
+ msg[(*i)++] = 1;
+ msg[(*i)++] = (unsigned char) ss_subsc_option->option_type;
+
+ switch(ss_subsc_option->option_type)
+ {
+ case SS_SUBSC_OPTION_CLIR_OPTION:
+ msg[(*i)++] = (unsigned char) ss_subsc_option->clir_option;
+ break;
+
+ case SS_SUBSC_OPTION_OVERRIDE_CATEGORY:
+ msg[(*i)++] = (unsigned char) ss_subsc_option->override_category;
+ break;
+
+ default:
+ printf("Unsupported SS Subscription Option Type : %d\n", ss_subsc_option->option_type);
+ printf("msg index value: %d\n", *i);
+ return SUBSC_INFO_ERR_SS_SUBSC_OPTION;
+ }
+
+ return 0;
+}
+
+short EncodeForwOption(unsigned char *msg, short *i,
+ T_SS_FORW_OPTION *forw)
+{
+ msg[(*i)++] = 0 |
+ ((forw->notify_forw_party & 0x01) << SS_NOTIFY_FORW_FLAG_BIT) |
+ ((forw->notify_calling_party & 0x01)<< SS_NOTIFY_CALLING_FLAG_BIT) |
+ ((forw->forw_reason & 0x03) << SS_FORW_REASON_FLAG_BIT);
+ return 0;
+}
+
+short EncodeSSInfoForw(unsigned char *msg, short *i, T_SUBSC_IE_SS_INFO_FORW *forw)
+{
+ int j, num;
+ msg[(*i)++] = (unsigned char)forw->ss_code;
+ num = msg[(*i)++] = (unsigned char)forw->num_feature;
+ if(num > MAX_NUM_EXT_FEATURE){
+ printf("Err. forw feature number too large : %d\n", num);
+ return SUBSC_INFO_ERR_FORW_NUM_FEATURE;
+ }
+ for(j=0; j<num; j++){
+ EncodeBasicServiceCode(msg, i, &forw->list[j].basic_service);
+ EncodeSSStatus(msg, i, &forw->list[j].ss_status);
+ EncodeISDN(msg, i, &forw->list[j].forw_to_num);
+ EncodeSubAddr(msg, i, &forw->list[j].forw_to_sub);
+ EncodeForwOption(msg, i, &forw->list[j].forw_options);
+ msg[(*i)++] = (unsigned char)forw->list[j].no_reply_cond_time;
+ }
+ return 0;
+}
+
+short EncodeSSInfoBar(unsigned char *msg, short *i, T_SUBSC_IE_SS_INFO_BAR *bar)
+{
+ int j, num;
+ msg[(*i)++] = (unsigned char)bar->ss_code;
+ num = msg[(*i)++] = (unsigned char)bar->num_feature;
+ if(num > MAX_NUM_EXT_FEATURE){
+ printf("Err. bar feature number too large : %d\n", num);
+ return SUBSC_INFO_ERR_BAR_NUM_FEATURE;
+ }
+ for(j=0; j<num; j++){
+ EncodeBasicServiceCode(msg, i, &bar->list[j].basic_service);
+ EncodeSSStatus(msg, i, &bar->list[j].ss_status);
+ }
+ return 0;
+}
+
+short EncodeSSInfoData(unsigned char *msg, short *i, T_SUBSC_IE_SS_INFO_DATA *data) // 2.0.5
+{
+ msg[(*i)++] = (unsigned char)data->ss_code;
+ EncodeSSStatus(msg, i, &data->ss_status);
+ EncodeSSSubscOption(msg, i, &data->ss_subsc_option); // 2.1.1
+ return 0;
+}
+
+short EncodeSSInfo(unsigned char *msg, short *i, T_SUBSC_IE_SS_INFO *ss_info)
+{
+ msg[(*i)++] = (unsigned char)ss_info->info_type;
+ switch(ss_info->info_type){
+ case SUBSC_IE_SS_INFO_FORW_TYPE:
+ EncodeSSInfoForw(msg, i, &ss_info->info_forw);
+ break;
+ case SUBSC_IE_SS_INFO_BARR_TYPE:
+ EncodeSSInfoBar(msg, i, &ss_info->info_bar);
+ break;
+ case SUBSC_IE_SS_INFO_DATA_TYPE: // 2.0.5
+ EncodeSSInfoData(msg, i, &ss_info->info_data);
+ break;
+ default:
+ printf("Unsupported SS Info Type encountered :%d\n", ss_info->info_type);
+ return SUBSC_INFO_ERR_SS_INFO_TYPE;
+ }
+ return 0;
+}
+
+short EncodeSSInfoList(unsigned char *msg, short *i, T_SUBSC_IE_SS_INFO_LIST *ss_info_list)
+{
+ int j, num;
+ short ret;
+ msg[(*i)++] = SUBSC_INFO_IE_SS_INFO_LIST;
+ num = msg[(*i)++] = (unsigned char)ss_info_list->num_ss_info;
+ if(num > MAX_NUM_SUPP_SERVICE){
+ printf("Err. ss info list number too large : %d\n", num);
+ return SUBSC_INFO_ERR_SS_NUM_INFO;
+ }
+ for(j=0; j<SS_INFO_IND_FORW_MAX; j++){
+ msg[(*i)++] = (unsigned char)SUBSC_IE_SS_INFO_FORW_TYPE;
+ ret = EncodeSSInfoForw(msg, i, &ss_info_list->ss_info_forw[j]);
+ if(ret) return ret;
+ }
+ for(j=0; j<SS_INFO_IND_DATA_MAX; j++){
+ msg[(*i)++] = (unsigned char)SUBSC_IE_SS_INFO_DATA_TYPE;
+ ret = EncodeSSInfoData(msg, i, &ss_info_list->ss_info_data[j]);
+ if(ret) return ret;
+ }
+ for(j=0; j<SS_INFO_IND_BAR_MAX; j++){
+ msg[(*i)++] = (unsigned char)SUBSC_IE_SS_INFO_BARR_TYPE;
+ ret = EncodeSSInfoBar(msg, i, &ss_info_list->ss_info_bar[j]);
+ if(ret) return ret;
+ }
+ return 0;
+}
+
+short EncodeUserInfo(unsigned char *msg, short *i, T_SUBSC_IE_USER_INFO *user)
+{
+ int j, num;
+
+ msg[(*i)++] = SUBSC_INFO_IE_USER_INFO;
+ num = msg[(*i)++] = (unsigned char)user->len;
+ if(num > MAX_NUM_USER_INFO){
+ printf("Err. user info too large: %d\n", num);
+ return SUBSC_INFO_ERR_USER_INFO;
+ }
+ for(j=0; j<num; j++){
+ msg[(*i)++] = user->name[j];
+ }
+ return 0;
+}
+
+short EncodeGPRSData(unsigned char *msg, short *i, T_SUBSC_GPRS_DATA *data)
+{
+ int j, num;
+
+ msg[(*i)++] = data->pdpContextId;
+ msg[(*i)++] = (unsigned char)data->pdpType;
+ for(j=0; j<MAX_LEN_SUBSC_PDP_ADDR; j++)
+ msg[(*i)++] = data->pdpAddress[j];
+ msg[(*i)++] = (unsigned char)data->qosSubscribed.delay_class;
+ msg[(*i)++] = (unsigned char)data->qosSubscribed.reliability_class;
+ msg[(*i)++] = (unsigned char)data->qosSubscribed.precedence_class;
+ msg[(*i)++] = (unsigned char)data->qosSubscribed.peak_throughput;
+ msg[(*i)++] = (unsigned char)data->qosSubscribed.mean_throughput;
+ msg[(*i)++] = data->vplmnAddressAllowed;
+ num = msg[(*i)++] = data->apn_length;
+ if(num > MAX_LEN_SUBSC_APN){
+ printf("Err. apn length too large: %d\n", num);
+ return SUBSC_INFO_ERR_APN_LEN;
+ }
+ for(j=0; j<num; j++)
+ msg[(*i)++] = data->apn[j];
+ return 0;
+}
+
+short EncodeGPRSDataInfo(unsigned char *msg, short *i, T_SUBSC_IE_GPRS_DATA_INFO *gprs_data)
+{
+ int j, num;
+ short ret;
+
+ msg[(*i)++] = SUBSC_INFO_IE_GPRS_DATA;
+ num = msg[(*i)++] = (unsigned char)gprs_data->num_data;
+ if(num > MAX_NUM_SUBSC_GPRS_DATA){
+ printf("Err. gprs data too many: %d\n", num);
+ return SUBSC_INFO_ERR_GPRS_DATA_LEN;
+ }
+ for(j=0; j<num; j++){
+ ret = EncodeGPRSData(msg, i, &gprs_data->data[j]);
+ if(ret) return ret;
+ }
+ return 0;
+}
+
+// EncodeSubscInfo or DecodeSubscInfo does not allocate memory spaces
+// for message buffer nor subsc info sturcture. It should be allocated
+// prior to the calls and pass pointer to the functions.
+
+// Encode SubscInfo to Message Buffer (Byte Stream) provided.
+// size - size of msg buffer, returned with actual used size
+bool dbgEncodeSubscInfoFlag = false;
+
+extern "C" void dbgEncodeSubscInfoFlagToggle(void)
+{
+ dbgEncodeSubscInfoFlag = !dbgEncodeSubscInfoFlag;
+ printf("[dbgEncodeSubscInfoFlagToggle] debugging is %s\n",
+ (dbgEncodeSubscInfoFlag)? "enabled" : "disabled");
+}
+
+short EncodeSubscInfo(unsigned char *msg,
+ short *size,
+ T_SUBSC_INFO *subsc)
+{
+ short i = 0;
+ short ret;
+
+ if (dbgEncodeSubscInfoFlag)
+ {
+ printf("[EncodeSubscInfo] \n");
+ subscPrintInfo(subsc);
+ }
+
+ if(ret = EncodeVersionNumber(msg, &i)) return ret;
+ if(ret = EncodeMobileId(msg, &i, &subsc->imsi)) return ret;
+ if(ret = EncodeISDN(msg, &i, &subsc->msisdn)) return ret;
+ if(ret = EncodeProvisionBS(msg, &i, &subsc->prov_bs)) return ret;
+ if(ret = EncodeProvisionTS(msg, &i, &subsc->prov_ts)) return ret;
+ if(ret = EncodeProvisionSS(msg, &i, &subsc->prov_ss)) return ret;
+ if(ret = EncodeStatusFlag(msg, &i, &subsc->status)) return ret;
+ if(ret = EncodeODBData(msg, &i, &subsc->odb_data)) return ret;
+ if(ret = EncodeSSInfoList(msg, &i, &subsc->ss_info_list)) return ret;
+ if(ret = EncodeUserInfo(msg, &i, &subsc->user)) return ret;
+ if(ret = EncodeGPRSDataInfo(msg, &i, &subsc->gprs_data)) return ret;
+ *size = i;
+
+ return 0;
+}
+
+
+short EncodeAuthTriplet(unsigned char *msg, short *i, T_AUTH_TRIPLET *triplet)
+{
+ int j;
+ for(j=0; j<SEC_RAND_LEN; j++){ msg[(*i)++] = triplet->RAND[j]; }
+ for(j=0; j<SEC_SRES_LEN; j++){ msg[(*i)++] = triplet->SRES[j]; }
+ for(j=0; j<SEC_KC_LEN; j++){ msg[(*i)++] = triplet->Kc[j]; }
+ return 0;
+}
+
+short EncodeAuthList(unsigned char *msg, short *i, T_SEC_IE_AUTH_LIST *auth_set)
+{
+ int j, num;
+ short ret;
+ msg[(*i)++] = SUBSC_INFO_IE_AUTH_LIST;
+ num = msg[(*i)++] = (unsigned char)auth_set->num_set;
+ if(num > SEC_MAX_TRIPLET){
+ printf("Err. auth triplet list number too large : %d\n", num);
+ return SUBSC_INFO_ERR_AUTH_NUM_LIST;
+ }
+ for(j=0; j<num; j++){
+ ret = EncodeAuthTriplet(msg, i, &auth_set->triplet[j]);
+ if(ret) return ret;
+ }
+ return 0;
+}
+
+// EncodeSecInfo or DecodeSecInfo does not allocate memory spaces
+// for message buffer nor sec info sturcture. It should be allocated
+// prior to the calls and pass pointer to the functions.
+
+// Encode SecInfo to Message Buffer (Byte Stream) provided.
+// size - size of msg buffer, returned with actual used size
+short EncodeSecInfo(unsigned char *msg,
+ short *size,
+ T_SEC_INFO *sec)
+{
+ short i = 0;
+ short ret;
+
+ if((ret = EncodeMobileId(msg, &i, &sec->imsi))) return ret;
+ if((ret = EncodeAuthList(msg, &i, &sec->auth_set))) return ret;
+ *size = i;
+ return 0;
+}
+
diff --git a/data/mnet/Common/subsc/src/SubscInfoUtil.cpp b/data/mnet/Common/subsc/src/SubscInfoUtil.cpp
new file mode 100644
index 0000000..ef2e3f3
--- /dev/null
+++ b/data/mnet/Common/subsc/src/SubscInfoUtil.cpp
@@ -0,0 +1,1814 @@
+// *******************************************************************
+//
+// (c) Copyright Cisco 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// Status : Under development
+// File : SubscInfoUtil.cpp
+// Author(s) : Kevin Lim
+// Create Date : 06-16-99
+// Description : subscriber information structure and en/decoding function
+// for messages
+//
+// *******************************************************************
+#include "stdio.h"
+#include "string.h"
+#include "subsc/SubscInfoType.h"
+#include "subsc/SubscInfoUtil.h"
+
+//*****************************************************************************
+T_SUBSC_IE_MOBILE_ID_IMSI* subscGetMobileIdPtr(T_SUBSC_INFO *info)
+{
+ if(info != 0) return(&info->imsi);
+ else return 0;
+}
+
+//*****************************************************************************
+T_SUBSC_IE_ISDN* subscGetMSISDNPtr(T_SUBSC_INFO *info)
+{
+ if(info != 0) return(&info->msisdn);
+ else return 0;
+}
+
+//*****************************************************************************
+T_SUBSC_IE_PROVISION_BS* subscGetProvBSPtr(T_SUBSC_INFO *info)
+{
+ if(info != 0) return(&info->prov_bs);
+ else return 0;
+}
+
+//*****************************************************************************
+T_SUBSC_IE_PROVISION_TS* subscGetProvTSPtr(T_SUBSC_INFO *info)
+{
+ if(info != 0) return(&info->prov_ts);
+ else return 0;
+}
+
+//*****************************************************************************
+T_SUBSC_IE_PROVISION_SS* subscGetProvSSPtr(T_SUBSC_INFO *info)
+{
+ if(info != 0) return(&info->prov_ss);
+ else return 0;
+}
+
+//*****************************************************************************
+T_SUBSC_IE_SUBSC_STATUS* subscGetSubscStatusPtr(T_SUBSC_INFO *info)
+{
+ if(info != 0) return(&info->status);
+ else return 0;
+}
+
+//*****************************************************************************
+T_SUBSC_IE_ODB_DATA* subscGetODBDataPtr(T_SUBSC_INFO *info)
+{
+ if(info != 0) return(&info->odb_data);
+ else return 0;
+}
+
+//*****************************************************************************
+T_SUBSC_IE_SS_INFO_LIST* subscGetSSInfoListPtr(T_SUBSC_INFO *info)
+{
+ if(info != 0) return(&info->ss_info_list);
+ else return 0;
+}
+
+//*****************************************************************************
+T_SUBSC_IE_USER_INFO* subscGetUserInfoPtr(T_SUBSC_INFO *info)
+{
+ if(info != 0) return(&info->user);
+ else return 0;
+}
+
+//*****************************************************************************
+T_SUBSC_IE_GPRS_DATA_INFO* subscGetGPRSDataPtr(T_SUBSC_INFO *info)
+{
+ if(info != 0) return(&info->gprs_data);
+ else return 0;
+}
+
+//*****************************************************************************
+// [jihoon 07/13/01]
+// 1. 'subscGetCLIROption' added
+// 2. When success, it returns 0 and the CLIR option through 'option'.
+// 3. When fails, it return non-zero.
+// 4. Fail cases include null 'info', CLIR not provisioned, no index for SUPP_SERV_CLIR,
+// CLIR option not present, or wrong option type.
+int subscGetCLIROption(T_SUBSC_INFO *info, T_SS_SUBSC_CLIR_OPTION *option) // 2.1.1
+{
+ if (info == 0) return -1;
+
+ T_SUBSC_IE_SS_INFO_LIST *info_list = subscGetSSInfoListPtr(info);
+ if (subscGetP(info_list, SUPP_SERV_CLIR) == 0) return -2; // not provisioned
+
+ int ind = subscGetSSInfoDataInd(SUPP_SERV_CLIR);
+ if(ind == -1) return -3;
+ T_SS_SUBSC_OPTION* subsc_option = &info_list->ss_info_data[ind].ss_subsc_option;
+
+ if (subsc_option->isPresent==false) return -4;
+ if (subsc_option->option_type!=SS_SUBSC_OPTION_CLIR_OPTION) return -5;
+
+ *option = subsc_option->clir_option;
+
+ return 0; // success
+}
+
+//*****************************************************************************
+// [jihoon 07/13/01]
+// 1. 'subscSetCLIROption' added
+// 2. When success, it returns 0.
+// 3. When fails, it return non-zero.
+// 4. Fail cases include null 'info', no index for SUPP_SERV_CLIR, 'option' of wrong value.
+int subscSetCLIROption(T_SUBSC_INFO *info, T_SS_SUBSC_CLIR_OPTION option) // 2.1.1
+{
+ if (info == 0) return -1;
+
+ T_SUBSC_IE_SS_INFO_LIST *info_list = subscGetSSInfoListPtr(info);
+
+ int ind = subscGetSSInfoDataInd(SUPP_SERV_CLIR);
+ if(ind == -1) return -2;
+ T_SS_SUBSC_OPTION* subsc_option = &info_list->ss_info_data[ind].ss_subsc_option;
+
+ switch(option)
+ {
+ case CLIR_PERMANENT:
+ case CLIR_TEMP_DFT_RESTRICTED:
+ case CLIR_TEMP_DFT_ALLOWED:
+ subsc_option->isPresent = true;
+ subsc_option->option_type = SS_SUBSC_OPTION_CLIR_OPTION;
+ subsc_option->clir_option = option;
+ break;
+
+ default:
+ return -3;
+ }
+
+
+ return 0; // success
+}
+
+//*****************************************************************************
+//*****************************************************************************
+/*
+T_SUBSC_IE_SS_INFO* subscGetSSInfoPtr(T_SUBSC_INFO *info,
+ T_SUBSC_SS_INFO_INDEX ind)
+{
+ if(info == 0) return 0;
+ T_SUBSC_IE_SS_INFO_LIST *info_list = subscGetSSInfoListPtr(info);
+ if(info_list == 0) return 0;
+ return( &info_list->ss_info[ind]);
+}
+*/
+//*****************************************************************************
+bool subscIsProvCLIP(T_SUBSC_INFO *info)
+{
+ if(info == 0) return 0;
+ T_SUBSC_IE_SS_INFO_LIST *info_list = subscGetSSInfoListPtr(info);
+ return (subscGetP(info_list, SUPP_SERV_CLIP) == 1);
+}
+
+//*****************************************************************************
+bool subscIsProvCLIR(T_SUBSC_INFO *info)
+{
+ if(info == 0) return 0;
+ T_SUBSC_IE_SS_INFO_LIST *info_list = subscGetSSInfoListPtr(info);
+ return (subscGetP(info_list, SUPP_SERV_CLIR) == 1);
+}
+
+//*****************************************************************************
+bool subscIsProvCOLP(T_SUBSC_INFO *info)
+{
+ if(info == 0) return 0;
+ T_SUBSC_IE_SS_INFO_LIST *info_list = subscGetSSInfoListPtr(info);
+ return (subscGetP(info_list, SUPP_SERV_COLP) == 1);
+}
+
+//*****************************************************************************
+bool subscIsProvCOLR(T_SUBSC_INFO *info)
+{
+ if(info == 0) return 0;
+ T_SUBSC_IE_SS_INFO_LIST *info_list = subscGetSSInfoListPtr(info);
+ return (subscGetP(info_list, SUPP_SERV_COLR) == 1);
+}
+
+//*****************************************************************************
+bool subscIsProvCFU(T_SUBSC_INFO *info)
+{
+ if(info == 0) return 0;
+ T_SUBSC_IE_SS_INFO_LIST *info_list = subscGetSSInfoListPtr(info);
+ return (subscGetP(info_list, SUPP_SERV_CFU) == 1);
+}
+
+//*****************************************************************************
+bool subscIsProvCFB(T_SUBSC_INFO *info)
+{
+ if(info == 0) return 0;
+ T_SUBSC_IE_SS_INFO_LIST *info_list = subscGetSSInfoListPtr(info);
+ return (subscGetP(info_list, SUPP_SERV_CFB) == 1);
+}
+
+//*****************************************************************************
+bool subscIsProvCFNRY(T_SUBSC_INFO *info)
+{
+ if(info == 0) return 0;
+ T_SUBSC_IE_SS_INFO_LIST *info_list = subscGetSSInfoListPtr(info);
+ return (subscGetP(info_list, SUPP_SERV_CFNRY) == 1);
+}
+
+//*****************************************************************************
+bool subscIsProvCFNRC(T_SUBSC_INFO *info)
+{
+ if(info == 0) return 0;
+ T_SUBSC_IE_SS_INFO_LIST *info_list = subscGetSSInfoListPtr(info);
+ return (subscGetP(info_list, SUPP_SERV_CFNRC) == 1);
+}
+
+//*****************************************************************************
+bool subscIsProvECT(T_SUBSC_INFO *info)
+{
+ if(info == 0) return 0;
+ T_SUBSC_IE_SS_INFO_LIST *info_list = subscGetSSInfoListPtr(info);
+ return (subscGetP(info_list, SUPP_SERV_ECT) == 1);
+}
+
+//*****************************************************************************
+bool subscIsProvCW(T_SUBSC_INFO *info)
+{
+ if(info == 0) return 0;
+ T_SUBSC_IE_SS_INFO_LIST *info_list = subscGetSSInfoListPtr(info);
+ return (subscGetP(info_list, SUPP_SERV_CW) == 1);
+}
+
+//*****************************************************************************
+bool subscIsProvHOLD(T_SUBSC_INFO *info)
+{
+ if(info == 0) return 0;
+ T_SUBSC_IE_SS_INFO_LIST *info_list = subscGetSSInfoListPtr(info);
+ return (subscGetP(info_list, SUPP_SERV_HOLD) == 1);
+}
+
+//*****************************************************************************
+bool subscIsProvMPTY(T_SUBSC_INFO *info)
+{
+ if(info == 0) return 0;
+ T_SUBSC_IE_SS_INFO_LIST *info_list = subscGetSSInfoListPtr(info);
+ return (subscGetP(info_list, SUPP_SERV_MPTY) == 1);
+}
+
+//*****************************************************************************
+bool subscIsProvBAOC(T_SUBSC_INFO *info)
+{
+ if(info == 0) return 0;
+ T_SUBSC_IE_SS_INFO_LIST *info_list = subscGetSSInfoListPtr(info);
+ return (subscGetP(info_list, SUPP_SERV_BAOC) == 1);
+}
+
+//*****************************************************************************
+bool subscIsProvBOIC(T_SUBSC_INFO *info)
+{
+ if(info == 0) return 0;
+ T_SUBSC_IE_SS_INFO_LIST *info_list = subscGetSSInfoListPtr(info);
+ return (subscGetP(info_list, SUPP_SERV_BOIC) == 1);
+}
+
+//*****************************************************************************
+bool subscIsProvBOICE(T_SUBSC_INFO *info)
+{
+ if(info == 0) return 0;
+ T_SUBSC_IE_SS_INFO_LIST *info_list = subscGetSSInfoListPtr(info);
+ return (subscGetP(info_list, SUPP_SERV_BOICE) == 1);
+}
+
+//*****************************************************************************
+bool subscIsProvBAIC(T_SUBSC_INFO *info)
+{
+ if(info == 0) return 0;
+ T_SUBSC_IE_SS_INFO_LIST *info_list = subscGetSSInfoListPtr(info);
+ return (subscGetP(info_list, SUPP_SERV_BAIC) == 1);
+}
+
+//*****************************************************************************
+bool subscIsProvBICRoam(T_SUBSC_INFO *info)
+{
+ if(info == 0) return 0;
+ T_SUBSC_IE_SS_INFO_LIST *info_list = subscGetSSInfoListPtr(info);
+ return (subscGetP(info_list, SUPP_SERV_BIC_ROAM) == 1);
+}
+
+//*****************************************************************************
+T_SUBSC_FORW_FEATURE* subscGetForwFeature(T_SUBSC_IE_SS_INFO_LIST *ss_info_list,
+ T_SUBSC_INFO_SUPP_SERVICE_CODE ss_code)
+{
+ if(ss_info_list == 0) return 0;
+ int i, j;
+ i = subscGetSSInfoForwInd(ss_code);
+ int num_feature = ss_info_list->ss_info_forw[i].num_feature;
+ for(j=0; j<num_feature; j++){
+ // check for BS here
+ // for now just one
+ return(&ss_info_list->ss_info_forw[i].list[j]);
+ }
+ return 0;
+}
+
+//*****************************************************************************
+bool subscIsActiveCF(T_SUBSC_IE_SS_INFO_LIST *ss_info_list,
+ T_SUBSC_INFO_SUPP_SERVICE_CODE ss_code)
+{
+ return (subscGetA(ss_info_list, ss_code) == 1);
+}
+
+//*****************************************************************************
+bool subscIsActiveCW(T_SUBSC_IE_SS_INFO_LIST *ss_info_list)
+{
+ return (subscGetA(ss_info_list, SUPP_SERV_CW) == 1);
+}
+
+//*****************************************************************************
+int subscGetTimerCFNRY(T_SUBSC_IE_SS_INFO_LIST *ss_info_list)
+{
+ if(ss_info_list == 0) return -1;
+ T_SUBSC_FORW_FEATURE* feature = subscGetForwFeature(ss_info_list, SUPP_SERV_CFNRY);
+ if(feature == 0) return -1;
+ else return feature->no_reply_cond_time;
+}
+
+//*****************************************************************************
+// print
+//*****************************************************************************
+void subscPrintImsi(T_SUBSC_IE_MOBILE_ID_IMSI *imsi)
+{
+ if(imsi == 0) return;
+ int i;
+ for(i=0; i<imsi->num_digit; i++) printf("%c", imsi->imsi[i]);
+}
+
+//*****************************************************************************
+void subscPrintIsdn(T_SUBSC_IE_ISDN *msisdn)
+{
+ if(msisdn == 0) return;
+ int i;
+ int num_digit = (msisdn->num_digit > MAX_NUM_SUBSC_ISDN)?
+ MAX_NUM_SUBSC_ISDN: msisdn->num_digit;
+ for(i=0; i<num_digit; i++)
+ printf("%c", msisdn->digits[i]);
+}
+
+//*****************************************************************************
+void subscPrintProvBS(T_SUBSC_IE_PROVISION_BS *prov_bs)
+{
+ if(prov_bs == 0) return;
+ int i;
+ int num_srv = (prov_bs->num_srv > MAX_NUM_BEARER_SERVICE)?
+ MAX_NUM_BEARER_SERVICE: prov_bs->num_srv;
+ for(i=0; i<num_srv; i++)
+ printf("%s,", getSubscInfoBSCodeStr(prov_bs->bs_code[i]));
+}
+
+//*****************************************************************************
+void subscPrintProvTS(T_SUBSC_IE_PROVISION_TS *prov_ts)
+{
+ if(prov_ts == 0) return;
+ int i;
+ int num_srv = (prov_ts->num_srv > MAX_NUM_TELE_SERVICE)?
+ MAX_NUM_TELE_SERVICE: prov_ts->num_srv;
+ for(i=0; i<num_srv; i++)
+ printf("%s,", getSubscInfoTSCodeStr(prov_ts->ts_code[i]));
+}
+
+//*****************************************************************************
+void subscPrintProvSS(T_SUBSC_IE_PROVISION_SS *prov_ss)
+{
+ if(prov_ss == 0) return;
+ int i;
+ int num_srv = (prov_ss->num_srv > MAX_NUM_SUPP_SERVICE)?
+ MAX_NUM_SUPP_SERVICE: prov_ss->num_srv;
+ for(i=0; i<num_srv; i++)
+ printf("%s,", getSubscInfoSSCodeStr(prov_ss->ss_code[i]));
+}
+
+//*****************************************************************************
+void subscPrintSubscStatus(T_SUBSC_IE_SUBSC_STATUS *status)
+{
+ if(status == 0) return;
+ printf("%d", status->status);
+}
+
+//*****************************************************************************
+void subscPrintODBData(T_SUBSC_IE_ODB_DATA *odb_data)
+{
+ if(odb_data == 0) return;
+ printf(" ODB General: \n");
+ printf(" all og barred :%d\n", odb_data->odb_general.all_og_barred);
+ printf(" intrn og barred :%d\n", odb_data->odb_general.intrn_og_barred);
+ printf(" intrn og not hplmn barred :%d\n", odb_data->odb_general.intrn_og_not_hplmn_barred);
+ printf(" premium info og barred :%d\n", odb_data->odb_general.premium_info_og_barred);
+ printf(" premium enter og barred :%d\n", odb_data->odb_general.premium_enter_og_barred);
+ printf(" ss access barred :%d\n", odb_data->odb_general.ss_access_barred);
+ printf(" intrz og barred :%d\n", odb_data->odb_general.intrz_og_barred);
+ printf(" intrz og not hplmn barred :%d\n", odb_data->odb_general.intrz_og_not_hplmn_barred);
+ printf(" intrz intrn og not hplmn barr:%d\n", odb_data->odb_general.intrz_intrn_og_not_hplmn_barred);
+ printf(" all ect barred :%d\n", odb_data->odb_general.all_ect_barred);
+ printf(" chargeable ect barred :%d\n", odb_data->odb_general.chargeable_ect_barred);
+ printf(" intrn ect barred :%d\n", odb_data->odb_general.intrn_ect_barred);
+ printf(" intrz ect barred :%d\n", odb_data->odb_general.intrz_ect_barred);
+ printf(" double chargeable ect barred :%d\n", odb_data->odb_general.double_chargeable_ect_barred);
+ printf(" multiple ect barred :%d\n", odb_data->odb_general.multiple_ect_barred);
+ printf(" ODB PLMN specific: \n");
+ printf(" type 1 :%d\n", odb_data->odb_plmn.plmn_specific_type1);
+ printf(" type 2 :%d\n", odb_data->odb_plmn.plmn_specific_type2);
+ printf(" type 3 :%d\n", odb_data->odb_plmn.plmn_specific_type3);
+ printf(" type 4 :%d\n", odb_data->odb_plmn.plmn_specific_type4);
+}
+
+//*****************************************************************************
+void subscPrintSSStatus(T_SS_STATUS_FLAG *ss_status)
+{
+ printf("ss status - A: %d, R: %d, P: %d, Q: %d\n", ss_status->ss_status_A,
+ ss_status->ss_status_R,
+ ss_status->ss_status_P,
+ ss_status->ss_status_Q);
+}
+
+//*****************************************************************************
+void subscPrintSSSubscOption(T_SS_SUBSC_OPTION *ss_subsc_option) // 2.1.1
+{
+ if (!ss_subsc_option->isPresent) return; // nothing to print
+
+ printf(" SS SUBSC OPTION \n");
+ switch(ss_subsc_option->option_type)
+ {
+ case SS_SUBSC_OPTION_CLIR_OPTION:
+ printf(" CLIR Option :%d\n",ss_subsc_option->clir_option);
+ break;
+
+ case SS_SUBSC_OPTION_OVERRIDE_CATEGORY:
+ printf(" Override Category :%d\n",ss_subsc_option->override_category);
+ break;
+
+ default:
+ printf(" Unknown Option Type :%d\n",ss_subsc_option->option_type);
+ }
+}
+
+//*****************************************************************************
+void subscPrintSSInfoForw(T_SUBSC_IE_SS_INFO_FORW *info_forw)
+{
+ int j;
+ printf(" SS FORW INFO: \n");
+ printf(" ss code: %s\n", getSubscInfoSSCodeStr(info_forw->ss_code));
+ int num_feature = (info_forw->num_feature > MAX_NUM_EXT_FEATURE)?
+ MAX_NUM_EXT_FEATURE : info_forw->num_feature;
+ for(j=0; j<num_feature; j++){
+ printf(" feature[%d]\n", j);
+ printf(" basic service - service type: %d\n", info_forw->list[j].basic_service.service_type);
+ printf(" service code: 0x%02x\n", info_forw->list[j].basic_service.ex_bs_code[0]);
+ printf(" ");
+ subscPrintSSStatus(&info_forw->list[j].ss_status);
+ printf(" forward to num: ");
+ int num_digit = (info_forw->list[j].forw_to_num.num_digit > MAX_NUM_SUBSC_ISDN)?
+ MAX_NUM_SUBSC_ISDN: info_forw->list[j].forw_to_num.num_digit;
+ for(int k=0; k<num_digit; k++)
+ printf("%c", info_forw->list[j].forw_to_num.digits[k]);
+ printf("\n");
+ printf(" forward option: \n");
+ printf(" notify forwarding party: %d\n", info_forw->list[j].forw_options.notify_forw_party);
+ printf(" notify calling party: %d\n", info_forw->list[j].forw_options.notify_calling_party);
+ printf(" forwarding reason: %d\n", info_forw->list[j].forw_options.forw_reason);
+ printf(" no reply condition time: %d\n", info_forw->list[j].no_reply_cond_time);
+ }
+}
+
+//*****************************************************************************
+void subscPrintSSInfoBar(T_SUBSC_IE_SS_INFO_BAR *info_bar)
+{
+ int j;
+ printf(" SS BARR INFO: \n");
+ printf(" ss code: %s\n", getSubscInfoSSCodeStr(info_bar->ss_code));
+ int num_feature = (info_bar->num_feature > MAX_NUM_EXT_FEATURE)?
+ MAX_NUM_EXT_FEATURE : info_bar->num_feature;
+ for(j=0; j<num_feature; j++){
+ printf(" feature[%d]\n", j);
+ printf(" basic service - service type: %d\n", info_bar->list[j].basic_service.service_type);
+ printf(" service code: 0x%02x\n", info_bar->list[j].basic_service.ex_bs_code[0]);
+ printf(" ");
+ subscPrintSSStatus(&info_bar->list[j].ss_status);
+ }
+}
+
+//*****************************************************************************
+void subscPrintSSInfoData(T_SUBSC_IE_SS_INFO_DATA *info_data)
+{
+ printf(" SS DATA INFO: \n");
+ printf(" ss code: %s\n", getSubscInfoSSCodeStr(info_data->ss_code));
+ subscPrintSSStatus(&info_data->ss_status);
+ subscPrintSSSubscOption(&info_data->ss_subsc_option); // 2.1.1
+}
+
+//*****************************************************************************
+void subscPrintSSInfoList(T_SUBSC_IE_SS_INFO_LIST *ss_info_list)
+{
+ if(ss_info_list == 0) return;
+ int i;
+ for(i=0; i<SS_INFO_IND_FORW_MAX; i++){
+ printf("SS Forw Info[%d] \n", i);
+ subscPrintSSInfoForw(&ss_info_list->ss_info_forw[i]);
+ }
+ for(i=0; i<SS_INFO_IND_BAR_MAX; i++){
+ printf("SS Bar Info[%d] \n", i);
+ subscPrintSSInfoBar(&ss_info_list->ss_info_bar[i]);
+ }
+ for(i=0; i<SS_INFO_IND_DATA_MAX; i++){
+ printf("SS Data Info[%d] \n", i);
+ subscPrintSSInfoData(&ss_info_list->ss_info_data[i]);
+ }
+}
+
+//*****************************************************************************
+void subscPrintUserInfo(T_SUBSC_IE_USER_INFO *user)
+{
+ if(user == 0) return;
+ for(int i=0; i<user->len; i++){
+ printf("%c", user->name[i]);
+ }
+ printf("\n");
+}
+
+//*****************************************************************************
+void subscPrintPDPType(CNI_RIL3_PDP_ADDRESS_TYPE value)
+{
+ switch(value){
+ case CNI_RIL3_PDP_ADDRESS_TYPE_IETF_IPV4:
+ printf("IETF_IPV4\n");
+ break;
+ case CNI_RIL3_PDP_ADDRESS_TYPE_IETF_IPV6:
+ printf("IETF_IPV6\n");
+ break;
+ case CNI_RIL3_PDP_ADDRESS_TYPE_ETSI_X121:
+ printf("ETSI_X121\n");
+ break;
+ case CNI_RIL3_PDP_ADDRESS_TYPE_ETSI_PPP:
+ printf("ETSI_PPP\n");
+ break;
+ case CNI_RIL3_PDP_ADDRESS_TYPE_ETSI_OSP_IHOSS:
+ printf("ETSI_OSP_IHOSS\n");
+ break;
+ default: printf("Unknown :%d\n", value);
+ }
+}
+
+/*********************************************************************/
+void subscPrintQOSDelay(CNI_RIL3_QOS_DELAY_CLASS value)
+{
+ switch(value){
+ case CNI_RIL3_QOS_DELAY_CLASS_1:
+ printf("CLASS_1\n");
+ break;
+ case CNI_RIL3_QOS_DELAY_CLASS_2:
+ printf("CLASS_2\n");
+ break;
+ case CNI_RIL3_QOS_DELAY_CLASS_3:
+ printf("CLASS_3\n");
+ break;
+ case CNI_RIL3_QOS_DELAY_CLASS_4:
+ printf("CLASS_4\n");
+ break;
+ default: printf("Unknown :%d\n", value);
+ }
+}
+
+/*********************************************************************/
+void subscPrintQOSRely(CNI_RIL3_QOS_RELIABILITY_CLASS value)
+{
+ switch(value){
+ case CNI_RIL3_QOS_RELIABILITY_CLASS_ACK_GTP_LLC_RLC_PROTECTED_DATA:
+ printf("ACK_GTP_LLC_RLC_PROTECTED_DATA\n");
+ break;
+ case CNI_RIL3_QOS_RELIABILITY_CLASS_UNACK_GTP_ACK_LLC_RLC_PROTECTED_DATA:
+ printf("UNACK_GTP_ACK_LLC_RLC_PROTECTED_DATA\n");
+ break;
+ case CNI_RIL3_QOS_RELIABILITY_CLASS_UNACK_GTP_LLC_ACK_RLC_PROTECTED_DATA:
+ printf("UNACK_GTP_LLC_ACK_RLC_PROTECTED_DATA\n");
+ break;
+ case CNI_RIL3_QOS_RELIABILITY_CLASS_UNACK_GTP_LLC_RLC_PROTECTED_DATA:
+ printf("UNACK_GTP_LLC_RLC_ACK_PROTECTED_DATA\n");
+ break;
+ case CNI_RIL3_QOS_RELIABILITY_CLASS_UNACK_GTP_LLC_RLC_UNPROTECTED_DATA:
+ printf("UNACK_GTP_LLC_RLC_UNPROTECTED_DATA\n");
+ break;
+ default: printf("Unknown :%d\n", value);
+ }
+}
+
+/*********************************************************************/
+void subscPrintQOSPrec(CNI_RIL3_QOS_PRECEDENCE_CLASS value)
+{
+ switch(value){
+ case CNI_RIL3_QOS_PRECEDENCE_CLASS_HIGH_PRIORITY:
+ printf("HIGH\n");
+ break;
+ case CNI_RIL3_QOS_PRECEDENCE_CLASS_NORMAL_PRIORITY:
+ printf("NORMAL\n");
+ break;
+ case CNI_RIL3_QOS_PRECEDENCE_CLASS_LOW_PRIORITY:
+ printf("LOW\n");
+ break;
+ default: printf("Unknown :%d\n", value);
+ }
+}
+
+/*********************************************************************/
+void subscPrintQOSPeak(CNI_RIL3_QOS_PEAK_THROUGHPUT value)
+{
+ switch(value){
+ case CNI_RIL3_QOS_PEAK_THROUGHPUT_1_KBPS:
+ printf("PEAK 1KBPS\n");
+ break;
+ case CNI_RIL3_QOS_PEAK_THROUGHPUT_2_KBPS:
+ printf("PEAK 2KBPS\n");
+ break;
+ case CNI_RIL3_QOS_PEAK_THROUGHPUT_4_KBPS:
+ printf("PEAK 4KBPS\n");
+ break;
+ case CNI_RIL3_QOS_PEAK_THROUGHPUT_8_KBPS:
+ printf("PEAK 8KBPS\n");
+ break;
+ case CNI_RIL3_QOS_PEAK_THROUGHPUT_16_KBPS:
+ printf("PEAK 16KBPS\n");
+ break;
+ case CNI_RIL3_QOS_PEAK_THROUGHPUT_32_KBPS:
+ printf("PEAK 32KBPS\n");
+ break;
+ case CNI_RIL3_QOS_PEAK_THROUGHPUT_64_KBPS:
+ printf("PEAK 64KBPS\n");
+ break;
+ case CNI_RIL3_QOS_PEAK_THROUGHPUT_128_KBPS:
+ printf("PEAK 128KBPS\n");
+ break;
+ case CNI_RIL3_QOS_PEAK_THROUGHPUT_256_KBPS:
+ printf("PEAK 256KBPS\n");
+ break;
+ default: printf("Unknown :%d\n", value);
+ }
+}
+
+/*********************************************************************/
+void subscPrintQOSMean(CNI_RIL3_QOS_MEAN_THROUGHPUT value)
+{
+ switch(value){
+ case CNI_RIL3_QOS_MEAN_THROUGHPUT_100_OPH:
+ printf("MEAN 100 OPH\n");
+ break;
+ case CNI_RIL3_QOS_MEAN_THROUGHPUT_200_OPH:
+ printf("MEAN 200 OPH\n");
+ break;
+ case CNI_RIL3_QOS_MEAN_THROUGHPUT_500_OPH:
+ printf("MEAN 500 OPH\n");
+ break;
+ case CNI_RIL3_QOS_MEAN_THROUGHPUT_1_KOPH:
+ printf("MEAN 1 KOPH\n");
+ break;
+ case CNI_RIL3_QOS_MEAN_THROUGHPUT_2_KOPH:
+ printf("MEAN 2 KOPH\n");
+ break;
+ case CNI_RIL3_QOS_MEAN_THROUGHPUT_5_KOPH:
+ printf("MEAN 5 KOPH\n");
+ break;
+ case CNI_RIL3_QOS_MEAN_THROUGHPUT_10_KOPH:
+ printf("MEAN 10 KOPH\n");
+ break;
+ case CNI_RIL3_QOS_MEAN_THROUGHPUT_20_KOPH:
+ printf("MEAN 20 KOPH\n");
+ break;
+ case CNI_RIL3_QOS_MEAN_THROUGHPUT_50_KOPH:
+ printf("MEAN 50 KOPH\n");
+ break;
+ case CNI_RIL3_QOS_MEAN_THROUGHPUT_100_KOPH:
+ printf("MEAN 100 KOPH\n");
+ break;
+ case CNI_RIL3_QOS_MEAN_THROUGHPUT_200_KOPH:
+ printf("MEAN 200 KOPH\n");
+ break;
+ case CNI_RIL3_QOS_MEAN_THROUGHPUT_500_KOPH:
+ printf("MEAN 500 KOPH\n");
+ break;
+ case CNI_RIL3_QOS_MEAN_THROUGHPUT_1_MOPH:
+ printf("MEAN 1 MOPH\n");
+ break;
+ case CNI_RIL3_QOS_MEAN_THROUGHPUT_2_MOPH:
+ printf("MEAN 2 MOPH\n");
+ break;
+ case CNI_RIL3_QOS_MEAN_THROUGHPUT_5_MOPH:
+ printf("MEAN 5 MOPH\n");
+ break;
+ case CNI_RIL3_QOS_MEAN_THROUGHPUT_10_MOPH:
+ printf("MEAN 10 MOPH\n");
+ break;
+ case CNI_RIL3_QOS_MEAN_THROUGHPUT_20_MOPH:
+ printf("MEAN 20 MOPH\n");
+ break;
+ case CNI_RIL3_QOS_MEAN_THROUGHPUT_50_MOPH:
+ printf("MEAN 50 MOPH\n");
+ break;
+ case CNI_RIL3_QOS_MEAN_THROUGHPUT_BEST_EFFORT:
+ printf("MEAN BEST EFFORT\n");
+ break;
+ default: printf("Unknown :%d\n", value);
+ }
+}
+
+//*****************************************************************************
+void subscPrintQoS(T_SUBSC_QOS_DATA *ie)
+{
+ printf(" delay_class : "); subscPrintQOSDelay(ie->delay_class);
+ printf(" reliability_class: "); subscPrintQOSRely(ie->reliability_class);
+ printf(" precedence_class : "); subscPrintQOSPrec(ie->precedence_class);
+ printf(" peak_throughput : "); subscPrintQOSPeak(ie->peak_throughput);
+ printf(" mean_throughput : "); subscPrintQOSMean(ie->mean_throughput);
+}
+
+//*****************************************************************************
+void subscPrintPDPData(T_SUBSC_GPRS_DATA *data)
+{
+ int i;
+ if(data == 0) return;
+ printf(" pdp context id: %d\n", data->pdpContextId);
+ printf(" pdp type: ");
+ subscPrintPDPType(data->pdpType);
+ printf(" pdp address: ");
+ for(i=0; i<MAX_LEN_SUBSC_PDP_ADDR; i++) printf("%02x ", data->pdpAddress[i]);
+ printf("\n");
+ printf(" qos data: \n");
+ subscPrintQoS(&data->qosSubscribed);
+ printf(" vplmn address allowed: %d\n", data->vplmnAddressAllowed);
+ printf(" apn [%d] : ", data->apn_length);
+ for(i=0; i<data->apn_length; i++) printf("%c", data->apn[i]);
+ printf("\n");
+}
+
+//*****************************************************************************
+void subscPrintGPRSDataPtr(T_SUBSC_IE_GPRS_DATA_INFO *gprs_data)
+{
+ if(gprs_data == 0) return;
+ if(gprs_data->num_data >= MAX_NUM_SUBSC_GPRS_DATA) return;
+ int i;
+ for(i=0; i<gprs_data->num_data; i++){
+ printf(" PDP Data[%d] \n", i);
+ subscPrintPDPData(&gprs_data->data[i]);
+ }
+}
+
+//*****************************************************************************
+void subscPrintInfo(T_SUBSC_INFO *info)
+{
+ printf("IMSI: ");
+ subscPrintImsi(subscGetMobileIdPtr(info));
+ printf("\n");
+ printf("ISDN: ");
+ subscPrintIsdn(subscGetMSISDNPtr(info));
+ printf("\n");
+ printf("Provision Bearer Service: ");
+ subscPrintProvBS(subscGetProvBSPtr(info));
+ printf("\n");
+ printf("Provision Teleservice: ");
+ subscPrintProvTS(subscGetProvTSPtr(info));
+ printf("\n");
+ printf("Provision Supplementary Service: ");
+ subscPrintProvSS(subscGetProvSSPtr(info));
+ printf("\n");
+ printf("Subscriber Status: ");
+ subscPrintSubscStatus(subscGetSubscStatusPtr(info));
+ printf("\n");
+ printf("ODB Data\n");
+ subscPrintODBData(subscGetODBDataPtr(info));
+ subscPrintSSInfoList(subscGetSSInfoListPtr(info));
+ printf("UserInfo :");
+ subscPrintUserInfo(subscGetUserInfoPtr(info));
+ printf("GPRS :\n");
+ subscPrintGPRSDataPtr(subscGetGPRSDataPtr(info));
+}
+
+//*****************************************************************************
+void subscPrintGPRSInfo(T_SUBSC_INFO *info)
+{
+ printf("IMSI: ");
+ subscPrintImsi(subscGetMobileIdPtr(info));
+ printf("\n");
+ printf("GPRS :\n");
+ subscPrintGPRSDataPtr(subscGetGPRSDataPtr(info));
+}
+
+//*****************************************************************************
+char *subscGetStringImsi(T_SUBSC_IE_MOBILE_ID_IMSI *imsi)
+{
+ if(imsi == 0) return 0;
+ return (char *)imsi->imsi;
+}
+
+char *subscGetStringIsdn(T_SUBSC_IE_ISDN *isdn)
+{
+ if(isdn == 0) return 0;
+ return (char *)isdn->digits;
+}
+
+char *subscGetStringUser(T_SUBSC_IE_USER_INFO *user)
+{
+ if(user == 0) return "Unknown";
+ return (char *)user->name;
+}
+
+char *subscGetCFNum(T_SUBSC_IE_SS_INFO_LIST *ss_info_list,
+ T_SUBSC_INFO_SUPP_SERVICE_CODE ss_code)
+{
+ if(ss_info_list == 0) return "Unknown";
+ T_SUBSC_FORW_FEATURE* feature = subscGetForwFeature(ss_info_list, ss_code);
+ if(feature == 0) return "Unknown";
+ else return((char *)feature->forw_to_num.digits);
+}
+
+T_SUBSC_IE_ISDN* subscGetCFNumPtr(T_SUBSC_IE_SS_INFO_LIST *ss_info_list,
+ T_SUBSC_INFO_SUPP_SERVICE_CODE ss_code)
+{
+ if(ss_info_list == 0) return 0;
+ T_SUBSC_FORW_FEATURE* feature = subscGetForwFeature(ss_info_list, ss_code);
+ if(feature == 0) return 0;
+ else return(&feature->forw_to_num);
+}
+
+void subscSetIMSI(T_SUBSC_INFO *subsc, char *buf)
+{
+ T_SUBSC_IE_MOBILE_ID_IMSI* imsi = subscGetMobileIdPtr(subsc);
+ int len = strlen(buf);
+ if(len > MAX_NUM_SUBSC_IMSI) imsi->num_digit = len = MAX_NUM_SUBSC_IMSI;
+ else imsi->num_digit = len;
+ strncpy((char *)imsi->imsi, buf, len);
+ imsi->imsi[len] = '\0';
+}
+
+void subscSetMSISDN(T_SUBSC_INFO *subsc, char *buf)
+{
+ T_SUBSC_IE_ISDN* isdn = subscGetMSISDNPtr(subsc);
+ int len = strlen(buf);
+ if(len > MAX_NUM_SUBSC_ISDN) isdn->num_digit = len = MAX_NUM_SUBSC_ISDN;
+ else isdn->num_digit = len;
+ strncpy((char *)isdn->digits, buf, len);
+ isdn->digits[len] = '\0';
+}
+
+void subscSetUserInfo(T_SUBSC_INFO *subsc, char *buf)
+{
+ T_SUBSC_IE_USER_INFO* user = subscGetUserInfoPtr(subsc);
+ int len = strlen(buf);
+ if(len > MAX_NUM_USER_INFO) user->len = len = MAX_NUM_USER_INFO;
+ else user->len = len;
+ strncpy((char *)user->name, buf, len);
+ user->name[len] = '\0';
+}
+
+void subscSetACF(T_SUBSC_IE_SS_INFO_LIST *ss_info_list,
+ T_SUBSC_INFO_SUPP_SERVICE_CODE ss_code,
+ int active)
+{
+ if(ss_info_list == 0) return;
+ T_SUBSC_FORW_FEATURE* feature = subscGetForwFeature(ss_info_list, ss_code);
+ if(feature == 0) return;
+ else feature->ss_status.ss_status_A = (unsigned char)(active & 0x01);
+}
+
+void subscSetPCF(T_SUBSC_IE_SS_INFO_LIST *ss_info_list,
+ T_SUBSC_INFO_SUPP_SERVICE_CODE ss_code,
+ int prov)
+{
+ if(ss_info_list == 0) return;
+ T_SUBSC_FORW_FEATURE* feature = subscGetForwFeature(ss_info_list, ss_code);
+ if(feature == 0) return;
+ else feature->ss_status.ss_status_P = (unsigned char)(prov & 0x01);
+}
+
+void subscSetRCF(T_SUBSC_IE_SS_INFO_LIST *ss_info_list,
+ T_SUBSC_INFO_SUPP_SERVICE_CODE ss_code,
+ int reg)
+{
+ if(ss_info_list == 0) return;
+ T_SUBSC_FORW_FEATURE* feature = subscGetForwFeature(ss_info_list, ss_code);
+ if(feature == 0) return;
+ else feature->ss_status.ss_status_R = (unsigned char)(reg & 0x01);
+}
+
+void subscSetCFNum(T_SUBSC_IE_SS_INFO_LIST *ss_info_list,
+ T_SUBSC_INFO_SUPP_SERVICE_CODE ss_code,
+ char *num)
+{
+ T_SUBSC_IE_ISDN* forw_num = subscGetCFNumPtr(ss_info_list, ss_code);
+ if(forw_num != 0){
+ forw_num->num_digit = strlen(num);
+ strcpy((char *)forw_num->digits, num);
+ forw_num->num_plan[0] = 0x91; // Set All Call Forwarding Number Type as International
+ }
+}
+
+void subscSetTimerCFNRY(T_SUBSC_IE_SS_INFO_LIST *ss_info_list,
+ int sec)
+{
+ if(ss_info_list == 0) return;
+ T_SUBSC_FORW_FEATURE* feature = subscGetForwFeature(ss_info_list, SUPP_SERV_CFNRY);
+ if(feature == 0) return;
+ else feature->no_reply_cond_time = sec;
+}
+
+T_SS_STATUS_FLAG* subscGetStatusFlagPtr(T_SUBSC_IE_SS_INFO_LIST *ss_info_list,
+ T_SUBSC_INFO_SUPP_SERVICE_CODE ss_code)
+{
+ int ind;
+ if(ss_info_list == 0) return 0;
+ switch(ss_code){
+ case SUPP_SERV_CLIP :
+ case SUPP_SERV_CLIR :
+ case SUPP_SERV_COLP :
+ case SUPP_SERV_COLR :
+ case SUPP_SERV_ECT :
+ case SUPP_SERV_ALL_CC:
+ case SUPP_SERV_CW :
+ case SUPP_SERV_HOLD :
+ case SUPP_SERV_ALL_MULT:
+ case SUPP_SERV_MPTY:
+ ind = subscGetSSInfoDataInd(ss_code);
+ if(ind == -1) return 0;
+ return &ss_info_list->ss_info_data[ind].ss_status;
+ case SUPP_SERV_CFU :
+ case SUPP_SERV_CFB :
+ case SUPP_SERV_CFNRY :
+ case SUPP_SERV_CFNRC :
+ ind = subscGetSSInfoForwInd(ss_code);
+ if(ind == -1) return 0;
+ return &ss_info_list->ss_info_forw[ind].list[0].ss_status;
+ case SUPP_SERV_BAOC :
+ case SUPP_SERV_BOIC :
+ case SUPP_SERV_BOICE :
+ case SUPP_SERV_BAIC :
+ case SUPP_SERV_BIC_ROAM:
+ ind = subscGetSSInfoBarInd(ss_code);
+ if(ind == -1) return 0;
+ return &ss_info_list->ss_info_bar[ind].list[0].ss_status;
+ default:
+ return 0;
+ }
+}
+
+int subscGetP(T_SUBSC_IE_SS_INFO_LIST *ss_info_list,
+ T_SUBSC_INFO_SUPP_SERVICE_CODE ss_code)
+{
+ T_SS_STATUS_FLAG *ss_status = subscGetStatusFlagPtr(ss_info_list, ss_code);
+ if(ss_status == 0) return 0;
+ return ss_status->ss_status_P;
+}
+
+int subscGetA(T_SUBSC_IE_SS_INFO_LIST *ss_info_list,
+ T_SUBSC_INFO_SUPP_SERVICE_CODE ss_code)
+{
+ T_SS_STATUS_FLAG *ss_status = subscGetStatusFlagPtr(ss_info_list, ss_code);
+ if(ss_status == 0) return 0;
+ return ss_status->ss_status_A;
+}
+
+int subscGetR(T_SUBSC_IE_SS_INFO_LIST *ss_info_list,
+ T_SUBSC_INFO_SUPP_SERVICE_CODE ss_code)
+{
+ T_SS_STATUS_FLAG *ss_status = subscGetStatusFlagPtr(ss_info_list, ss_code);
+ if(ss_status == 0) return 0;
+ return ss_status->ss_status_R;
+}
+
+int subscGetQ(T_SUBSC_IE_SS_INFO_LIST *ss_info_list,
+ T_SUBSC_INFO_SUPP_SERVICE_CODE ss_code)
+{
+ T_SS_STATUS_FLAG *ss_status = subscGetStatusFlagPtr(ss_info_list, ss_code);
+ if(ss_status == 0) return 0;
+ return ss_status->ss_status_Q;
+}
+
+void subscSetP(T_SUBSC_IE_SS_INFO_LIST *ss_info_list,
+ T_SUBSC_INFO_SUPP_SERVICE_CODE ss_code,
+ int prov)
+{
+ T_SS_STATUS_FLAG *ss_status = subscGetStatusFlagPtr(ss_info_list, ss_code);
+ if(ss_status == 0) return;
+ ss_status->ss_status_P = prov;
+}
+
+void subscSetA(T_SUBSC_IE_SS_INFO_LIST *ss_info_list,
+ T_SUBSC_INFO_SUPP_SERVICE_CODE ss_code,
+ int active)
+{
+ T_SS_STATUS_FLAG *ss_status = subscGetStatusFlagPtr(ss_info_list, ss_code);
+ if(ss_status == 0) return;
+ ss_status->ss_status_A = active;
+}
+
+void subscSetR(T_SUBSC_IE_SS_INFO_LIST *ss_info_list,
+ T_SUBSC_INFO_SUPP_SERVICE_CODE ss_code,
+ int registered)
+{
+ T_SS_STATUS_FLAG *ss_status = subscGetStatusFlagPtr(ss_info_list, ss_code);
+ if(ss_status == 0) return;
+ ss_status->ss_status_R = registered;
+}
+
+void subscSetQ(T_SUBSC_IE_SS_INFO_LIST *ss_info_list,
+ T_SUBSC_INFO_SUPP_SERVICE_CODE ss_code,
+ int quiescent)
+{
+ T_SS_STATUS_FLAG *ss_status = subscGetStatusFlagPtr(ss_info_list, ss_code);
+ if(ss_status == 0) return;
+ ss_status->ss_status_Q = quiescent;
+}
+
+
+int subscGetSSInfoInd(T_SUBSC_INFO_SUPP_SERVICE_CODE ss_code) // 2.0.6
+{
+ switch (ss_code){
+ case SUPP_SERV_CFU :
+ case SUPP_SERV_CFB :
+ case SUPP_SERV_CFNRY :
+ case SUPP_SERV_CFNRC :
+ return subscGetSSInfoForwInd(ss_code);
+ case SUPP_SERV_CLIP :
+ case SUPP_SERV_CLIR :
+ case SUPP_SERV_COLP :
+ case SUPP_SERV_COLR :
+ case SUPP_SERV_ECT :
+ case SUPP_SERV_CW :
+ case SUPP_SERV_HOLD :
+ case SUPP_SERV_MPTY :
+ return subscGetSSInfoDataInd(ss_code);
+ case SUPP_SERV_BAOC :
+ case SUPP_SERV_BOIC :
+ case SUPP_SERV_BOICE :
+ case SUPP_SERV_BAIC :
+ case SUPP_SERV_BIC_ROAM:
+ return subscGetSSInfoBarInd(ss_code);
+ default: return -1;
+ }
+}
+
+int subscGetSSInfoForwInd(T_SUBSC_INFO_SUPP_SERVICE_CODE ss_code) // 2.0.7
+{
+ switch (ss_code){
+ case SUPP_SERV_CFU : return(SS_INFO_IND_FORW_CFU);
+ case SUPP_SERV_CFB : return(SS_INFO_IND_FORW_CFB);
+ case SUPP_SERV_CFNRY : return(SS_INFO_IND_FORW_CFNRY);
+ case SUPP_SERV_CFNRC : return(SS_INFO_IND_FORW_CFNRC);
+ default: return -1;
+ }
+}
+
+int subscGetSSInfoDataInd(T_SUBSC_INFO_SUPP_SERVICE_CODE ss_code) // 2.0.7
+{
+ switch (ss_code){
+ case SUPP_SERV_CLIP : return(SS_INFO_IND_DATA_CLIP);
+ case SUPP_SERV_CLIR : return(SS_INFO_IND_DATA_CLIR);
+ case SUPP_SERV_COLP : return(SS_INFO_IND_DATA_COLP);
+ case SUPP_SERV_COLR : return(SS_INFO_IND_DATA_COLR);
+ case SUPP_SERV_ECT : return(SS_INFO_IND_DATA_ECT);
+ case SUPP_SERV_CW : return(SS_INFO_IND_DATA_CW);
+ case SUPP_SERV_HOLD : return(SS_INFO_IND_DATA_HOLD);
+ case SUPP_SERV_MPTY : return(SS_INFO_IND_DATA_MPTY);
+ default: return -1;
+ }
+}
+
+int subscGetSSInfoBarInd(T_SUBSC_INFO_SUPP_SERVICE_CODE ss_code) // 2.0.7
+{
+ switch (ss_code){
+ case SUPP_SERV_BAOC : return(SS_INFO_IND_BAR_BAOC);
+ case SUPP_SERV_BOIC : return(SS_INFO_IND_BAR_BOIC);
+ case SUPP_SERV_BOICE : return(SS_INFO_IND_BAR_BOICE);
+ case 0x96: // wrong value, but for older user profile
+ case SUPP_SERV_BAIC : return(SS_INFO_IND_BAR_BAIC);
+ case 0x97: // wrong value, but for older user profile
+ case SUPP_SERV_BIC_ROAM: return(SS_INFO_IND_BAR_BIC_ROAM);
+ default: return -1;
+ }
+}
+
+void subscSSInfoListClear(T_SUBSC_IE_SS_INFO_LIST *info_list) // 2.0.6
+{
+ if(info_list == 0) return;
+
+ memset(info_list, 0, sizeof(T_SUBSC_IE_SS_INFO_LIST));
+
+ info_list->num_ss_info = SS_INFO_IND_DATA_MAX + SS_INFO_IND_FORW_MAX + SS_INFO_IND_BAR_MAX;
+
+ info_list->ss_info_data[SS_INFO_IND_DATA_CLIP ].ss_code = SUPP_SERV_CLIP;
+ info_list->ss_info_data[SS_INFO_IND_DATA_CLIR ].ss_code = SUPP_SERV_CLIR;
+ info_list->ss_info_data[SS_INFO_IND_DATA_COLP ].ss_code = SUPP_SERV_COLP;
+ info_list->ss_info_data[SS_INFO_IND_DATA_COLR ].ss_code = SUPP_SERV_COLR;
+ info_list->ss_info_data[SS_INFO_IND_DATA_ECT ].ss_code = SUPP_SERV_ECT;
+ info_list->ss_info_data[SS_INFO_IND_DATA_CW ].ss_code = SUPP_SERV_CW;
+ info_list->ss_info_data[SS_INFO_IND_DATA_HOLD ].ss_code = SUPP_SERV_HOLD;
+ info_list->ss_info_data[SS_INFO_IND_DATA_MPTY ].ss_code = SUPP_SERV_MPTY;
+
+ info_list->ss_info_forw[SS_INFO_IND_FORW_CFU ].ss_code = SUPP_SERV_CFU;
+ info_list->ss_info_forw[SS_INFO_IND_FORW_CFU ].num_feature = 1;
+ info_list->ss_info_forw[SS_INFO_IND_FORW_CFU ].list[0].basic_service.service_type = TELE_SERVICE_TYPE;
+ info_list->ss_info_forw[SS_INFO_IND_FORW_CFB ].ss_code = SUPP_SERV_CFB;
+ info_list->ss_info_forw[SS_INFO_IND_FORW_CFB ].num_feature = 1;
+ info_list->ss_info_forw[SS_INFO_IND_FORW_CFB ].list[0].basic_service.service_type = TELE_SERVICE_TYPE;
+ info_list->ss_info_forw[SS_INFO_IND_FORW_CFNRY].ss_code = SUPP_SERV_CFNRY;
+ info_list->ss_info_forw[SS_INFO_IND_FORW_CFNRY].num_feature = 1;
+ info_list->ss_info_forw[SS_INFO_IND_FORW_CFNRY].list[0].basic_service.service_type = TELE_SERVICE_TYPE;
+ info_list->ss_info_forw[SS_INFO_IND_FORW_CFNRC].ss_code = SUPP_SERV_CFNRC;
+ info_list->ss_info_forw[SS_INFO_IND_FORW_CFNRC].num_feature = 1;
+ info_list->ss_info_forw[SS_INFO_IND_FORW_CFNRC].list[0].basic_service.service_type = TELE_SERVICE_TYPE;
+
+ info_list->ss_info_bar[SS_INFO_IND_BAR_BAOC ].ss_code = SUPP_SERV_BAOC;
+ info_list->ss_info_bar[SS_INFO_IND_BAR_BAOC ].num_feature = 1;
+ info_list->ss_info_bar[SS_INFO_IND_BAR_BAOC ].list[0].basic_service.service_type = TELE_SERVICE_TYPE;
+ info_list->ss_info_bar[SS_INFO_IND_BAR_BOIC ].ss_code = SUPP_SERV_BOIC;
+ info_list->ss_info_bar[SS_INFO_IND_BAR_BOIC ].num_feature = 1;
+ info_list->ss_info_bar[SS_INFO_IND_BAR_BOIC ].list[0].basic_service.service_type = TELE_SERVICE_TYPE;
+ info_list->ss_info_bar[SS_INFO_IND_BAR_BOICE].ss_code = SUPP_SERV_BOICE;
+ info_list->ss_info_bar[SS_INFO_IND_BAR_BOICE ].num_feature = 1;
+ info_list->ss_info_bar[SS_INFO_IND_BAR_BOICE ].list[0].basic_service.service_type = TELE_SERVICE_TYPE;
+ info_list->ss_info_bar[SS_INFO_IND_BAR_BAIC ].ss_code = SUPP_SERV_BAIC;
+ info_list->ss_info_bar[SS_INFO_IND_BAR_BAIC ].num_feature = 1;
+ info_list->ss_info_bar[SS_INFO_IND_BAR_BAIC ].list[0].basic_service.service_type = TELE_SERVICE_TYPE;
+ info_list->ss_info_bar[SS_INFO_IND_BAR_BIC_ROAM].ss_code = SUPP_SERV_BIC_ROAM;
+ info_list->ss_info_bar[SS_INFO_IND_BAR_BIC_ROAM ].num_feature = 1;
+ info_list->ss_info_bar[SS_INFO_IND_BAR_BIC_ROAM ].list[0].basic_service.service_type = TELE_SERVICE_TYPE;
+}
+
+void subscInfoInitialize(T_SUBSC_INFO *info) // 2.0.6
+{
+ memset(info, 0, sizeof(T_SUBSC_INFO));
+
+ info->prov_bs.num_srv = 2;
+ info->prov_bs.bs_code[0] = DATA_CDA_9600BPS;
+ info->prov_bs.bs_code[1] = DATA_CDA_14400BPS;
+ info->prov_ts.num_srv = 2;
+ info->prov_ts.ts_code[0] = TELEPHONY_SERVICES;
+ info->prov_ts.ts_code[1] = EMERGENCY_CALLS;
+// info->prov_ts.ts_code[2] = SMS_MT_PP;
+// info->prov_ts.ts_code[3] = SMS_MO_PP;
+// info->prov_ts.ts_code[4] = FACS_GRP3_ALT_SPEECH;
+
+ subscSSInfoListClear(subscGetSSInfoListPtr(info));
+}
+
+int subscIsODBarred (T_SUBSC_INFO *info)
+{
+ T_SUBSC_IE_SUBSC_STATUS* status_ptr = subscGetSubscStatusPtr(info);
+ if(status_ptr != 0){
+ return(status_ptr->status);
+ }
+ else
+ return 0;
+}
+
+int subscIsODBAllOg (T_SUBSC_INFO *info)
+{
+ T_SUBSC_IE_ODB_DATA* odb_ptr = subscGetODBDataPtr(info);
+ if(odb_ptr != 0){
+ return(odb_ptr->odb_general.all_og_barred);
+ }
+ else
+ return 0;
+}
+
+int subscIsODBIntrnOg (T_SUBSC_INFO *info)
+{
+ T_SUBSC_IE_ODB_DATA* odb_ptr = subscGetODBDataPtr(info);
+ if(odb_ptr != 0){
+ return(odb_ptr->odb_general.intrn_og_barred);
+ }
+ else
+ return 0;
+}
+
+int subscIsODBIntrnOgNotHplmn (T_SUBSC_INFO *info)
+{
+ T_SUBSC_IE_ODB_DATA* odb_ptr = subscGetODBDataPtr(info);
+ if(odb_ptr != 0){
+ return(odb_ptr->odb_general.intrn_og_not_hplmn_barred);
+ }
+ else
+ return 0;
+}
+
+int subscIsODBPremiumInfoOg (T_SUBSC_INFO *info)
+{
+ T_SUBSC_IE_ODB_DATA* odb_ptr = subscGetODBDataPtr(info);
+ if(odb_ptr != 0){
+ return(odb_ptr->odb_general.premium_info_og_barred);
+ }
+ else
+ return 0;
+}
+
+int subscIsODBPremiumEnterOg (T_SUBSC_INFO *info)
+{
+ T_SUBSC_IE_ODB_DATA* odb_ptr = subscGetODBDataPtr(info);
+ if(odb_ptr != 0){
+ return(odb_ptr->odb_general.premium_enter_og_barred);
+ }
+ else
+ return 0;
+}
+
+int subscIsODBSsAccess (T_SUBSC_INFO *info)
+{
+ T_SUBSC_IE_ODB_DATA* odb_ptr = subscGetODBDataPtr(info);
+ if(odb_ptr != 0){
+ return(odb_ptr->odb_general.ss_access_barred);
+ }
+ else
+ return 0;
+}
+
+int subscIsODBIntrzOg (T_SUBSC_INFO *info)
+{
+ T_SUBSC_IE_ODB_DATA* odb_ptr = subscGetODBDataPtr(info);
+ if(odb_ptr != 0){
+ return(odb_ptr->odb_general.intrz_og_barred);
+ }
+ else
+ return 0;
+}
+
+int subscIsODBIntrzOgNotHplmn (T_SUBSC_INFO *info)
+{
+ T_SUBSC_IE_ODB_DATA* odb_ptr = subscGetODBDataPtr(info);
+ if(odb_ptr != 0){
+ return(odb_ptr->odb_general.intrz_og_not_hplmn_barred);
+ }
+ else
+ return 0;
+}
+
+int subscIsODBIntrzIntrnOgNotHplmn (T_SUBSC_INFO *info)
+{
+ T_SUBSC_IE_ODB_DATA* odb_ptr = subscGetODBDataPtr(info);
+ if(odb_ptr != 0){
+ return(odb_ptr->odb_general.intrz_intrn_og_not_hplmn_barred);
+ }
+ else
+ return 0;
+}
+
+int subscIsODBAllEct (T_SUBSC_INFO *info)
+{
+ T_SUBSC_IE_ODB_DATA* odb_ptr = subscGetODBDataPtr(info);
+ if(odb_ptr != 0){
+ return(odb_ptr->odb_general.all_ect_barred);
+ }
+ else
+ return 0;
+}
+
+int subscIsODBChargeableEct (T_SUBSC_INFO *info)
+{
+ T_SUBSC_IE_ODB_DATA* odb_ptr = subscGetODBDataPtr(info);
+ if(odb_ptr != 0){
+ return(odb_ptr->odb_general.chargeable_ect_barred);
+ }
+ else
+ return 0;
+}
+
+int subscIsODBIntrnEct (T_SUBSC_INFO *info)
+{
+ T_SUBSC_IE_ODB_DATA* odb_ptr = subscGetODBDataPtr(info);
+ if(odb_ptr != 0){
+ return(odb_ptr->odb_general.intrn_ect_barred);
+ }
+ else
+ return 0;
+}
+
+int subscIsODBIntrzEct (T_SUBSC_INFO *info)
+{
+ T_SUBSC_IE_ODB_DATA* odb_ptr = subscGetODBDataPtr(info);
+ if(odb_ptr != 0){
+ return(odb_ptr->odb_general.intrz_ect_barred);
+ }
+ else
+ return 0;
+}
+
+int subscIsODBDoubleChargeableEct (T_SUBSC_INFO *info)
+{
+ T_SUBSC_IE_ODB_DATA* odb_ptr = subscGetODBDataPtr(info);
+ if(odb_ptr != 0){
+ return(odb_ptr->odb_general.double_chargeable_ect_barred);
+ }
+ else
+ return 0;
+}
+
+int subscIsODBMultipleEct (T_SUBSC_INFO *info)
+{
+ T_SUBSC_IE_ODB_DATA* odb_ptr = subscGetODBDataPtr(info);
+ if(odb_ptr != 0){
+ return(odb_ptr->odb_general.multiple_ect_barred);
+ }
+ else
+ return 0;
+}
+
+
+void subscSetODB (T_SUBSC_INFO *info, int flag)
+{
+ T_SUBSC_IE_SUBSC_STATUS* status_ptr = subscGetSubscStatusPtr(info);
+ if(status_ptr != 0){
+ if(flag){
+ status_ptr->status = SUBSC_STATUS_ODBARRING;
+ }
+ else{
+ status_ptr->status = SUBSC_STATUS_SERVICE_GRANTED;
+ }
+ }
+}
+
+void subscSetODBAllOg (T_SUBSC_INFO *info, int flag)
+{
+ T_SUBSC_IE_ODB_DATA* odb_ptr = subscGetODBDataPtr(info);
+ if(odb_ptr != 0){
+ if(flag){
+ odb_ptr->odb_general.all_og_barred = 1;
+ }
+ else{
+ odb_ptr->odb_general.all_og_barred = 0;
+ }
+ }
+}
+
+void subscSetODBIntrnOg (T_SUBSC_INFO *info, int flag)
+{
+ T_SUBSC_IE_ODB_DATA* odb_ptr = subscGetODBDataPtr(info);
+ if(odb_ptr != 0){
+ if(flag){
+ odb_ptr->odb_general.intrn_og_barred = 1;
+ }
+ else{
+ odb_ptr->odb_general.intrn_og_barred = 0;
+ }
+ }
+}
+
+void subscSetODBIntrnOgNotHplmn (T_SUBSC_INFO *info, int flag)
+{
+ T_SUBSC_IE_ODB_DATA* odb_ptr = subscGetODBDataPtr(info);
+ if(odb_ptr != 0){
+ if(flag){
+ odb_ptr->odb_general.intrn_og_not_hplmn_barred = 1;
+ }
+ else{
+ odb_ptr->odb_general.intrn_og_not_hplmn_barred = 0;
+ }
+ }
+}
+
+void subscSetODBPremiumInfoOg (T_SUBSC_INFO *info, int flag)
+{
+ T_SUBSC_IE_ODB_DATA* odb_ptr = subscGetODBDataPtr(info);
+ if(odb_ptr != 0){
+ if(flag){
+ odb_ptr->odb_general.premium_info_og_barred = 1;
+ }
+ else{
+ odb_ptr->odb_general.premium_info_og_barred = 0;
+ }
+ }
+}
+
+void subscSetODBPremiumEnterOg (T_SUBSC_INFO *info, int flag)
+{
+ T_SUBSC_IE_ODB_DATA* odb_ptr = subscGetODBDataPtr(info);
+ if(odb_ptr != 0){
+ if(flag){
+ odb_ptr->odb_general.premium_enter_og_barred = 1;
+ }
+ else{
+ odb_ptr->odb_general.premium_enter_og_barred = 0;
+ }
+ }
+}
+
+void subscSetODBSsAccess (T_SUBSC_INFO *info, int flag)
+{
+ T_SUBSC_IE_ODB_DATA* odb_ptr = subscGetODBDataPtr(info);
+ if(odb_ptr != 0){
+ if(flag){
+ odb_ptr->odb_general.ss_access_barred = 1;
+ }
+ else{
+ odb_ptr->odb_general.ss_access_barred = 0;
+ }
+ }
+}
+
+void subscSetODBIntrzOg (T_SUBSC_INFO *info, int flag)
+{
+ T_SUBSC_IE_ODB_DATA* odb_ptr = subscGetODBDataPtr(info);
+ if(odb_ptr != 0){
+ if(flag){
+ odb_ptr->odb_general.intrz_og_barred = 1;
+ }
+ else{
+ odb_ptr->odb_general.intrz_og_barred = 0;
+ }
+ }
+}
+
+void subscSetODBIntrzOgNotHplmn (T_SUBSC_INFO *info, int flag)
+{
+ T_SUBSC_IE_ODB_DATA* odb_ptr = subscGetODBDataPtr(info);
+ if(odb_ptr != 0){
+ if(flag){
+ odb_ptr->odb_general.intrz_og_not_hplmn_barred = 1;
+ }
+ else{
+ odb_ptr->odb_general.intrz_og_not_hplmn_barred = 0;
+ }
+ }
+}
+
+void subscSetODBIntrzIntrnOgNotHplmn (T_SUBSC_INFO *info, int flag)
+{
+ T_SUBSC_IE_ODB_DATA* odb_ptr = subscGetODBDataPtr(info);
+ if(odb_ptr != 0){
+ if(flag){
+ odb_ptr->odb_general.intrz_intrn_og_not_hplmn_barred = 1;
+ }
+ else{
+ odb_ptr->odb_general.intrz_intrn_og_not_hplmn_barred = 0;
+ }
+ }
+}
+
+void subscSetODBAllEct (T_SUBSC_INFO *info, int flag)
+{
+ T_SUBSC_IE_ODB_DATA* odb_ptr = subscGetODBDataPtr(info);
+ if(odb_ptr != 0){
+ if(flag){
+ odb_ptr->odb_general.all_ect_barred = 1;
+ }
+ else{
+ odb_ptr->odb_general.all_ect_barred = 0;
+ }
+ }
+}
+
+void subscSetODBChargeableEct (T_SUBSC_INFO *info, int flag)
+{
+ T_SUBSC_IE_ODB_DATA* odb_ptr = subscGetODBDataPtr(info);
+ if(odb_ptr != 0){
+ if(flag){
+ odb_ptr->odb_general.chargeable_ect_barred = 1;
+ }
+ else{
+ odb_ptr->odb_general.chargeable_ect_barred = 0;
+ }
+ }
+}
+
+void subscSetODBIntrnEct (T_SUBSC_INFO *info, int flag)
+{
+ T_SUBSC_IE_ODB_DATA* odb_ptr = subscGetODBDataPtr(info);
+ if(odb_ptr != 0){
+ if(flag){
+ odb_ptr->odb_general.intrn_ect_barred = 1;
+ }
+ else{
+ odb_ptr->odb_general.intrn_ect_barred = 0;
+ }
+ }
+}
+
+void subscSetODBIntrzEct (T_SUBSC_INFO *info, int flag)
+{
+ T_SUBSC_IE_ODB_DATA* odb_ptr = subscGetODBDataPtr(info);
+ if(odb_ptr != 0){
+ if(flag){
+ odb_ptr->odb_general.intrz_ect_barred = 1;
+ }
+ else{
+ odb_ptr->odb_general.intrz_ect_barred = 0;
+ }
+ }
+}
+
+void subscSetODBDoubleChargeableEct (T_SUBSC_INFO *info, int flag)
+{
+ T_SUBSC_IE_ODB_DATA* odb_ptr = subscGetODBDataPtr(info);
+ if(odb_ptr != 0){
+ if(flag){
+ odb_ptr->odb_general.double_chargeable_ect_barred = 1;
+ }
+ else{
+ odb_ptr->odb_general.double_chargeable_ect_barred = 0;
+ }
+ }
+}
+
+void subscSetODBMultipleEct (T_SUBSC_INFO *info, int flag)
+{
+ T_SUBSC_IE_ODB_DATA* odb_ptr = subscGetODBDataPtr(info);
+ if(odb_ptr != 0){
+ if(flag){
+ odb_ptr->odb_general.multiple_ect_barred = 1;
+ }
+ else{
+ odb_ptr->odb_general.multiple_ect_barred = 0;
+ }
+ }
+}
+
+int subscIsSSBaoc (T_SUBSC_INFO *info)
+{
+ if(info == 0) return 0;
+ T_SUBSC_IE_SS_INFO_LIST *info_list = subscGetSSInfoListPtr(info);
+ return (subscGetA(info_list, SUPP_SERV_BAOC) == 1);
+}
+
+int subscIsSSBoic (T_SUBSC_INFO *info)
+{
+ if(info == 0) return 0;
+ T_SUBSC_IE_SS_INFO_LIST *info_list = subscGetSSInfoListPtr(info);
+ return (subscGetA(info_list, SUPP_SERV_BOIC) == 1);
+}
+
+int subscIsSSBoicExHC (T_SUBSC_INFO *info)
+{
+ if(info == 0) return 0;
+ T_SUBSC_IE_SS_INFO_LIST *info_list = subscGetSSInfoListPtr(info);
+ return (subscGetA(info_list, SUPP_SERV_BOICE) == 1);
+}
+
+int subscIsSSBaic (T_SUBSC_INFO *info)
+{
+ if(info == 0) return 0;
+ T_SUBSC_IE_SS_INFO_LIST *info_list = subscGetSSInfoListPtr(info);
+ return (subscGetA(info_list, SUPP_SERV_BAIC) == 1);
+}
+
+int subscIsSSBicRoam (T_SUBSC_INFO *info)
+{
+ if(info == 0) return 0;
+ T_SUBSC_IE_SS_INFO_LIST *info_list = subscGetSSInfoListPtr(info);
+ return (subscGetA(info_list, SUPP_SERV_BIC_ROAM) == 1);
+}
+
+void subscSetSSBaoc (T_SUBSC_INFO *info, int flag)
+{
+ if(info == 0) return;
+ T_SUBSC_IE_SS_INFO_LIST *info_list = subscGetSSInfoListPtr(info);
+ if(info_list == 0) return;
+ subscSetA(info_list, SUPP_SERV_BAOC, flag);
+}
+
+void subscSetSSBoic (T_SUBSC_INFO *info, int flag)
+{
+ if(info == 0) return;
+ T_SUBSC_IE_SS_INFO_LIST *info_list = subscGetSSInfoListPtr(info);
+ if(info_list == 0) return;
+ subscSetA(info_list, SUPP_SERV_BOIC, flag);
+}
+
+void subscSetSSBoicExHC (T_SUBSC_INFO *info, int flag)
+{
+ if(info == 0) return;
+ T_SUBSC_IE_SS_INFO_LIST *info_list = subscGetSSInfoListPtr(info);
+ if(info_list == 0) return;
+ subscSetA(info_list, SUPP_SERV_BOICE, flag);
+}
+
+void subscSetSSBaic (T_SUBSC_INFO *info, int flag)
+{
+ if(info == 0) return;
+ T_SUBSC_IE_SS_INFO_LIST *info_list = subscGetSSInfoListPtr(info);
+ if(info_list == 0) return;
+ subscSetA(info_list, SUPP_SERV_BAIC, flag);
+}
+
+void subscSetSSBicRoam (T_SUBSC_INFO *info, int flag)
+{
+ if(info == 0) return;
+ T_SUBSC_IE_SS_INFO_LIST *info_list = subscGetSSInfoListPtr(info);
+ if(info_list == 0) return;
+ subscSetA(info_list, SUPP_SERV_BIC_ROAM, flag);
+}
+
+int subscGetTSIndex(T_SUBSC_IE_PROVISION_TS *ts_list,
+ T_SUBSC_INFO_TELE_SERVICE_CODE code)
+{
+ int index = -1;
+ for(int i=0; i<ts_list->num_srv; i++){
+ if(ts_list->ts_code[i] == code){
+ index = i;
+ break;
+ }
+ }
+ return index;
+}
+
+int subscExistTS(T_SUBSC_INFO *info, T_SUBSC_INFO_TELE_SERVICE_CODE code)
+{
+ T_SUBSC_IE_PROVISION_TS* ts_list = subscGetProvTSPtr(info);
+ if(ts_list == 0) return 0;
+
+ int index = subscGetTSIndex(ts_list, code);
+ if(index == -1)
+ return 0;
+ else
+ return 1;
+}
+
+int subscAddTS(T_SUBSC_INFO *info, T_SUBSC_INFO_TELE_SERVICE_CODE code)
+{
+ T_SUBSC_IE_PROVISION_TS* ts_list = subscGetProvTSPtr(info);
+ if(ts_list == 0) return -1;
+
+ int index = subscGetTSIndex(ts_list, code);
+ if(index != -1) // already exists
+ return 1;
+ if(ts_list->num_srv == MAX_NUM_TELE_SERVICE) // list full
+ return -1;
+ ts_list->ts_code[ts_list->num_srv] = code;
+ ts_list->num_srv++;
+ return 0;
+}
+
+int subscDelTS(T_SUBSC_INFO *info, T_SUBSC_INFO_TELE_SERVICE_CODE code)
+{
+ T_SUBSC_IE_PROVISION_TS* ts_list = subscGetProvTSPtr(info);
+ if(ts_list == 0) return -1;
+
+ int index = subscGetTSIndex(ts_list, code);
+ if(index == -1) // doesn't exist
+ return 1;
+ if(ts_list->num_srv == 1){ // last one
+ ts_list->ts_code[index] = ALL_TELE_SERVICES;
+ }
+ else{
+ ts_list->ts_code[index] = ts_list->ts_code[ts_list->num_srv - 1];
+ ts_list->ts_code[ts_list->num_srv - 1] = ALL_TELE_SERVICES;
+ }
+ ts_list->num_srv--;
+ return 0;
+}
+
+int subscProvSMS_MT_PP(T_SUBSC_INFO *info)
+{
+ return( subscExistTS(info, ALL_SMS) || subscExistTS(info, SMS_MT_PP) );
+}
+
+int subscProvSMS_MO_PP(T_SUBSC_INFO *info)
+{
+ return( subscExistTS(info, ALL_SMS) || subscExistTS(info, SMS_MO_PP) );
+}
+
+void subscProvSSCode(T_SUBSC_INFO *info, T_SUBSC_INFO_SUPP_SERVICE_CODE code, int add)
+{
+ T_SUBSC_IE_PROVISION_SS* list = subscGetProvSSPtr(info);
+
+ int found = 0;
+ int i;
+ for(i=0; i<list->num_srv; i++){
+ if(list->ss_code[i] == code){
+ found = 1;
+ break;
+ }
+ }
+ if(found){
+ if(!add){
+ list->ss_code[i] = list->ss_code[list->num_srv - 1];
+ list->num_srv--;
+ }
+ }
+ else{
+ if(add){
+ list->ss_code[list->num_srv++] = code;
+ }
+ }
+}
+
+/* GPRS */
+T_SUBSC_GPRS_DATA *subscGetGprsPdpDataPtr(T_SUBSC_INFO *info, int index)
+{
+ T_SUBSC_IE_GPRS_DATA_INFO* gprs_data = subscGetGPRSDataPtr(info);
+ if(gprs_data == 0) return 0;
+ else return &gprs_data->data[index];
+}
+
+T_SUBSC_GPRS_DATA *subscFindGprsPdpData(T_SUBSC_INFO *info, unsigned char pdpContextId, int *index)
+{
+ T_SUBSC_IE_GPRS_DATA_INFO* gprs_data = subscGetGPRSDataPtr(info);
+ *index = -1;
+ int i;
+
+ if(gprs_data == 0) return 0;
+
+ for(i=0; i<gprs_data->num_data; i++){
+ if(gprs_data->data[i].pdpContextId == pdpContextId){
+ *index = i;
+ return &gprs_data->data[i];
+ }
+ }
+
+ return 0;
+}
+
+int subscAddGprsPdpData(T_SUBSC_INFO *info, T_SUBSC_GPRS_DATA *data)
+{
+ T_SUBSC_IE_GPRS_DATA_INFO* gprs_data = subscGetGPRSDataPtr(info);
+ if(gprs_data == 0) return -1; // can't get pointer to the gprs_data
+ if(data == 0) return -1; // just being cautious
+ int index;
+ T_SUBSC_GPRS_DATA *pdp_data = subscFindGprsPdpData(info, data->pdpContextId, &index);
+ if(pdp_data != 0) return 1; // pdp data exists
+ if(index != -1) return 2; // internal error
+
+ if(gprs_data->num_data == MAX_NUM_SUBSC_GPRS_DATA) return 3; // list full
+
+ memcpy(&gprs_data->data[gprs_data->num_data], data, sizeof(T_SUBSC_GPRS_DATA));
+ gprs_data->num_data++;
+
+ return 0;
+}
+
+int subscDelGprsPdpData(T_SUBSC_INFO *info, unsigned char pdpContextId)
+{
+ T_SUBSC_IE_GPRS_DATA_INFO* gprs_data = subscGetGPRSDataPtr(info);
+ if(gprs_data == 0) return -1; // can't get pointer to the gprs_data
+ int index;
+ T_SUBSC_GPRS_DATA *pdp_data = subscFindGprsPdpData(info, pdpContextId, &index);
+ if(pdp_data == 0) return 1; // pdp data doesn't exists
+ if(index == -1) return 2; // internal error
+
+ if(gprs_data->num_data == 0) return 3; // internal error, empty list
+
+ if(gprs_data->num_data != 1){ // not the last one
+ memcpy(pdp_data, &gprs_data->data[gprs_data->num_data-1], sizeof(T_SUBSC_GPRS_DATA));
+ }
+ gprs_data->num_data--;
+
+ return 0;
+}
+
+int subscModifyGprsPdpData(T_SUBSC_INFO *info, T_SUBSC_GPRS_DATA *data)
+{
+ T_SUBSC_IE_GPRS_DATA_INFO* gprs_data = subscGetGPRSDataPtr(info);
+ if(gprs_data == 0) return -1; // can't get pointer to the gprs_data
+ if(data == 0) return -1; // just being cautious
+ int index;
+ T_SUBSC_GPRS_DATA *pdp_data = subscFindGprsPdpData(info, data->pdpContextId, &index);
+
+ if(index == -1) return 2; // internal error
+
+ if(gprs_data->num_data == MAX_NUM_SUBSC_GPRS_DATA) return 3; // list full
+
+ memcpy(&gprs_data->data[index], data, sizeof(T_SUBSC_GPRS_DATA));
+// gprs_data->num_data++;
+
+ return 0;
+}
+
+int subscGetClassInfo(T_SUBSC_INFO *info, unsigned char* classId) // 2.1.2
+{
+ if (info == 0) return -1;
+
+ T_SUBSC_IE_IN_PROFILE* in_profile = &(info->in_profile);
+
+ if (in_profile->isPresent == false) return -2;
+
+ *classId = in_profile->classInfo.classId;
+
+ return 0; // success
+}
+
+int subscGetPrepaidIndicator(T_SUBSC_INFO *info, bool* isPrepaid) // 2.1.2
+{
+ if (info == 0) return -1;
+
+ T_SUBSC_IE_IN_PROFILE* in_profile = &(info->in_profile);
+
+ if (in_profile->isPresent == false) return -2;
+
+ *isPrepaid = in_profile->prepaidIndicator.isPrepaid;
+
+ return 0; // success
+}
+
+int subscSetInProfile(T_SUBSC_INFO *info, T_SUBSC_IE_IN_PROFILE *inProf)
+{
+ if (info == 0) return -1;
+
+ info->in_profile = *inProf;
+
+ return 0; // success
+} \ No newline at end of file
diff --git a/data/mnet/Common/vxTemplate/Makefile b/data/mnet/Common/vxTemplate/Makefile
new file mode 100644
index 0000000..bd4611d
--- /dev/null
+++ b/data/mnet/Common/vxTemplate/Makefile
@@ -0,0 +1,47 @@
+##########################################################
+#
+# (c) Copyright Cisco 2000
+# All Rights Reserved
+#
+# Use Examples:
+#
+# Case 1:
+# make all VOB=GP10 -
+# Places .out in VOB/bin directory
+#
+# Case 2:
+# make all VOB=GP10 APPDIR=Host\<Application Name>\<Source Directory> -
+# Places .o file(s) in VOB\$(APPDIR)\bin directory.
+#
+# <Application Name> = Name of Application directory
+# <Source Directory> = application sub directory where the calling
+# Makefile resides.
+#
+# Example: make all VOB=GP10 APPDIR=Host\vxTemplate\src
+#
+# (OPTIONAL) Append REPLACE - Replaces the List of directories
+# to be used in the SUBDIRS variable
+#
+# Example: make all VOB=GP10 APPDIR=Host\vxTemplate\src REPLACE=src
+#
+# Note: This make file must reference a VOB that
+# has a defs.mk in the top level directory.
+#
+##########################################################
+
+SUBDIRS = src
+
+# TOP_OF_VOB must be defined before including l3defs.mk
+TOP_OF_VOB = ..\..
+
+VOBDIR = $(TOP_OF_VOB)\$(VOB)
+
+# Allows a sub-set of the source code directories to be used
+
+ifneq ($(REPLACE),)
+ SUBDIRS = $(REPLACE)
+endif
+
+include $(VOBDIR)\l3defs.mk
+
+
diff --git a/data/mnet/Common/vxTemplate/include/vxTemplate.h b/data/mnet/Common/vxTemplate/include/vxTemplate.h
new file mode 100644
index 0000000..dd20de5
--- /dev/null
+++ b/data/mnet/Common/vxTemplate/include/vxTemplate.h
@@ -0,0 +1,33 @@
+/********************************************************************
+ *
+ * (c) Copyright Cisco 2000
+ * All Rights Reserved
+ *
+ ********************************************************************/
+
+/********************************************************************
+ *
+ * Version : 1.0
+ * Status : Under development
+ * File : template.h
+ * Author(s) : Lou Travaglione
+ * Create Date : 8/29/00
+ * Description : Demo header code for template directory.
+ *
+ ********************************************************************/
+
+#ifndef _TEMPLATE_H_
+#define _TEMPLATE_H_
+
+/*************************************************************
+ *
+ * Module Name: Hello_World
+ *
+ * Function: Demo function for template directory.
+ *
+ *************************************************************/
+
+void Hello_World(void);
+
+
+#endif /* _TEMPLATE_H_ */ \ No newline at end of file
diff --git a/data/mnet/Common/vxTemplate/src/Makefile b/data/mnet/Common/vxTemplate/src/Makefile
new file mode 100644
index 0000000..397f0a7
--- /dev/null
+++ b/data/mnet/Common/vxTemplate/src/Makefile
@@ -0,0 +1,61 @@
+##########################################################
+#
+# (c) Copyright Cisco 2000
+# All Rights Reserved
+#
+# Use Examples:
+#
+# Case 1:
+# make all VOB=GP10 -
+# Places .out in VOB/bin directory
+#
+# Case 2:
+# make all VOB=GP10 APPDIR=Host\<Application Name>\<Source Directory> -
+# Places .o file(s) in VOB\$(APPDIR)\bin directory.
+#
+# <Application Name> = Name of Application directory
+# <Source Directory> = application sub directory where the calling
+# Makefile resides.
+#
+# Example: make all VOB=GP10 APPDIR=Host\vxTemplate\src
+#
+#
+# Note: This make file must reference a VOB that
+# has a defs.mk in the top level directory.
+#
+##########################################################
+
+# TOP_OF_VOB must be defined before including l3defs.mk
+TOP_OF_VOB = ..\..
+
+# Name of this App's Directory
+THIS_APP_DIR = vxTemplate
+
+VOB2DIR = $(TOP_OF_VOB)\..\$(VOB)
+BINDIR = ..\bin
+
+ifeq ($(APPDIR),)
+ MY_OUTPUT = $(VOB2DIR)\bin\$(THIS_APP_DIR).out
+else
+ MY_OUTPUT = $(OBJDIR)\$(THIS_APP_DIR).out
+endif
+
+include $(VOB2DIR)\l3defs.mk
+
+
+all: $(MY_OUTPUT)
+
+$(MY_OUTPUT): $(MODULE_OBJS)
+ $(LD) -r -o $@.tmp $(MODULE_OBJS)
+ $(NM) $@.tmp | munch > _ctdt.c
+ $(CC) -traditional $(CC_ARCH_SPEC) -c _ctdt.c
+ $(LD) -r -o $@ _ctdt.o $@.tmp
+ $(RM)$(subst /,$(DIRCHAR), _ctdt.c _ctdt.o $@.tmp)
+
+cleanall:
+ @for %f in ($(notdir $(MODULE_OBJS))) do \
+ $(RM) ..\bin\%f
+
+ $(RM) $(MY_OUTPUT)
+
+
diff --git a/data/mnet/Common/vxTemplate/src/vxTemplate.c b/data/mnet/Common/vxTemplate/src/vxTemplate.c
new file mode 100644
index 0000000..1a17995
--- /dev/null
+++ b/data/mnet/Common/vxTemplate/src/vxTemplate.c
@@ -0,0 +1,34 @@
+/* *******************************************************************
+ *
+ * (c) Copyright Cisco 2000
+ * All Rights Reserved
+ *
+ *********************************************************************/
+
+/*********************************************************************
+ *
+ * Version : 1.0
+ * Status : Under development
+ * File : vxTemplate.c
+ * Author(s) : Lou Travaglione
+ * Create Date : 8/29/00
+ * Description : Demo source code for vxTemplate directory.
+ *
+ *********************************************************************/
+
+#include <stdio.h>
+#include "vxTemplate.h"
+
+/*************************************************************
+ *
+ * Module Name: Hello_World
+ *
+ * Function: Demo function for template directory.
+ *
+ *************************************************************/
+
+void Hello_World(void)
+{
+ printf("Hello World\n");
+}
+