Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "util.h"
#include "dhcp_lease_monitor_thrd.h"

Expand Down Expand Up @@ -69,6 +70,40 @@
#define DHCPMGR_LOG_WARNING(fmt, ...) PLUGIN_DBG_PRINT(fmt, ##__VA_ARGS__)
#endif

static void trim(char *in)
{
if (NULL == in)
{
return;
}

char *start = in;
while (isspace((unsigned char)*start))
{
start++;
}

if (*start == '\0')
{
*in = '\0';
return;
}

char *end = start + strlen(start) - 1;

while (end >= start && isspace((unsigned char)*end))
{
*end = '\0';
end--;
}

if (start != in)
{
size_t len = strlen(start) + 1;
memmove(in, start, len);
}
}

static int get_and_fill_env_data_dhcp6(DHCPv6_PLUGIN_MSG *dhcpv6_data, char *input_option)
{
char *env;
Expand Down Expand Up @@ -220,11 +255,14 @@ static int get_and_fill_env_data_dhcp6(DHCPv6_PLUGIN_MSG *dhcpv6_data, char *inp
/** AFTR (Access Gateway for DS-Lite) */
if ((env = getenv(DHCPv6_OPTION_DSLITE)) != NULL)
{
strncpy(dhcpv6_data->aftr, env, sizeof(dhcpv6_data->aftr));
strncpy(dhcpv6_data->aftr, env, sizeof(dhcpv6_data->aftr) - 1);
dhcpv6_data->aftr[sizeof(dhcpv6_data->aftr) - 1] = '\0';
trim(dhcpv6_data->aftr);
DHCPMGR_LOG_INFO("[%s-%d] AFTR FQDN is %s\n", __FUNCTION__, __LINE__, dhcpv6_data->aftr);
}
else
{
DHCPMGR_LOG_INFO("[%s-%d] AFTR name is missing\n", __FUNCTION__, __LINE__);
DHCPMGR_LOG_INFO("[%s-%d] AFTR FQDN is missing\n", __FUNCTION__, __LINE__);
}

/** MAP-T Configuration */
Expand Down
2 changes: 1 addition & 1 deletion source/DHCPClientUtils/DHCPv6Client/dhcpv6_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ typedef struct _DHCPv6_PLUGIN_MSG

char domainName[BUFLEN_64]; /**< New domain Name, */
char ntpserver[BUFLEN_128]; /**< New ntp server(s), dhcp server may provide this */
char aftr[AFTR_NAME_LENGTH]; /**< dhcp server may provide this */
char aftr[AFTR_NAME_LENGTH]; /**< dhcp server may provide this */
uint32_t ipv6_TimeOffset; /**< New time offset */
struct _DHCPv6_PLUGIN_MSG *next; /** link to the next lease */
}DHCPv6_PLUGIN_MSG;
Expand Down
2 changes: 1 addition & 1 deletion source/DHCPMgrUtils/dhcpmgr_v6_lease_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ static bool compare_dhcpv6_plugin_msg(const DHCPv6_PLUGIN_MSG *currentLease, con
memcmp(&currentLease->mapt, &newLease->mapt, sizeof(currentLease->mapt)) != 0 ||
strcmp(currentLease->domainName, newLease->domainName) != 0 ||
strcmp(currentLease->ntpserver, newLease->ntpserver) != 0 ||
strcmp(currentLease->aftr, newLease->aftr) != 0)
strcmp(currentLease->aftr, newLease->aftr) != 0)
{
return false; // Structures are not equal
}
Expand Down
2 changes: 2 additions & 0 deletions source/TR-181/middle_layer_src/dhcpmgr_rbus_apis.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@ static void DhcpMgr_createDhcpv6LeaseInfoMsg(DHCPv6_PLUGIN_MSG *src, DHCP_MGR_IP
strncpy(dest->nameserver1, src->dns.nameserver1, sizeof(dest->nameserver1) - 1);
strncpy(dest->domainName, src->domainName, sizeof(dest->domainName) - 1);
snprintf(dest->sitePrefix, sizeof(dest->sitePrefix), "%s/%d", src->ia_pd.Prefix, src->ia_pd.PrefixLength);
strncpy(dest->aftr, src->aftr, sizeof(dest->aftr) - 1);
dest->aftr[sizeof(dest->aftr) - 1] = '\0';

dest->prefixPltime = src->ia_pd.PreferedLifeTime;
dest->prefixVltime = src->ia_pd.ValidLifeTime;
Expand Down