Thanks to Alejandro for providing help and his container_of implementation taken from sancus-core. https://github.com/sancus-project/sancus-core/blob/master/include/sancus_common.h