NDN-DPDK
High-Speed Named Data Networking Forwarder
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Macros | Enumerations | Functions | Variables
fd.c File Reference
#include "fd.h"
#include "../core/logger.h"
#include "../ndni/tlv-encoder.h"
#include "an.h"
#include "naming.h"
#include "server.h"
#include <dirent.h>
#include <sys/syscall.h>
#include <unistd.h>
#include "../vendor/uthash.h"

Macros

#define uthash_malloc(sz)   rte_malloc("FileServer.uthash", (sz), 0)
 
#define uthash_free(ptr, sz)   rte_free((ptr))
 
#define HASH_FUNCTION   HASH_FUNCTION_DONOTUSE
 
#define HASH_KEYCMP(a, b, n)   (!FdHt_Cmp_((const FileServerFd*)(a), (const LName*)(b)))
 
#define uthash_fatal(msg)   rte_panic("uthash_fatal %s", msg)
 
#define HASH_INITIAL_NUM_BUCKETS   (p->nFdHtBuckets)
 
#define HASH_INITIAL_NUM_BUCKETS_LOG2   (rte_log2_u32(HASH_INITIAL_NUM_BUCKETS))
 
#define HASH_BKT_CAPACITY_THRESH   UINT_MAX
 
#define HASH_EXPAND_BUCKETS(hh, tbl, oomed)   FdHt_Expand_(tbl)
 
#define FdStx_NextUpdate   stx_ino
 Reuse FileServerFd.st.stx_ino field as (TscTime)nextUpdate. More...
 
#define HAS_STAT_BIT(bit)    (likely((FileServerStatxRequired & (bit)) == (bit) || FileServerFd_HasStatBit(entry, (bit))))
 
#define APPEND_NNI(type, bits, val)
 

Enumerations

enum  { FileServerStatxRequired = STATX_TYPE | STATX_MODE | STATX_MTIME | STATX_SIZE , FileServerStatxOptional = STATX_ATIME | STATX_CTIME | STATX_BTIME }
 

Functions

 N_LOG_INIT (FileServerFd)
 
FileServerFdFileServerFd_Open (FileServer *p, const PName *name, TscTime now)
 Open file descriptor or increment reference count. More...
 
void FileServerFd_Unref (FileServer *p, FileServerFd *entry)
 Decrement file descriptor reference count. More...
 
void FileServerFd_Clear (FileServer *p)
 Close all file descriptors. More...
 
uint32_t FileServerFd_PrepareMetadata_ (FileServer *p, FileServerFd *entry)
 
void FileServerFd_WriteMetadata (FileServerFd *entry, struct iovec *iov, int iovcnt)
 Write metadata packet. More...
 
bool FileServerFd_GenerateLs (FileServer *p, FileServerFd *entry)
 Populate directory listing. More...
 

Variables

FileServerFdFileServer_NotFound = &notFound
 Sentinel value to indicate file not found. More...
 

Macro Definition Documentation

◆ APPEND_NNI

#define APPEND_NNI (   type,
  bits,
  val 
)
Value:
do { \
struct { \
unaligned_uint32_t tl; \
unaligned_uint##bits##_t v; \
} __rte_packed* f = (void*)output; \
f->tl = TlvEncoder_ConstTL3(TtFile##type, sizeof(f->v)); \
f->v = rte_cpu_to_be_##bits((uint##bits##_t)(val)); \
output += sizeof(*f); \
} while (false)
struct vlanhdr __rte_packed
#define TlvEncoder_ConstTL3(type, length)
Encode constant TLV-TYPE and TLV-LENGTH to unaligned_uint32_t constant.
Definition: tlv-encoder.h:74

◆ FdStx_NextUpdate

#define FdStx_NextUpdate   stx_ino

Reuse FileServerFd.st.stx_ino field as (TscTime)nextUpdate.

◆ HAS_STAT_BIT

#define HAS_STAT_BIT (   bit)     (likely((FileServerStatxRequired & (bit)) == (bit) || FileServerFd_HasStatBit(entry, (bit))))

◆ HASH_BKT_CAPACITY_THRESH

#define HASH_BKT_CAPACITY_THRESH   UINT_MAX

◆ HASH_EXPAND_BUCKETS

#define HASH_EXPAND_BUCKETS (   hh,
  tbl,
  oomed 
)    FdHt_Expand_(tbl)

◆ HASH_FUNCTION

#define HASH_FUNCTION   HASH_FUNCTION_DONOTUSE

◆ HASH_INITIAL_NUM_BUCKETS

#define HASH_INITIAL_NUM_BUCKETS   (p->nFdHtBuckets)

◆ HASH_INITIAL_NUM_BUCKETS_LOG2

#define HASH_INITIAL_NUM_BUCKETS_LOG2   (rte_log2_u32(HASH_INITIAL_NUM_BUCKETS))

◆ HASH_KEYCMP

#define HASH_KEYCMP (   a,
  b,
 
)    (!FdHt_Cmp_((const FileServerFd*)(a), (const LName*)(b)))

◆ uthash_fatal

#define uthash_fatal (   msg)    rte_panic("uthash_fatal %s", msg)

◆ uthash_free

#define uthash_free (   ptr,
  sz 
)    rte_free((ptr))

◆ uthash_malloc

#define uthash_malloc (   sz)    rte_malloc("FileServer.uthash", (sz), 0)

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
FileServerStatxRequired 
FileServerStatxOptional 

Function Documentation

◆ FileServerFd_Clear()

void FileServerFd_Clear ( FileServer p)

Close all file descriptors.

◆ FileServerFd_GenerateLs()

bool FileServerFd_GenerateLs ( FileServer p,
FileServerFd entry 
)

Populate directory listing.

Parameters
entrya valid FileServerFd entry representing a directory.
Postcondition
entry->lsV[:entry->lsL] contains 32=ls payload.
entry->lastSeg and entry->meta FinalBlock reflects entry->lsL size.

◆ FileServerFd_Open()

FileServerFd* FileServerFd_Open ( FileServer p,
const PName name,
TscTime  now 
)

Open file descriptor or increment reference count.

Parameters
nameInterest name.
Return values
NULLfilename is invalid or does not match a mount.
FileServer_NotFoundfile does not exist; do not Unref this value.

◆ FileServerFd_PrepareMetadata_()

uint32_t FileServerFd_PrepareMetadata_ ( FileServer p,
FileServerFd entry 
)

◆ FileServerFd_Unref()

void FileServerFd_Unref ( FileServer p,
FileServerFd entry 
)

Decrement file descriptor reference count.

◆ FileServerFd_WriteMetadata()

void FileServerFd_WriteMetadata ( FileServerFd entry,
struct iovec *  iov,
int  iovcnt 
)

Write metadata packet.

Parameters
entrya valid FileServerFd entry.
iovContent iov, must match the length from FileServerFd_PrepareMetadata .

◆ N_LOG_INIT()

N_LOG_INIT ( FileServerFd  )

Variable Documentation

◆ FileServer_NotFound

FileServerFd* FileServer_NotFound = &notFound

Sentinel value to indicate file not found.