Skip to content

Commit

Permalink
[cleanup] start splitting the code across multiple files
Browse files Browse the repository at this point in the history
Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
  • Loading branch information
fabbione committed Apr 19, 2018
1 parent 052a2b2 commit f9e4836
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 36 deletions.
18 changes: 13 additions & 5 deletions libnozzle/Makefile.am
Expand Up @@ -19,9 +19,6 @@ sources = libnozzle.c

libversion = 1:0:0

AM_CFLAGS += $(PTHREAD_CFLAGS)
LIBS = $(PTHREAD_LIBS)

if BUILD_LIBNOZZLE

include_HEADERS = libnozzle.h
Expand All @@ -30,22 +27,29 @@ pkgconfigdir = $(libdir)/pkgconfig

pkgconfig_DATA = libnozzle.pc

noinst_HEADERS = \
internals.h

lib_LTLIBRARIES = libnozzle.la

libnozzle_la_SOURCES = $(sources)

libnozzle_la_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS)

EXTRA_libnozzle_la_DEPENDENCIES = $(SYMFILE)

libnozzle_la_LDFLAGS = $(AM_LDFLAGS) \
-Wl,-version-script,$(srcdir)/$(SYMFILE) \
-version-info $(libversion)

libnozzle_la_LIBADD = $(PTHREAD_LIBS)

check_PROGRAMS = nozzle_test

TESTS = $(check_PROGRAMS)

noinst_PROGRAMS = $(check_PROGRAMS)

check_PROGRAMS = nozzle_test

check-local: check-api-test-coverage

check-api-test-coverage:
Expand All @@ -57,4 +61,8 @@ nozzle_test_SOURCES = $(sources)
nozzle_test_CPPFLAGS = -DTEST \
-DABSBUILDDIR=\"$(abs_builddir)\"

nozzle_test_CFLAGS = $(PTHREAD_CFLAGS)

nozzle_test_LDFLAGS = $(PTHREAD_LIBS)

endif
46 changes: 46 additions & 0 deletions libnozzle/internals.h
@@ -0,0 +1,46 @@
/*
* Copyright (C) 2010-2017 Red Hat, Inc. All rights reserved.
*
* Author: Fabio M. Di Nitto <fabbione@kronosnet.org>
*
* This software licensed under GPL-2.0+, LGPL-2.0+
*/

#ifndef __NOZZLE_INTERNALS_H__
#define __NOZZLE_INTERNALS_H__

#include "config.h"
#include <net/if.h>

#define MAX_IP_CHAR 128
#define MAX_PREFIX_CHAR 4
#define MAX_MAC_CHAR 18

struct _ip {
char ip_addr[MAX_IP_CHAR];
char prefix[MAX_PREFIX_CHAR];
int domain;
struct _ip *next;
};

struct nozzle_iface {
struct ifreq ifr;
int fd;
char nozzlename[IFNAMSIZ];
char default_mac[MAX_MAC_CHAR];
int default_mtu;
int current_mtu;
char updownpath[PATH_MAX - 11 - 1 - IFNAMSIZ]; /* 11 = post-down.d 1 = / */
int hasupdown;
int up;
struct _ip *ip;
struct nozzle_iface *next;
};
#define ifname ifr.ifr_name

struct _config {
struct nozzle_iface *head;
int sockfd;
};

#endif
32 changes: 1 addition & 31 deletions libnozzle/libnozzle.c
Expand Up @@ -36,37 +36,7 @@
#endif

#include "libnozzle.h"

#define MAX_IP_CHAR 128
#define MAX_PREFIX_CHAR 4
#define MAX_MAC_CHAR 18

struct _ip {
char ip_addr[MAX_IP_CHAR];
char prefix[MAX_PREFIX_CHAR];
int domain;
struct _ip *next;
};

struct nozzle_iface {
struct ifreq ifr;
int fd;
char nozzlename[IFNAMSIZ];
char default_mac[MAX_MAC_CHAR];
int default_mtu;
int current_mtu;
char updownpath[PATH_MAX - 11 - 1 - IFNAMSIZ]; /* 11 = post-down.d 1 = / */
int hasupdown;
int up;
struct _ip *ip;
struct nozzle_iface *next;
};
#define ifname ifr.ifr_name

struct _config {
struct nozzle_iface *head;
int sockfd;
};
#include "internals.h"

static int lib_init = 0;
static struct _config lib_cfg;
Expand Down

0 comments on commit f9e4836

Please sign in to comment.