Checks for psk and cert files
New indentation. FossilOrigin-Name: dc933bcd1f09da544d06ef1c35bb4693a74c896999f90a3897c9c5fcb8816e9b
This commit is contained in:
parent
638683d211
commit
dd7b4f46a5
@ -109,10 +109,12 @@ int run_join_d(struct sockaddr *sa)
|
||||
}
|
||||
sock_set_recvtimeout(sockfd, 1);
|
||||
|
||||
rc = connect(sockfd,(struct sockaddr*)sa,sock_addrlen((struct sockaddr*)sa));
|
||||
rc = connect(sockfd, (struct sockaddr *) sa,
|
||||
sock_addrlen((struct sockaddr *) sa));
|
||||
|
||||
if (rc < 0) {
|
||||
cw_log(LOG_ERR,"Can't connect to %s: %s\n",sock_addr2str(sa),strerror(errno));
|
||||
cw_log(LOG_ERR, "Can't connect to %s: %s\n", sock_addr2str(sa),
|
||||
strerror(errno));
|
||||
close(sockfd);
|
||||
return -1;
|
||||
}
|
||||
@ -122,10 +124,13 @@ int run_join_d(struct sockaddr *sa)
|
||||
|
||||
cw_dbg(DBG_DTLS, "Establishing DTLS session with %s", sock_addr2str(sa));
|
||||
|
||||
int dtls_conf_ok=0;
|
||||
|
||||
if (conf_dtls_psk) {
|
||||
conn->dtls_psk = conf_dtls_psk;
|
||||
conn->dtls_psk_len = strlen(conn->dtls_psk);
|
||||
conn->dtls_cipher = conf_dtls_cipher;
|
||||
dtls_conf_ok=1;
|
||||
}
|
||||
|
||||
if (conf_sslkeyfilename && conf_sslcertfilename) {
|
||||
@ -134,21 +139,29 @@ int run_join_d(struct sockaddr *sa)
|
||||
conn->dtls_cert_file = conf_sslcertfilename;
|
||||
conn->dtls_key_pass = conf_sslkeypass;
|
||||
conn->dtls_cipher = conf_dtls_cipher;
|
||||
|
||||
dtls_conf_ok=1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
rc = dtls_connect(conn);
|
||||
if (rc!=1){
|
||||
dtls_shutdown(conn);
|
||||
cw_log(LOG_ERR,"Can't establish DTLS connection to %s", sock_addr2str(sa));
|
||||
if (!dtls_conf_ok){
|
||||
cw_log(LOG_ERR,"Can't establish DTLS connection with %s, neither psk nor cert set in config",
|
||||
sock_addr2str(sa));
|
||||
close(sockfd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
cw_dbg (DBG_DTLS,"DTLS Connection successful established with %s",sock_addr2str(sa));
|
||||
rc = dtls_connect(conn);
|
||||
if (rc != 1) {
|
||||
dtls_shutdown(conn);
|
||||
cw_log(LOG_ERR, "Can't establish DTLS connection to %s",
|
||||
sock_addr2str(sa));
|
||||
close(sockfd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
cw_dbg(DBG_DTLS, "DTLS Connection successful established with %s",
|
||||
sock_addr2str(sa));
|
||||
|
||||
|
||||
|
||||
@ -165,22 +178,26 @@ int run_join(struct conn * conn)
|
||||
//
|
||||
// conn_send_msg(conn, conn->req_buffer);
|
||||
|
||||
|
||||
|
||||
int rc = cw_send_request(conn, CW_MSG_JOIN_REQUEST);
|
||||
|
||||
|
||||
|
||||
if (!cw_rcok(rc)) {
|
||||
if (rc > 0) {
|
||||
cw_log(LOG_ERR, "Can't Join AC at %s, AC said: %d - %s.",
|
||||
sock_addr2str(&conn->addr), rc, cw_strerror(rc));
|
||||
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
cw_log(LOG_ERR, "Can't Join AC at %s: %d - %s.",
|
||||
sock_addr2str(&conn->addr), errno, cw_strerror(rc));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
cw_dbg(DBG_ELEM,"Joined AC at %s, Join Result: %d - %s",sock_addr2str(&conn->addr),rc,cw_strresult(rc));
|
||||
cw_dbg(DBG_ELEM, "Joined AC at %s, Join Result: %d - %s",
|
||||
sock_addr2str(&conn->addr), rc, cw_strresult(rc));
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -191,17 +208,28 @@ int join()
|
||||
{
|
||||
struct conn *conn = get_conn();
|
||||
|
||||
cw_aciplist_t iplist = mbag_get_mavl(conn->local,CW_ITEM_CAPWAP_CONTROL_IP_ADDRESS_LIST);
|
||||
printf("Join\n");
|
||||
|
||||
cw_aciplist_t iplist =
|
||||
mbag_get_mavl(conn->local, CW_ITEM_CAPWAP_CONTROL_IP_ADDRESS_LIST);
|
||||
if (!iplist) {
|
||||
cw_log(LOG_ERR, "No IPs to join controller.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!mavl_get_count(iplist)){
|
||||
cw_log(LOG_ERR, "No IPs to join controller. IP list is empty.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
DEFINE_AVLITER(ii, iplist);
|
||||
avliter_foreach(&ii) {
|
||||
|
||||
cw_acip_t *ip = avliter_get(&ii);
|
||||
|
||||
cw_dbg(DBG_INFO,"Going to join CAWAP controller on %s",sock_addr2str(&ip->ip));
|
||||
cw_dbg(DBG_INFO, "Going to join CAWAP controller on %s",
|
||||
sock_addr2str(&ip->ip));
|
||||
|
||||
int rc = run_join_d((struct sockaddr *) &ip->ip);
|
||||
if (!rc)
|
||||
@ -216,7 +244,8 @@ int join()
|
||||
|
||||
}
|
||||
|
||||
printf("Nudel\n");
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user