Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added data strcutures for rpl instnace, dodag, parent amd mc #4

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
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
29 changes: 26 additions & 3 deletions include/rpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,34 @@
#ifndef _RPL_H_
#define _RPL_H_

#include <stdint.h>
#include <stddef.h>

#ifdef __cplusplus
extern "C" {
#endif

enum {
SUCCESS = 0,
FAILURE,
// Add specific return codes here
SUCCESS = 0,
FAILURE,

// Add specific return codes here
RPL_ERR_INSTANCE_ROOT_EXISTS,
};

typedef struct _rpl_ipv6_address{
union{
uint8_t addr8[16];
uint16_t addr16[8];
uint32_t addr32[4];
}ip6addr;
}rpl_ipv6_address_t;

typedef rpl_ipv6_address_t rpl_ipv6_prefix;

#ifdef __cplusplus
}
#endif

#endif // _RPL_H_

135 changes: 135 additions & 0 deletions include/rpl_configurations.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
/**
* @file
* Tripple Configurations
*/

/*
* Copyright (C) 2020 Authors of Tripple
*
* This file is subject to the terms and conditions. See the file LICENSE in
* the top level directory for more details.
*/

/**
* @ingroup Include
* @{
*
* @file
* @brief RPL Configurations
*
* @}
*/

#ifndef _RPL_CONFIGURATIONS_H_
#define _RPL_CONFIGURATIONS_H_

#ifdef __cplusplus
extern "C" {
#endif

/* Platform Related Configurations */

#define RPL_SUPPORTED_FOR_LWIP 0x01
#define RPL_SUPPORTED_FOR_UIP 0x02
#define RPL_SUPPORTED_FOR_RIOT 0x03
#define RPL_SUPPORTED_FOR_LINUX 0x04

#ifndef RPL_PLATFORM
#ifdef RPL_WITH_LWIP
#define RPL_PLATFORM RPL_SUPPORTED_FOR_LWIP
#define TIMER_INCLUDE "lwip_patimer.h"
#endif
#endif

#ifndef RPL_PLATFORM
#ifdef RPL_WITH_UIP
#define RPL_PLATFORM RPL_SUPPORTED_FOR_UIP
#endif
#endif

#ifndef RPL_PLATFORM
#ifdef RPL_WITH_RIOT
#define RPL_PLATFORM RPL_SUPPORTED_FOR_RIOT
#endif
#endif

#ifndef RPL_PLATFORM
#ifdef RPL_WITH_LINUX
#define RPL_PLATFORM RPL_SUPPORTED_FOR_LINUX
#endif
#endif


/* Static Mmeory Related Configuration */

#ifndef RPL_CONF_USE_STATIC_ALLOCATION
#define RPL_USE_STATIC_ALLOCATION 1
#else
#define RPL_USE_STATIC_ALLOCATION RPL_CONF_USE_STATIC_ALLOCATION
#endif

#if RPL_USE_STATIC_ALLOCATION

#ifndef RPL_CONF_MAXIMUM_RPL_INSTNACE
#define RPL_MAXIMUM_RPL_INSTNACE 2
#else
#define RPL_MAXIMUM_RPL_INSTNACE RPL_CONF_MAXIMUM_RPL_INSTNACE
#endif

#ifndef RPL_CONF_MAXIMUM_RPL_PARENT
#define RPL_MAXIMUM_RPL_PARENT 50
#else
#define RPL_MAXIMUM_RPL_PARENT RPL_CONF_MAXIMUM_RPL_PARENT
#endif

#endif

/* RPL Protocol Constants as per RFC 6550*/

#define DEFAULT_DIO_INTERVAL_MIN 3
#define DEFAULT_DIO_INTERVAL_DOUBLINGS 20
#define DEFAULT_DIO_REDUNDANCY_CONSTANT 10

/* Trickle Related Configurations */
#ifndef RPL_CONF_DIO_INTERVAL_MIN
#define RPL_DIO_INTERVAL_MIN DEFAULT_DIO_INTERVAL_MIN
#else
#define RPL_DIO_INTERVAL_MIN RPL_CONF_DIO_INTERVAL_MIN
#endif

#ifndef RPL_CONF_DIO_INTERVAL_DOUBLINGS
#define RPL_DIO_INTERVAL_DOUBLINGS DEFAULT_DIO_INTERVAL_DOUBLINGS
#else
#define RPL_DIO_INTERVAL_DOUBLINGS RPL_CONF_DIO_INTERVAL_DOUBLINGS
#endif

#ifndef RPL_CONF_DIO_REDUNDANCY_CONSTANT
#define RPL_DIO_REDUNDANCY_CONSTANT DEFAULT_DIO_REDUNDANCY_CONSTANT
#else
#define RPL_DIO_REDUNDANCY_CONSTANT RPL_CONF_DIO_REDUNDANCY_CONSTANT
#endif

/* Configuration common accross all the RPL instnaces a node
will be part of */
typedef struct _rpl_node_configurations{

}rpl_node_configurations_t;

/* In a given instnace a node can be part of only one DODAG
so it can have both instnace and DODAG specific configuration */
typedef struct _rpl_instance_configuration{

}rpl_instance_configuration_t;


typedef struct _rpl_configurations{
rpl_node_configurations_t stNodeConfig;
rpl_instance_configuration_t instance_config;
}rpl_configurations_t;

#ifdef __cplusplus
}
#endif

#endif /*_RPL_CONFIGURATIONS_H_*/

