devtls: implement "hangup" ctl message

This makes devtls connection directories compatible to
hangup function (see dial(2)).
This commit is contained in:
cinap_lenrek 2021-10-16 15:07:39 +00:00
parent bb2357de0c
commit 72d08816ab

View file

@ -1751,10 +1751,10 @@ tlswrite(Chan *c, void *a, long n, vlong off)
}else if(strcmp(cb->f[0], "alert") == 0){
if(cb->nf != 2)
error("usage: alert n");
m = strtol(cb->f[1], nil, 0);
Hangup:
if(tr->c == nil)
error("must set fd before sending alerts");
m = strtol(cb->f[1], nil, 0);
qunlock(&tr->in.seclock);
qunlock(&tr->out.seclock);
poperror();
@ -1767,6 +1767,9 @@ tlswrite(Chan *c, void *a, long n, vlong off)
tlsclosed(tr, SLClose);
return n;
} else if(strcmp(cb->f[0], "hangup") == 0){
m = ECloseNotify;
goto Hangup;
} else if(strcmp(cb->f[0], "debug") == 0){
if(cb->nf == 2){
if(strcmp(cb->f[1], "on") == 0)