library/Osmocom_VTY_Functions: cosmetic: coding style changes
Change-Id: Idccdf6fcbda2d020d2263ea1440ea1c5d9ea0e45
This commit is contained in:
parent
e00776c5db
commit
26e30aa4e0
|
@ -56,39 +56,40 @@ module Osmocom_VTY_Functions {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* wait for any of the permitted prompts; buffer + return all intermediate output */
|
/* wait for any of the permitted prompts; buffer + return all intermediate output */
|
||||||
function f_vty_wait_for_prompt(TELNETasp_PT pt, boolean strict := true, charstring log_label := "(?)") return charstring {
|
function f_vty_wait_for_prompt(TELNETasp_PT pt, boolean strict := true, charstring log_label := "(?)")
|
||||||
|
return charstring {
|
||||||
var charstring rx, buf := "";
|
var charstring rx, buf := "";
|
||||||
var integer fd;
|
var integer fd;
|
||||||
timer T := 2.0;
|
timer T := 2.0;
|
||||||
|
|
||||||
T.start;
|
T.start;
|
||||||
alt {
|
alt {
|
||||||
[] pt.receive(pattern "[\w-]+" & VTY_VIEW_SUFFIX) { };
|
[] pt.receive(pattern "[\w-]+" & VTY_VIEW_SUFFIX) { };
|
||||||
[] pt.receive(pattern "[\w-]+\# ") { };
|
[] pt.receive(pattern "[\w-]+\# ") { };
|
||||||
[] pt.receive(pattern "[\w-]+\(*\)\# ") { };
|
[] pt.receive(pattern "[\w-]+\(*\)\# ") { };
|
||||||
[] pt.receive(t_vty_unknown) -> value rx {
|
[] pt.receive(t_vty_unknown) -> value rx {
|
||||||
if (strict) {
|
if (strict) {
|
||||||
setverdict(fail, "VTY: Unknown Command: " & log_label);
|
setverdict(fail, "VTY: Unknown Command: " & log_label);
|
||||||
mtc.stop;
|
|
||||||
} else {
|
|
||||||
log("VTY: Unknown Command (ignored): " & log_label);
|
|
||||||
buf := buf & rx;
|
|
||||||
repeat;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
[] pt.receive(charstring:?) -> value rx { buf := buf & rx; repeat };
|
|
||||||
[] pt.receive(integer:?) -> value fd {
|
|
||||||
if (fd == -1) {
|
|
||||||
setverdict(fail, "VTY Telnet Connection Failure: " & log_label);
|
|
||||||
mtc.stop;
|
|
||||||
} else {
|
|
||||||
repeat; /* telnet connection succeeded */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
[] T.timeout {
|
|
||||||
setverdict(fail, "VTY Timeout for prompt: " & log_label);
|
|
||||||
mtc.stop;
|
mtc.stop;
|
||||||
};
|
} else {
|
||||||
|
log("VTY: Unknown Command (ignored): " & log_label);
|
||||||
|
buf := buf & rx;
|
||||||
|
repeat;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
[] pt.receive(charstring:?) -> value rx { buf := buf & rx; repeat };
|
||||||
|
[] pt.receive(integer:?) -> value fd {
|
||||||
|
if (fd == -1) {
|
||||||
|
setverdict(fail, "VTY Telnet Connection Failure: " & log_label);
|
||||||
|
mtc.stop;
|
||||||
|
} else {
|
||||||
|
repeat; /* telnet connection succeeded */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[] T.timeout {
|
||||||
|
setverdict(fail, "VTY Timeout for prompt: " & log_label);
|
||||||
|
mtc.stop;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
T.stop;
|
T.stop;
|
||||||
return buf;
|
return buf;
|
||||||
|
|
Loading…
Reference in New Issue