110 changes: 87 additions & 23 deletions include/rpl_papi.h
Original file line number Diff line number Diff line change
@@ -1,23 +1,87 @@
/*
* Copyright (C) 2020 Authors of Tripple
*
* This file is subject to the terms and conditions. See the file LICENSE in
* the top level directory for more details.
*/

/**
* @ingroup PAPI
* @{
*
* @file
* @brief Tripple Platform API exported header
*
* @}
*/

#ifndef _RPL_PAPI_H_
#define _RPL_PAPI_H_

#include <rpl.h>

#endif // _RPL_PAPI_H_
/*
* Copyright (C) 2020 Authors of Tripple
*
* This file is subject to the terms and conditions. See the file LICENSE in
* the top level directory for more details.
*/

/**
* @ingroup PAPI
* @{
*
* @file
* @brief Tripple Platform API exported header
*
* @}
*/

#ifndef _RPL_PAPI_H_
#define _RPL_PAPI_H_

#include "init.h"
#include "rpl.h"
#include "rpl_configurations.h"

#ifdef __cplusplus
extern "C" {
#endif

/* Memory Related Functions */
/* If some platform has its memory manager modules then
adopt it bu writting wrapper and register the below callbacks to handle the memory
allocation
*/
typedef void *(*pfmem_alloc)(size_t memsize);
typedef void (*pfmem_free)(void *memory);

/*********************************
Message Processing APIs
*********************************/
#define RPL_ICMPV6_MSG_TYPE 155
#define RPL_CTRL_MSG_CODE_DIS 0x00
#define RPL_CTRL_MSG_CODE_DIO 0x01
#define RPL_CTRL_MSG_CODE_DAO 0x02
#define RPL_CTRL_MSG_CODE_DAO_ACK 0x03
#define RPL_CTRL_MSG_CODE_DCO 0x04
#define RPL_CTRL_MSG_CODE_DCO_ACK 0x05

typedef struct _rpl_icmpv6_context{
uint8_t *icmpv6_msg_buff; /* ICMPv6 Message Buffer */
uint16_t length; /* ICMPv6 Message length */
rpl_ipv6_address_t *src_addr;
rpl_ipv6_address_t *dest_addr;
void *upperlayer_context;
}rpl_icmpv6_context_t;

/* Callback to send ICMPV6 message */
typedef int (*pfrpl_send_rpl_message)(rpl_icmpv6_context_t *message_ctx);
typedef struct _rpl_upperlayer_hooks{
pfrpl_send_rpl_message pfsendmsg;
}rpl_upperlayer_hooks_t;


/* Modules initialization */
typedef void * rpl_protocol_context;
typedef struct _rpl_instance_info{
rpl_ipv6_address_t dodag_id;
rpl_ipv6_address_t prefix;
uint8_t prefix_length;
uint8_t instance_id;
uint8_t join_as_root;
uint8_t isGrounded;
rpl_instance_configuration_t config;
}rpl_instance_info_t;
rpl_protocol_context rpl_init(rpl_node_configurations_t *config);
int rpl_add_root_instance(rpl_protocol_context rpl_ctx,
rpl_instance_info_t *instnace_info);
int rpl_start(rpl_protocol_context rpl_ctx);

int rpl_icmp6_handler(rpl_protocol_context rpl_ctx,
rpl_icmpv6_context_t *msg_context);

#ifdef __cplusplus
}
#endif

#endif /*_RPL_PAPI_H_*/

9 changes: 9 additions & 0 deletions include/rpl_uapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,13 @@

#include <rpl.h>

#ifdef __cplusplus
extern "C" {
#endif

#ifdef __cplusplus
}
#endif


#endif // _RPL_UAPI_H_
24 changes: 14 additions & 10 deletions src/Filelists.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,22 @@ else ("${TRPL_VERSION_RC}" STREQUAL "TRPL_RC_RELEASE")
endif ("${TRPL_VERSION_RC}" STREQUAL "TRPL_RC_RELEASE")

# The minimum set of files needed for tripple.
set(trplcore_SRCS
${TRPL_DIR}/src/core/msg_handler.c
)
#set(trplcore_SRCS
# ${TRPL_DIR}/src/core/msg_handler.c
#)

set(trpluapi_SRCS
${TRPL_DIR}/src/uapi/uapi_rpl.c
)
#set(trpluapi_SRCS
# ${TRPL_DIR}/src/uapi/uapi_rpl.c
#)

# APIFILES: The files which implement the sequential and socket APIs.
set(trplpapi_SRCS
${TRPL_DIR}/src/papi/papi_icmp6.c
)
#set(trplpapi_SRCS
# ${TRPL_DIR}/src/papi/papi_icmp6.c
#)

aux_source_directory(${TRPL_DIR}/src/core/ trplcore_SRCS)
aux_source_directory(${TRPL_DIR}/src/papi/ trplpapi_SRCS)
aux_source_directory(${TRPL_DIR}/src/uapi/ trpluapi_SRCS)

# All TRPL files without apps
set(trplall_SRCS
Expand Down Expand Up @@ -77,7 +81,7 @@ configure_file(${TRPL_DIR}/src/include/init.h.cmake.in ${TRPL_DIR}/src/include/i

# Tripple library
add_library(rplcore ${trplall_SRCS})
include_directories(include src/include)
include_directories(include src/include src/papi src/core)
target_compile_options(rplcore PRIVATE ${TRPL_COMPILER_FLAGS})
target_compile_definitions(rplcore PRIVATE ${TRPL_DEFINITIONS})
target_include_directories(rplcore PRIVATE ${TRPL_INCLUDE_DIRS})
Loading