Compare commits

...

3 Commits

Author SHA1 Message Date
Rick Sommerville
f3fc398eac WIFI-2416 Automatically get redirector from DigiCert
Signed-off-by: Rick Sommerville <rick.sommerville@netexperience.com>
2021-05-22 22:20:15 -04:00
Rick Sommerville
7aea689d9a WIFI-2381: Query DigiCert's API for Redirector's address
Signed-off-by: Max Brenner <xamrennerb@gmail.com>
Signed-off-by: Rick Sommerville <rick.sommerville@netexperience.com>
2021-05-19 16:52:35 -04:00
Chaitanya Godavarthi
7a634d80ed APC: Fix memory leaks
Fixed memory leaks in apc and interapcomm modules.

Signed-off-by: Rick Sommerville <rick.sommerville@netexperience.com>
2021-04-30 12:32:38 -04:00
8 changed files with 60 additions and 9 deletions

View File

@@ -30,4 +30,9 @@ static inline timer * tm_new_set( void (*hook)(struct _timer *), void *data, uns
return t;
}
static inline void tm_free(timer *t)
{
free(t);
}
#endif

View File

@@ -26,7 +26,8 @@ static void apc_dump( struct proto * P )
static struct proto * apc_init(struct proto_config * c)
{
struct proto * P = mb_allocz(sizeof(struct apc_proto));
printf("apc_init\n");
P->cf = c;
P->debug = c->debug;
P->mrtdump = c->mrtdump;

View File

@@ -103,6 +103,7 @@ void apc_send_hello(struct apc_iface * ifa, int kind )
struct apc_hello2_packet ps;
unsigned int length, report = 0;
struct apc_spec ApcSpec;
char dst_ip[16];
if (WaitingToReelect )
return;
@@ -202,8 +203,7 @@ void apc_send_hello(struct apc_iface * ifa, int kind )
length += i * sizeof(u32);
printf("HELLO packet sent via %s\n", ifa->ifname );
char *dst_ip = malloc(16);
printf("HELLO packet sent via %s\n", ifa->ifname );
memset(dst_ip, 0, 16);
if ((get_current_ip(dst_ip, IAC_IFACE)) < 0) {
printf("Error: Cannot get IP for %s", IAC_IFACE);

View File

@@ -36,7 +36,7 @@ reset_lists(struct apc_proto *p, struct apc_neighbor *n)
struct apc_neighbor * apc_neighbor_new(struct apc_iface * ifa)
{
struct apc_neighbor * n = mb_allocz(sizeof(struct apc_neighbor));
printf("apc_new_neighbor\n");
n->ifa = ifa;
add_tail(&ifa->neigh_list, NODE n);
n->adj = 0;
@@ -58,6 +58,8 @@ static void apc_neigh_down(struct apc_neighbor * n)
rem_node(NODE n);
printf("Neighbor %x on %s removed", n->rid, ifa->ifname );
tm_free(n->inactim);
mb_free(n);
}
/**

View File

@@ -26,6 +26,7 @@ static void receive_data_uloop(struct uloop_fd *fd, unsigned int events)
printf("recvfrom() failed");
ra.cb(recv_data, recv_data_len);
free(recv_data);
}
@@ -41,6 +42,7 @@ static void receive_data(struct ev_loop *ev, ev_io *io, int event)
printf("recvfrom() failed");
ra.cb(recv_data, recv_data_len);
free(recv_data);
}

View File

@@ -1,12 +1,45 @@
#!/bin/sh
if [ $# -ne 1 ] ; then
echo "Usage: $0 <redirector address>" >&2
exit 1
AP_PRIVATE_KEY_FILE="/usr/opensync/certs/client_dec.key"
AP_CERTIFICATE_FILE="/usr/opensync/certs/client.pem"
AP_DEVICE_ID_FILE="/usr/opensync/certs/client_deviceid.txt"
DIGICERT_API_URI="clientauth.one.digicert.com"
if [ "$1" = "-h" ]; then
echo "Usage: $0 [redirector address]" >&2
exit 1
fi
redirector_addr=$1
# Query DigiCert's API if redirector wasn't specified
if [ -z "$1" ]; then
if [ ! -f "$AP_DEVICE_ID_FILE" ]; then
echo "Device ID file $AP_DEVICE_ID_FILE does not exist. Make sure to create it or specify the redirector address manually."
exit 1
fi
# TODO: this command should be retried if it fails
digicert_device_id=`cat ${AP_DEVICE_ID_FILE}`
device_data=`curl -s \
--key "${AP_PRIVATE_KEY_FILE}" \
--cert "${AP_CERTIFICATE_FILE}" \
"https://${DIGICERT_API_URI}/iot/api/v2/device/${digicert_device_id}"`
controller_url=`echo ${device_data} | jsonfilter -e '@.fields[@.name="Redirector"].value'`
if [ -z "$controller_url" ]; then
echo "No redirector found for this device"
exit 1
fi
controller_port=`echo ${controller_url} | cut -d ":" -f2)`
if [ -z "$controller_port" ]; then
redirector_addr="ssl:${controller_url}:6643"
else
redirector_addr="ssl:${controller_url}"
fi
else
redirector_addr=$1
fi
uci set system.tip.redirector="${redirector_addr}"
uci set system.tip.deployed=0
uci commit system
/etc/init.d/opensync restart

View File

@@ -37,6 +37,14 @@ start_service() {
echo "Setting certificates"
mkdir -p ${CERTS_DEST_PATH}
cp ${CERTS_SRC_PATH}/* ${CERTS_DEST_PATH}/
echo "Checking Redirector"
redirector=$(uci get system.tip.redirector)
if [ -z "$redirector" ]; then
logger -t opensync "Contacting DigiCert for redirector address"
wlan_ap_redirector.sh
else
logger -t opensync "Redirector address is ${redirector}"
fi
echo "Starting OpenSync"
procd_set_param command ${PROG}
procd_close_instance

View File

@@ -130,6 +130,7 @@ static int rx_msg(struct nl_msg *msg, void* arg)
struct nlattr *attr[GENL_UCC_ATTR_MAX+1];
struct voip_session *data;
char dst_ip[16];
genlmsg_parse(nlmsg_hdr(msg), 0, attr,
GENL_UCC_ATTR_MAX, genl_ucc_policy);
@@ -140,7 +141,6 @@ static int rx_msg(struct nl_msg *msg, void* arg)
return NL_OK;
}
char *dst_ip = malloc(16);
memset(dst_ip, 0, 16);
if((get_current_ip(dst_ip, IAC_IFACE)) < 0) {
LOGI("Error: Cannot get IP for %s", IAC_IFACE);