33 static const char ssh_tx[] =
"suricata:ssh:tx";
48 struct LuaTx *ltx = (
struct LuaTx *)lua_newuserdata(L,
sizeof(*ltx));
54 luaL_getmetatable(L, ssh_tx);
55 lua_setmetatable(L, -2);
62 const uint8_t *buf = NULL;
64 struct LuaTx *ltx = luaL_testudata(L, 1, ssh_tx);
69 if (SCSshTxGetProtocol(ltx->
tx, &buf, &b_len,
flags) != 1) {
76 static int LuaSshTxGetServerProto(
lua_State *L)
78 return LuaSshTxGetProto(L, STREAM_TOCLIENT);
81 static int LuaSshTxGetClientProto(
lua_State *L)
83 return LuaSshTxGetProto(L, STREAM_TOSERVER);
88 const uint8_t *buf = NULL;
90 struct LuaTx *ltx = luaL_testudata(L, 1, ssh_tx);
95 if (SCSshTxGetSoftware(ltx->
tx, &buf, &b_len,
flags) != 1) {
102 static int LuaSshTxGetServerSoftware(
lua_State *L)
104 return LuaSshTxGetSoftware(L, STREAM_TOCLIENT);
107 static int LuaSshTxGetClientSoftware(
lua_State *L)
109 return LuaSshTxGetSoftware(L, STREAM_TOSERVER);
114 const uint8_t *buf = NULL;
116 struct LuaTx *ltx = luaL_testudata(L, 1, ssh_tx);
121 if (SCSshTxGetHassh(ltx->
tx, &buf, &b_len,
flags) != 1) {
128 static int LuaSshTxGetClientHassh(
lua_State *L)
130 return LuaSshTxGetHassh(L, STREAM_TOSERVER);
133 static int LuaSshTxGetServerHassh(
lua_State *L)
135 return LuaSshTxGetHassh(L, STREAM_TOCLIENT);
140 const uint8_t *buf = NULL;
142 struct LuaTx *ltx = luaL_testudata(L, 1, ssh_tx);
147 if (SCSshTxGetHasshString(ltx->
tx, &buf, &b_len,
flags) != 1) {
154 static int LuaSshTxGetClientHasshString(
lua_State *L)
156 return LuaSshTxGetHasshString(L, STREAM_TOSERVER);
159 static int LuaSshTxGetServerHasshString(
lua_State *L)
161 return LuaSshTxGetHasshString(L, STREAM_TOCLIENT);
164 static const struct luaL_Reg txlib[] = {
166 {
"server_proto", LuaSshTxGetServerProto },
167 {
"server_software", LuaSshTxGetServerSoftware },
168 {
"client_proto", LuaSshTxGetClientProto },
169 {
"client_software", LuaSshTxGetClientSoftware },
170 {
"client_hassh", LuaSshTxGetClientHassh },
171 {
"server_hassh", LuaSshTxGetServerHassh },
172 {
"client_hassh_string", LuaSshTxGetClientHasshString },
173 {
"server_hassh_string", LuaSshTxGetServerHasshString },
178 static int LuaSshEnableHassh(
lua_State *L)
184 static const struct luaL_Reg sshlib[] = {
186 {
"get_tx", LuaSshGetTx },
187 {
"enable_hassh", LuaSshEnableHassh },
194 luaL_newmetatable(L, ssh_tx);
195 lua_pushvalue(L, -1);
196 lua_setfield(L, -2,
"__index");
197 luaL_setfuncs(L, txlib, 0);
199 luaL_newlib(L, sshlib);