61 static int GetServerProtoVersion(
lua_State *luastate,
const Flow *f)
63 void *state = FlowGetAppState(f);
65 return LuaCallbackError(luastate,
"error: no app layer state");
69 void *tx = rs_ssh_state_get_tx(state, 0);
70 if (rs_ssh_tx_get_protocol(tx, &
protocol, &b_len, STREAM_TOCLIENT) != 1)
71 return LuaCallbackError(luastate,
"error: no server proto version");
72 if (
protocol == NULL || b_len == 0) {
73 return LuaCallbackError(luastate,
"error: no server proto version");
76 return LuaPushStringBuffer(luastate,
protocol, b_len);
79 static int SshGetServerProtoVersion(
lua_State *luastate)
84 return LuaCallbackError(luastate,
"error: protocol not ssh");
86 Flow *f = LuaStateGetFlow(luastate);
88 return LuaCallbackError(luastate,
"internal error: no flow");
90 r = GetServerProtoVersion(luastate, f);
95 static int GetServerSoftwareVersion(
lua_State *luastate,
const Flow *f)
97 void *state = FlowGetAppState(f);
99 return LuaCallbackError(luastate,
"error: no app layer state");
101 const uint8_t *software = NULL;
104 void *tx = rs_ssh_state_get_tx(state, 0);
105 if (rs_ssh_tx_get_software(tx, &software, &b_len, STREAM_TOCLIENT) != 1)
106 return LuaCallbackError(luastate,
"error: no server software version");
107 if (software == NULL || b_len == 0) {
108 return LuaCallbackError(luastate,
"error: no server software version");
111 return LuaPushStringBuffer(luastate, software, b_len);
114 static int SshGetServerSoftwareVersion(
lua_State *luastate)
119 return LuaCallbackError(luastate,
"error: protocol not ssh");
121 Flow *f = LuaStateGetFlow(luastate);
123 return LuaCallbackError(luastate,
"internal error: no flow");
125 r = GetServerSoftwareVersion(luastate, f);
130 static int GetClientProtoVersion(
lua_State *luastate,
const Flow *f)
132 void *state = FlowGetAppState(f);
134 return LuaCallbackError(luastate,
"error: no app layer state");
139 void *tx = rs_ssh_state_get_tx(state, 0);
140 if (rs_ssh_tx_get_protocol(tx, &
protocol, &b_len, STREAM_TOSERVER) != 1)
141 return LuaCallbackError(luastate,
"error: no client proto version");
142 if (
protocol == NULL || b_len == 0) {
143 return LuaCallbackError(luastate,
"error: no client proto version");
146 return LuaPushStringBuffer(luastate,
protocol, b_len);
149 static int SshGetClientProtoVersion(
lua_State *luastate)
154 return LuaCallbackError(luastate,
"error: protocol not ssh");
156 Flow *f = LuaStateGetFlow(luastate);
158 return LuaCallbackError(luastate,
"internal error: no flow");
160 r = GetClientProtoVersion(luastate, f);
165 static int GetClientSoftwareVersion(
lua_State *luastate,
const Flow *f)
167 void *state = FlowGetAppState(f);
169 return LuaCallbackError(luastate,
"error: no app layer state");
171 const uint8_t *software = NULL;
174 void *tx = rs_ssh_state_get_tx(state, 0);
175 if (rs_ssh_tx_get_software(tx, &software, &b_len, STREAM_TOSERVER) != 1)
176 return LuaCallbackError(luastate,
"error: no client software version");
177 if (software == NULL || b_len == 0) {
178 return LuaCallbackError(luastate,
"error: no client software version");
181 return LuaPushStringBuffer(luastate, software, b_len);
184 static int SshGetClientSoftwareVersion(
lua_State *luastate)
189 return LuaCallbackError(luastate,
"error: protocol not ssh");
191 Flow *f = LuaStateGetFlow(luastate);
193 return LuaCallbackError(luastate,
"internal error: no flow");
195 r = GetClientSoftwareVersion(luastate, f);
201 int LuaRegisterSshFunctions(
lua_State *luastate)
204 lua_pushcfunction(luastate, SshGetServerProtoVersion);
205 lua_setglobal(luastate,
"SshGetServerProtoVersion");
207 lua_pushcfunction(luastate, SshGetServerSoftwareVersion);
208 lua_setglobal(luastate,
"SshGetServerSoftwareVersion");
210 lua_pushcfunction(luastate, SshGetClientProtoVersion);
211 lua_setglobal(luastate,
"SshGetClientProtoVersion");
213 lua_pushcfunction(luastate, SshGetClientSoftwareVersion);
214 lua_setglobal(luastate,
"SshGetClientSoftwareVersion");