Skip to content

Commit

Permalink
Fix cmake script
Browse files Browse the repository at this point in the history
  • Loading branch information
rikka0w0 committed Jan 5, 2025
1 parent 057a36b commit f2c1b8d
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 19 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ if(${DHCPV4_SUPPORT})
set(EXT_SRC ${EXT_SRC} src/dhcpv4.c)
endif(${DHCPV4_SUPPORT})

add_executable(odhcpd src/odhcpd.c src/config.c src/router.c src/dhcpv6.c src/ndp.c src/dhcpv6-ia.c src/netlink.c ${EXT_SRC})
add_executable(odhcpd src/odhcpd.c src/config.c src/router.c src/dhcpv6.c src/ndp.c src/dhcpv6-ia.c src/dhcpv6-pxe.c src/netlink.c ${EXT_SRC})
target_link_libraries(odhcpd resolv ubox uci ${libnl} ${EXT_LINK})

# Installation
Expand Down
2 changes: 1 addition & 1 deletion src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include <libubox/vlist.h>

#include "odhcpd.h"
#include "dhcpv6-pxe.c"
#include "dhcpv6-pxe.h"

static struct blob_buf b;
static int reload_pipe[2] = { -1, -1 };
Expand Down
20 changes: 17 additions & 3 deletions src/dhcpv6-pxe.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,28 @@
#include <sys/timerfd.h>
#include <arpa/inet.h>

#include "odhcpd.h"
#include <libubox/utils.h>
#include <libubox/list.h>

#include "dhcpv6.h"
#include "dhcpv6-pxe.h"

struct ipv6_pxe_entry {
struct list_head list; // List head for linking
uint32_t arch;

// Ready to send
struct __attribute__((packed)) {
uint16_t type; // In network endianess
uint16_t len; // In network endianess, without /0
char payload[]; // Null-terminated here
} bootfile_url;
};

static struct ipv6_pxe_entry* ipv6_pxe_default = NULL;
LIST_HEAD(ipv6_pxe_list);

struct ipv6_pxe_entry* ipv6_pxe_entry_new(uint32_t arch, const char* url) {
const struct ipv6_pxe_entry* ipv6_pxe_entry_new(uint32_t arch, const char* url) {
size_t url_len = strlen(url);
struct ipv6_pxe_entry* ipe = malloc(sizeof(struct ipv6_pxe_entry) + url_len + 1);
if (!ipe)
Expand All @@ -33,7 +47,7 @@ struct ipv6_pxe_entry* ipv6_pxe_entry_new(uint32_t arch, const char* url) {
return ipe;
}

static const struct ipv6_pxe_entry* ipv6_pxe_of_arch(uint16_t arch) {
const struct ipv6_pxe_entry* ipv6_pxe_of_arch(uint16_t arch) {
struct ipv6_pxe_entry* entry;
list_for_each_entry(entry, &ipv6_pxe_list, list) {
if (arch == entry->arch)
Expand Down
18 changes: 4 additions & 14 deletions src/dhcpv6-pxe.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,12 @@

#include <unistd.h>
#include <stddef.h>
#include <libubox/utils.h>
#include <libubox/list.h>

struct ipv6_pxe_entry {
struct list_head list; // List head for linking
uint32_t arch;
// The detail is hidden except for dhcpv6-pxe.c
struct ipv6_pxe_entry;

// Ready to send
struct __attribute__((packed)) {
uint16_t type; // In network endianess
uint16_t len; // In network endianess, without /0
char payload[]; // Null-terminated here
} bootfile_url;
};

struct ipv6_pxe_entry* ipv6_pxe_entry_new(uint32_t arch, const char* url);
const struct ipv6_pxe_entry* ipv6_pxe_entry_new(uint32_t arch, const char* url);
const struct ipv6_pxe_entry* ipv6_pxe_of_arch(uint16_t arch);
void ipv6_pxe_serve_boot_url(uint16_t arch, struct iovec* iov);
void ipv6_pxe_dump(void);
void ipv6_pxe_clear(void);
1 change: 1 addition & 0 deletions src/dhcpv6.c
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,7 @@ static void handle_client_request(void *addr, void *data, size_t len,
.addr = iface->dhcpv6_pd_cer,
};


uint8_t pdbuf[512];
struct iovec iov[IOV_TOTAL] = {
[IOV_NESTED] = {NULL, 0},
Expand Down

0 comments on commit f2c1b8d

Please sign in to comment.