Skip to content
Snippets Groups Projects
Commit f27b0a3d authored by Mohd Mehdi's avatar Mohd Mehdi
Browse files

dhcpmngr: add micro service for Device.DHCPv4. and Device.DHCPv6.

* add support for DHCP data model objects as micro service (moved
  from bbfdm)
* add udhcpc.user.d script to keep track of remaining lease time
  (moved from bbfdm)
* replace function calls that do not work in micro service mode
* add pipeline
parent bd1d52b1
No related branches found
No related tags found
1 merge request!1dhcpmngr: add micro service for Device.DHCPv4. and Device.DHCPv6.
Pipeline #149859 passed
include:
- project: 'iopsys/gitlab-ci-pipeline'
file: '/static-code-analysis.yml'
ref: '0.31'
stages:
- static_code_analysis
variables:
DEBUG: 'TRUE'
SOURCE_FOLDER: "./src"
FLAWFINDER_OPTIONS: "-m 4 --error-level=5"
CPPCHECK_OPTIONS: "--enable=all --error-exitcode=1"
COMPILE: "./gitlab-ci/compile.sh"
# DHCP Manager
This package contains code for the Device.DHCPv4. and Device.DHCPv6. objects.
## Dependencies
- For DHCP server, UCI file dhcp is being used (package dnsmasq).
- For DHCP client, UCI file network is being used (package netifd).
#!/bin/bash
echo "Install dependencies"
orig_dir=$(pwd)
echo $orig_dir
source ./gitlab-ci/shared.sh
# install bbfdm
install_bbfdm
# compile
set -e
echo "build stage"
cd $orig_dir/src/
pwd
#!/bin/bash
function exec_cmd()
{
echo "executing $@"
$@ >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo "Failed to execute $@"
exit 1
fi
}
function install_bbfdm()
{
[ -d "/opt/dev/bbfdm" ] && rm -rf /opt/dev/bbfdm
if [ -n "${BBFDM_BRANCH}" ]; then
exec_cmd git clone -b ${BBFDM_BRANCH} https://dev.iopsys.eu/bbf/bbfdm.git /opt/dev/bbfdm
else
exec_cmd git clone https://dev.iopsys.eu/bbf/bbfdm.git /opt/dev/bbfdm
fi
cd /opt/dev/bbfdm
./gitlab-ci/install-dependencies.sh install
./gitlab-ci/setup.sh install
}
LIB = libdhcpmngr.so
LIB_OBJS = dhcpmngr.o dhcpv4.o dhcpv6.o
PROG_CFLAGS = $(CFLAGS) -Wall -Werror -fPIC
LIB_LDFLAGS = $(LDFLAGS)
%.o: %.c
$(CC) $(PROG_CFLAGS) -c -o $@ $<
all: $(LIB)
$(LIB): $(LIB_OBJS)
$(CC) $(PROG_CFLAGS) -shared -o $@ $^ $(LIB_LDFLAGS)
clean:
rm -f *.o $(LIB)
/*
* Copyright (C) 2024 iopsys Software Solutions AB
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 2.1
* as published by the Free Software Foundation
*
* Author Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
*
*/
#include "dhcpmngr.h"
#include "dhcpv4.h"
#include "dhcpv6.h"
DMOBJ tDHCPObjs[] = {
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/
{"DHCPv4", &DMREAD, NULL, NULL, "file:/lib/netifd/proto/dhcp.sh,/etc/config/dhcp", NULL, NULL, NULL, tDHCPv4Obj, tDHCPv4Params, NULL, BBFDM_BOTH, NULL},
{"DHCPv6", &DMREAD, NULL, NULL, "file:/lib/netifd/proto/dhcpv6.sh,/etc/config/dhcp", NULL, NULL, NULL, tDHCPv6Obj, tDHCPv6Params, NULL, BBFDM_BOTH, NULL},
{0}
};
/* ********** DynamicObj ********** */
DM_MAP_OBJ tDynamicObj[] = {
/* parentobj, nextobject, parameter */
{"Device.", tDHCPObjs, NULL},
{0}
};
/*
* Copyright (C) 2024 iopsys Software Solutions AB
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 2.1
* as published by the Free Software Foundation
*
* Author: Anis Ellouze <anis.ellouze@pivasoftware.com>
* Author: Omar Kallel <omar.kallel@pivasoftware.com>
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
*
*/
#ifndef __DHCPMNGR_H
#define __DHCPMNGR_H
#include "libbbfdm-api/dmcommon.h"
extern DMOBJ tDHCPObjs[];
#endif
This diff is collapsed.
/*
* Copyright (C) 2024 iopsys Software Solutions AB
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 2.1
* as published by the Free Software Foundation
*
* Author: Anis Ellouze <anis.ellouze@pivasoftware.com>
*
*/
#ifndef __DHCP_H
#define __DHCP_H
#include "libbbfdm-api/dmcommon.h"
extern DMOBJ tDHCPv4Obj[];
extern DMOBJ tDHCPv4ServerObj[];
extern DMOBJ tDHCPv4ServerPoolObj[];
extern DMOBJ tDHCPv4ServerPoolClientObj[];
extern DMLEAF tDHCPv4ServerPoolParams[];
extern DMLEAF tDHCPv4ServerPoolStaticAddressParams[];
extern DMLEAF tDHCPv4ServerPoolClientParams[];
extern DMLEAF tDHCPv4ServerPoolClientIPv4AddressParams[];
extern DMLEAF tDHCPv4Params[];
extern DMOBJ tDHCPv4ClientObj[];
extern DMLEAF tDHCPv4ClientParams[];
extern DMLEAF tDHCPv4ClientSentOptionParams[];
extern DMLEAF tDHCPv4ClientReqOptionParams[];
extern DMOBJ tDHCPv4ServerObj[];
extern DMLEAF tDHCPv4ServerParams[];
extern DMLEAF tDHCPv4ServerPoolOptionParams[];
extern DMLEAF tDHCPv4ServerPoolClientIPv4AddressParams[];
extern DMLEAF tDHCPv4ServerPoolClientOptionParams[];
extern DMOBJ tDHCPv4RelayObj[];
extern DMLEAF tDHCPv4RelayParams[];
extern DMLEAF tDHCPv4RelayForwardingParams[];
struct option_args
{
char *tag;
char *value;
};
int set_section_order(char *package, char *dmpackage, char* sect_type, struct uci_section *dmmap_sect, struct uci_section *conf, int set_force, char* order);
int get_value_in_mac_format(struct uci_section *s, char *option_name, bool type, char **value);
bool tag_option_exists(char *dmmap_package, char *section, char *opt_check, char *value_check, char *tag_name, char *tag_value);
char *generate_tag_option(char *dmmap_package, char *section, char *opt_check, char *value_check, char *tag_name);
int get_dhcp_client_interface(void *data, char **value);
#endif
This diff is collapsed.
/*
* Copyright (C) 2024 iopsys Software Solutions AB
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 2.1
* as published by the Free Software Foundation
*
* Author: Omar Kallel <omar.kallel@pivasoftware.com>
*/
#ifndef __DHCPV6_H
#define __DHCPV6_H
#include "libbbfdm-api/dmcommon.h"
extern DMOBJ tDHCPv6Obj[];
extern DMLEAF tDHCPv6Params[];
extern DMLEAF tDHCPv6ClientParams[];
extern DMOBJ tDHCPv6ServerObj[];
extern DMLEAF tDHCPv6ServerParams[];
extern DMOBJ tDHCPv6ServerPoolObj[];
extern DMLEAF tDHCPv6ServerPoolParams[];
extern DMOBJ tDHCPv6ServerPoolClientObj[];
extern DMLEAF tDHCPv6ServerPoolClientParams[];
extern DMLEAF tDHCPv6ServerPoolClientIPv6AddressParams[];
extern DMLEAF tDHCPv6ServerPoolClientIPv6PrefixParams[];
extern DMLEAF tDHCPv6ServerPoolClientOptionParams[];
extern DMLEAF tDHCPv6ServerPoolOptionParams[];
#endif //__DHCPV6_H
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment