|
|
|
@ -1109,8 +1109,15 @@ enum {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
sxlink_t *sxlink_connect(sxhub_t *hub, const char *host,
|
|
|
|
|
int port, const char *SSL_cert, const char *login,
|
|
|
|
|
const char *passwd)
|
|
|
|
|
int port, const char *SSL_cert, const char *login,
|
|
|
|
|
const char *passwd)
|
|
|
|
|
{
|
|
|
|
|
return sxlink_connect_at(hub, host, port, SSL_cert, login, passwd, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sxlink_t *sxlink_connect_at(sxhub_t *hub, const char *host,
|
|
|
|
|
int port, const char *SSL_cert, const char *login,
|
|
|
|
|
const char *passwd, const void *priv)
|
|
|
|
|
{
|
|
|
|
|
sxlink_t *link = __link_minimal_alloc(NULL);
|
|
|
|
|
struct hostent *host_;
|
|
|
|
@ -1202,6 +1209,9 @@ sxlink_t *sxlink_connect(sxhub_t *hub, const char *host,
|
|
|
|
|
bbuf += sizeof(sxmplv2_head_t);
|
|
|
|
|
head = (sxmplv2_head_t *)buf;
|
|
|
|
|
|
|
|
|
|
/* set out data */
|
|
|
|
|
if(priv) sxlink_setpriv(link, priv);
|
|
|
|
|
|
|
|
|
|
/* authentification first both V2 and newer */
|
|
|
|
|
/* form a message -- credentials */
|
|
|
|
|
ln = snprintf(bbuf, 65535 - sizeof(sxmplv2_head_t), "(auth-set-credentials \"%s\" \"%s\")",
|
|
|
|
@ -1210,13 +1220,13 @@ sxlink_t *sxlink_connect(sxhub_t *hub, const char *host,
|
|
|
|
|
head->opcode = SXE_SUCCESS;
|
|
|
|
|
head->payload_length = ln;
|
|
|
|
|
wr = __conn_write(link, buf, ln + sizeof(sxmplv2_head_t));
|
|
|
|
|
if(wr < 0) goto __fail2;
|
|
|
|
|
if(wr < 0) goto __fail3;
|
|
|
|
|
|
|
|
|
|
rd = __conn_read(link, head, sizeof(sxmplv2_head_t));
|
|
|
|
|
if(rd < 0) goto __fail2;
|
|
|
|
|
if(rd < 0) goto __fail3;
|
|
|
|
|
if(head->opcode != SXE_SUCCESS) {
|
|
|
|
|
r = head->opcode;
|
|
|
|
|
goto __fail2;
|
|
|
|
|
goto __fail3;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* since V2.1 syncronization should be done here */
|
|
|
|
@ -1238,22 +1248,22 @@ sxlink_t *sxlink_connect(sxhub_t *hub, const char *host,
|
|
|
|
|
/* write a message */
|
|
|
|
|
head->payload_length = ln;
|
|
|
|
|
wr = __conn_write(link, buf, ln + sizeof(sxmplv2_head_t));
|
|
|
|
|
if(wr < 0) goto __fail2;
|
|
|
|
|
if(wr < 0) goto __fail3;
|
|
|
|
|
|
|
|
|
|
rd = __conn_read(link, head, sizeof(sxmplv2_head_t));
|
|
|
|
|
if(rd < 0) goto __fail2;
|
|
|
|
|
if(head->opcode != SXE_SUCCESS) goto __fail2;
|
|
|
|
|
if(rd < 0) goto __fail3;
|
|
|
|
|
if(head->opcode != SXE_SUCCESS) goto __fail3;
|
|
|
|
|
if(!head->payload_length) {
|
|
|
|
|
sync_state++;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
rd = __conn_read(link, bbuf, head->payload_length);
|
|
|
|
|
if(rd < 0) goto __fail2;
|
|
|
|
|
if(rd < 0) goto __fail3;
|
|
|
|
|
|
|
|
|
|
/* perform a parsing of the desired message */
|
|
|
|
|
bbuf[rd] = '\0';
|
|
|
|
|
sx = parse_sexp(bbuf, rd);
|
|
|
|
|
if(!sx) { r = SXE_BADPROTO; goto __fail2; }
|
|
|
|
|
if(!sx) { r = SXE_BADPROTO; goto __fail3; }
|
|
|
|
|
r = __eval_syssexp(link, sx);
|
|
|
|
|
if(!r) r = SXE_SUCCESS;
|
|
|
|
|
destroy_sexp(sx);
|
|
|
|
@ -1263,8 +1273,8 @@ sxlink_t *sxlink_connect(sxhub_t *hub, const char *host,
|
|
|
|
|
head->opcode = r;
|
|
|
|
|
head->payload_length = 0;
|
|
|
|
|
wr = __conn_write(link, head, sizeof(sxmplv2_head_t));
|
|
|
|
|
if(wr < 0) { r = SXE_LINKERROR; goto __fail2;}
|
|
|
|
|
if(r != SXE_SUCCESS) { r = SXE_LINKERROR; goto __fail2;}
|
|
|
|
|
if(wr < 0) { r = SXE_LINKERROR; goto __fail3;}
|
|
|
|
|
if(r != SXE_SUCCESS) { r = SXE_LINKERROR; goto __fail3;}
|
|
|
|
|
}
|
|
|
|
|
sync_state++;
|
|
|
|
|
}
|
|
|
|
|