summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2024-11-12 13:19:09 -0700
committerLuke T. Shumaker <lukeshu@lukeshu.com>2024-11-12 13:23:33 -0700
commit5be7b1ebd1ab2bce1d53552b627fe55f425bdb38 (patch)
tree890cda05f97bac976c2120ade2df79408bd40c82
parentaec7a1209a7c2314acc5703a94509a403c796444 (diff)
Fuss with compile-time config
-rw-r--r--cmd/sbc_harness/config/config.h25
-rw-r--r--cmd/sbc_harness/main.c2
-rw-r--r--cmd/srv9p/config/config.h15
-rw-r--r--cmd/srv9p/main.c8
-rw-r--r--lib9p/9p.c6
-rw-r--r--lib9p/9p.generated.c132
-rwxr-xr-xlib9p/idl.gen13
-rw-r--r--lib9p/include/lib9p/9p.generated.h76
-rw-r--r--lib9p/include/lib9p/9p.h12
-rw-r--r--lib9p/srv.c14
-rw-r--r--libdhcp/dhcp_client.c6
-rw-r--r--libdhcp/dhcp_common.h2
-rw-r--r--libhw/w5500.c4
13 files changed, 180 insertions, 135 deletions
diff --git a/cmd/sbc_harness/config/config.h b/cmd/sbc_harness/config/config.h
index 5ee8634..e436eb5 100644
--- a/cmd/sbc_harness/config/config.h
+++ b/cmd/sbc_harness/config/config.h
@@ -12,7 +12,18 @@
/**
* How many W5500 chips we have.
*/
-#define CONFIG_W5500_NUM 1
+#define CONFIG_W5500_NUM 1
+
+/**
+ * When allocating an arbitrary local port, what range should it be
+ * allocated from?
+ *
+ * These are the default values of the Linux kernel's
+ * net.ipv4.ip_local_port_range, so I figure they're probably good
+ * values to use.
+ */
+#define CONFIG_W5500_LOCAL_PORT_MIN 32768
+#define CONFIG_W5500_LOCAL_PORT_MAX 60999
/* 9P *************************************************************************/
@@ -44,10 +55,20 @@
#define CONFIG_9P_MAX_FIDS 16
#define CONFIG_9P_MAX_REQS 2
#define CONFIG_9P_MAX_ERR_SIZE 128 /* 128 is what Plan 9 4e uses */
+#define CONFIG_9P_ENABLE_9P2000 1 /* bool */
+#define CONFIG_9P_ENABLE_9P2000_u 1 /* bool */
+#define CONFIG_9P_ENABLE_9P2000_e 0 /* bool */
+
+/* DHCP ***********************************************************************/
+
+#define CONFIG_DHCP_CAN_RECV_UNICAST_IP_WITHOUT_IP 0
+#define CONFIG_DHCP_DEBUG 0
+#define CONFIG_DHCP_OPT_SIZE 312 /* minimum of 312 */
+#define CONFIG_DHCP_SELECTING_NS (5*NS_PER_S)
/* COROUTINE ******************************************************************/
-#define CONFIG_COROUTINE_DEFAULT_STACK_SIZE 512
+#define CONFIG_COROUTINE_DEFAULT_STACK_SIZE (2*1024)
#define CONFIG_COROUTINE_MEASURE_STACK 1 /* bool */
#define CONFIG_COROUTINE_PROTECT_STACK 1 /* bool */
#define CONFIG_COROUTINE_DEBUG 0 /* bool */
diff --git a/cmd/sbc_harness/main.c b/cmd/sbc_harness/main.c
index 8ee2e7d..d015259 100644
--- a/cmd/sbc_harness/main.c
+++ b/cmd/sbc_harness/main.c
@@ -90,7 +90,7 @@ int main() {
usb_keyboard_rpc_t keyboard_chan = {0};
coroutine_add(usb_keyboard_cr, &keyboard_chan);
//coroutine_add(hello_world_cr, &keyboard_chan);
- coroutine_add_with_stack_size(3*1024, dhcp_cr, &dev_w5500);
+ coroutine_add_with_stack_size(4*1024, dhcp_cr, &dev_w5500);
/* event loop *********************************************************/
coroutine_main();
diff --git a/cmd/srv9p/config/config.h b/cmd/srv9p/config/config.h
index a184e6f..80c8125 100644
--- a/cmd/srv9p/config/config.h
+++ b/cmd/srv9p/config/config.h
@@ -7,7 +7,9 @@
#ifndef _CONFIG_H_
#define _CONFIG_H_
-#define CONFIG_NETIO_NUM_CONNS 8
+#define CONFIG_SRV9P_NUM_CONNS 8
+
+/* 9P *************************************************************************/
#define CONFIG_9P_PORT 564
/**
@@ -37,8 +39,11 @@
#define CONFIG_9P_MAX_FIDS 16
#define CONFIG_9P_MAX_REQS 2
#define CONFIG_9P_MAX_ERR_SIZE 128 /* 128 is what Plan 9 4e uses */
-#define CONFIG_9P_ENABLE_9P2000_u
-/*#define CONFIG_9P_ENABLE_9P2000_e*/
+#define CONFIG_9P_ENABLE_9P2000 1 /* bool */
+#define CONFIG_9P_ENABLE_9P2000_u 1 /* bool */
+#define CONFIG_9P_ENABLE_9P2000_e 0 /* bool */
+
+/* COROUTINE ******************************************************************/
#define CONFIG_COROUTINE_DEFAULT_STACK_SIZE (32*1024)
#define CONFIG_COROUTINE_MEASURE_STACK 1 /* bool */
@@ -47,7 +52,7 @@
#define CONFIG_COROUTINE_VALGRIND 1 /* bool */
#define CONFIG_COROUTINE_NUM (1 /* usb_common */ +\
1 /* usb_keyboard */ +\
- CONFIG_NETIO_NUM_CONNS /* accept+read */ +\
- (CONFIG_9P_MAX_REQS*CONFIG_NETIO_NUM_CONNS) /* work+write */ )
+ CONFIG_SRV9P_NUM_CONNS /* accept+read */ +\
+ (CONFIG_9P_MAX_REQS*CONFIG_SRV9P_NUM_CONNS) /* work+write */ )
#endif /* _CONFIG_H_ */
diff --git a/cmd/srv9p/main.c b/cmd/srv9p/main.c
index d30c4f9..c5a3367 100644
--- a/cmd/srv9p/main.c
+++ b/cmd/srv9p/main.c
@@ -19,8 +19,8 @@
#include "config.h"
-#ifndef CONFIG_NETIO_NUM_CONNS
- #error config.h must define CONFIG_NETIO_NUM_CONNS
+#ifndef CONFIG_SRV9P_NUM_CONNS
+ #error config.h must define CONFIG_SRV9P_NUM_CONNS
#endif
/* implementation *************************************************************/
@@ -104,10 +104,10 @@ int main() {
.rootdir = get_root,
};
- for (int i = 0; i < CONFIG_NETIO_NUM_CONNS; i++)
+ for (int i = 0; i < CONFIG_SRV9P_NUM_CONNS; i++)
if (!coroutine_add(read_cr, &srv))
error(1, 0, "coroutine_add(read_cr, &srv)");
- for (int i = 0; i < 2*CONFIG_NETIO_NUM_CONNS; i++)
+ for (int i = 0; i < 2*CONFIG_SRV9P_NUM_CONNS; i++)
if (!coroutine_add(lib9p_srv_write_cr, &srv))
error(1, 0, "coroutine_add(lib9p_srv_write_cr, &srv)");
diff --git a/lib9p/9p.c b/lib9p/9p.c
index 9ea0c46..5943b42 100644
--- a/lib9p/9p.c
+++ b/lib9p/9p.c
@@ -17,7 +17,7 @@
void lib9p_ctx_clear_error(struct lib9p_ctx *ctx) {
assert(ctx);
-#ifdef CONFIG_9P_ENABLE_9P2000_u
+#if CONFIG_9P_ENABLE_9P2000_u
ctx->err_num = 0;
#endif
ctx->err_msg[0] = '\0';
@@ -34,7 +34,7 @@ int lib9p_error(struct lib9p_ctx *ctx, uint32_t linux_errno, char const *msg) {
strncpy(ctx->err_msg, msg, sizeof(ctx->err_msg));
ctx->err_msg[sizeof(ctx->err_msg)-1] = '\0';
-#ifdef CONFIG_9P_ENABLE_9P2000_u
+#if CONFIG_9P_ENABLE_9P2000_u
ctx->err_num = linux_errno;
#else
(void)(linux_errno);
@@ -55,7 +55,7 @@ int lib9p_errorf(struct lib9p_ctx *ctx, uint32_t linux_errno, char const *fmt, .
if ((size_t)(n+1) < sizeof(ctx->err_msg))
memset(&ctx->err_msg[n+1], 0, sizeof(ctx->err_msg)-(n+1));
-#ifdef CONFIG_9P_ENABLE_9P2000_u
+#if CONFIG_9P_ENABLE_9P2000_u
ctx->err_num = linux_errno;
#else
(void)(linux_errno);
diff --git a/lib9p/9p.generated.c b/lib9p/9p.generated.c
index 1a00f10..536063a 100644
--- a/lib9p/9p.generated.c
+++ b/lib9p/9p.generated.c
@@ -15,15 +15,15 @@
static const char *version_strs[LIB9P_VER_NUM] = {
[LIB9P_VER_unknown] = "unknown",
-#if defined(CONFIG_9P_ENABLE_9P2000)
+#if CONFIG_9P_ENABLE_9P2000
[LIB9P_VER_9P2000] = "9P2000",
-#endif /* defined(CONFIG_9P_ENABLE_9P2000) */
-#if defined(CONFIG_9P_ENABLE_9P2000_e)
+#endif /* CONFIG_9P_ENABLE_9P2000 */
+#if CONFIG_9P_ENABLE_9P2000_e
[LIB9P_VER_9P2000_e] = "9P2000.e",
-#endif /* defined(CONFIG_9P_ENABLE_9P2000_e) */
-#if defined(CONFIG_9P_ENABLE_9P2000_u)
+#endif /* CONFIG_9P_ENABLE_9P2000_e */
+#if CONFIG_9P_ENABLE_9P2000_u
[LIB9P_VER_9P2000_u] = "9P2000.u",
-#endif /* defined(CONFIG_9P_ENABLE_9P2000_u) */
+#endif /* CONFIG_9P_ENABLE_9P2000_u */
};
const char *lib9p_version_str(enum lib9p_version ver) {
@@ -67,7 +67,7 @@ static ALWAYS_INLINE bool _validate_list(struct _validate_ctx *ctx,
#define validate_4(ctx) _validate_size_net(ctx, 4)
#define validate_8(ctx) _validate_size_net(ctx, 8)
-#if defined(CONFIG_9P_ENABLE_9P2000) || defined(CONFIG_9P_ENABLE_9P2000_e) || defined(CONFIG_9P_ENABLE_9P2000_u)
+#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
static ALWAYS_INLINE bool validate_tag(struct _validate_ctx *ctx) {
return validate_2(ctx);
}
@@ -97,15 +97,15 @@ static ALWAYS_INLINE bool validate_s(struct _validate_ctx *ctx) {
}
static const lib9p_dm_t dm_masks[LIB9P_VER_NUM] = {
-#if defined(CONFIG_9P_ENABLE_9P2000)
+#if CONFIG_9P_ENABLE_9P2000
[LIB9P_VER_9P2000] = 0b11101100000000000000000111111111,
-#endif /* defined(CONFIG_9P_ENABLE_9P2000) */
-#if defined(CONFIG_9P_ENABLE_9P2000_e)
+#endif /* CONFIG_9P_ENABLE_9P2000 */
+#if CONFIG_9P_ENABLE_9P2000_e
[LIB9P_VER_9P2000_e] = 0b11101100000000000000000111111111,
-#endif /* defined(CONFIG_9P_ENABLE_9P2000_e) */
-#if defined(CONFIG_9P_ENABLE_9P2000_u)
+#endif /* CONFIG_9P_ENABLE_9P2000_e */
+#if CONFIG_9P_ENABLE_9P2000_u
[LIB9P_VER_9P2000_u] = 0b11101100101111000000000111111111,
-#endif /* defined(CONFIG_9P_ENABLE_9P2000_u) */
+#endif /* CONFIG_9P_ENABLE_9P2000_u */
};
static ALWAYS_INLINE bool validate_dm(struct _validate_ctx *ctx) {
if (validate_4(ctx))
@@ -118,15 +118,15 @@ static ALWAYS_INLINE bool validate_dm(struct _validate_ctx *ctx) {
}
static const lib9p_qt_t qt_masks[LIB9P_VER_NUM] = {
-#if defined(CONFIG_9P_ENABLE_9P2000)
+#if CONFIG_9P_ENABLE_9P2000
[LIB9P_VER_9P2000] = 0b11101100,
-#endif /* defined(CONFIG_9P_ENABLE_9P2000) */
-#if defined(CONFIG_9P_ENABLE_9P2000_e)
+#endif /* CONFIG_9P_ENABLE_9P2000 */
+#if CONFIG_9P_ENABLE_9P2000_e
[LIB9P_VER_9P2000_e] = 0b11101100,
-#endif /* defined(CONFIG_9P_ENABLE_9P2000_e) */
-#if defined(CONFIG_9P_ENABLE_9P2000_u)
+#endif /* CONFIG_9P_ENABLE_9P2000_e */
+#if CONFIG_9P_ENABLE_9P2000_u
[LIB9P_VER_9P2000_u] = 0b11101110,
-#endif /* defined(CONFIG_9P_ENABLE_9P2000_u) */
+#endif /* CONFIG_9P_ENABLE_9P2000_u */
};
static ALWAYS_INLINE bool validate_qt(struct _validate_ctx *ctx) {
if (validate_1(ctx))
@@ -162,27 +162,27 @@ static ALWAYS_INLINE bool validate_stat(struct _validate_ctx *ctx) {
|| validate_s(ctx)
|| validate_s(ctx)
|| validate_s(ctx)
-#if defined(CONFIG_9P_ENABLE_9P2000_u)
+#if CONFIG_9P_ENABLE_9P2000_u
|| ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && validate_s(ctx) )
|| ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && validate_4(ctx) )
|| ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && validate_4(ctx) )
|| ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && validate_4(ctx) )
-#endif /* defined(CONFIG_9P_ENABLE_9P2000_u) */
+#endif /* CONFIG_9P_ENABLE_9P2000_u */
|| ({ uint32_t exp = ctx->net_offset - _kern_type_offset; (((uint32_t)stat_size) != exp) &&
lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "stat_size value is wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)stat_size, exp); })
;
}
static const lib9p_o_t o_masks[LIB9P_VER_NUM] = {
-#if defined(CONFIG_9P_ENABLE_9P2000)
+#if CONFIG_9P_ENABLE_9P2000
[LIB9P_VER_9P2000] = 0b01010011,
-#endif /* defined(CONFIG_9P_ENABLE_9P2000) */
-#if defined(CONFIG_9P_ENABLE_9P2000_e)
+#endif /* CONFIG_9P_ENABLE_9P2000 */
+#if CONFIG_9P_ENABLE_9P2000_e
[LIB9P_VER_9P2000_e] = 0b01010011,
-#endif /* defined(CONFIG_9P_ENABLE_9P2000_e) */
-#if defined(CONFIG_9P_ENABLE_9P2000_u)
+#endif /* CONFIG_9P_ENABLE_9P2000_e */
+#if CONFIG_9P_ENABLE_9P2000_u
[LIB9P_VER_9P2000_u] = 0b01010011,
-#endif /* defined(CONFIG_9P_ENABLE_9P2000_u) */
+#endif /* CONFIG_9P_ENABLE_9P2000_u */
};
static ALWAYS_INLINE bool validate_o(struct _validate_ctx *ctx) {
if (validate_1(ctx))
@@ -239,9 +239,9 @@ static FLATTEN bool validate_Tauth(struct _validate_ctx *ctx) {
|| validate_fid(ctx)
|| validate_s(ctx)
|| validate_s(ctx)
-#if defined(CONFIG_9P_ENABLE_9P2000_u)
+#if CONFIG_9P_ENABLE_9P2000_u
|| ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && validate_4(ctx) )
-#endif /* defined(CONFIG_9P_ENABLE_9P2000_u) */
+#endif /* CONFIG_9P_ENABLE_9P2000_u */
|| ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) &&
lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value is wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); })
|| ({ uint32_t exp = 102; (((uint32_t)typ) != exp) &&
@@ -277,9 +277,9 @@ static FLATTEN bool validate_Tattach(struct _validate_ctx *ctx) {
|| validate_fid(ctx)
|| validate_s(ctx)
|| validate_s(ctx)
-#if defined(CONFIG_9P_ENABLE_9P2000_u)
+#if CONFIG_9P_ENABLE_9P2000_u
|| ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && validate_4(ctx) )
-#endif /* defined(CONFIG_9P_ENABLE_9P2000_u) */
+#endif /* CONFIG_9P_ENABLE_9P2000_u */
|| ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) &&
lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value is wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); })
|| ({ uint32_t exp = 104; (((uint32_t)typ) != exp) &&
@@ -312,9 +312,9 @@ static FLATTEN bool validate_Rerror(struct _validate_ctx *ctx) {
|| (validate_1(ctx) || ({ typ = decode_u8le(&ctx->net_bytes[ctx->net_offset-1]); false; }))
|| validate_tag(ctx)
|| validate_s(ctx)
-#if defined(CONFIG_9P_ENABLE_9P2000_u)
+#if CONFIG_9P_ENABLE_9P2000_u
|| ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && validate_4(ctx) )
-#endif /* defined(CONFIG_9P_ENABLE_9P2000_u) */
+#endif /* CONFIG_9P_ENABLE_9P2000_u */
|| ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) &&
lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value is wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); })
|| ({ uint32_t exp = 107; (((uint32_t)typ) != exp) &&
@@ -669,8 +669,8 @@ static FLATTEN bool validate_Rwstat(struct _validate_ctx *ctx) {
;
}
-#endif /* defined(CONFIG_9P_ENABLE_9P2000) || defined(CONFIG_9P_ENABLE_9P2000_e) || defined(CONFIG_9P_ENABLE_9P2000_u) */
-#if defined(CONFIG_9P_ENABLE_9P2000_e)
+#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */
+#if CONFIG_9P_ENABLE_9P2000_e
static FLATTEN bool validate_Tsession(struct _validate_ctx *ctx) {
uint32_t size;
uint8_t typ;
@@ -770,7 +770,7 @@ static FLATTEN bool validate_Rswrite(struct _validate_ctx *ctx) {
lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value is wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)typ, exp); })
;
}
-#endif /* defined(CONFIG_9P_ENABLE_9P2000_e) */
+#endif /* CONFIG_9P_ENABLE_9P2000_e */
/* unmarshal_* ****************************************************************/
@@ -794,7 +794,7 @@ static ALWAYS_INLINE void unmarshal_8(struct _unmarshal_ctx *ctx, uint64_t *out)
ctx->net_offset += 8;
}
-#if defined(CONFIG_9P_ENABLE_9P2000) || defined(CONFIG_9P_ENABLE_9P2000_e) || defined(CONFIG_9P_ENABLE_9P2000_u)
+#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
static ALWAYS_INLINE void unmarshal_tag(struct _unmarshal_ctx *ctx, lib9p_tag_t *out) {
unmarshal_2(ctx, (uint16_t *)out);
}
@@ -852,12 +852,12 @@ static ALWAYS_INLINE void unmarshal_stat(struct _unmarshal_ctx *ctx, struct lib9
unmarshal_s(ctx, &out->file_owner_uid);
unmarshal_s(ctx, &out->file_owner_gid);
unmarshal_s(ctx, &out->file_last_modified_uid);
-#if defined(CONFIG_9P_ENABLE_9P2000_u)
+#if CONFIG_9P_ENABLE_9P2000_u
if ( (ctx->ctx->version==LIB9P_VER_9P2000_u) ) unmarshal_s(ctx, &out->file_extension);
if ( (ctx->ctx->version==LIB9P_VER_9P2000_u) ) unmarshal_4(ctx, &out->file_owner_n_uid);
if ( (ctx->ctx->version==LIB9P_VER_9P2000_u) ) unmarshal_4(ctx, &out->file_owner_n_gid);
if ( (ctx->ctx->version==LIB9P_VER_9P2000_u) ) unmarshal_4(ctx, &out->file_last_modified_n_uid);
-#endif /* defined(CONFIG_9P_ENABLE_9P2000_u) */
+#endif /* CONFIG_9P_ENABLE_9P2000_u */
}
static ALWAYS_INLINE void unmarshal_o(struct _unmarshal_ctx *ctx, lib9p_o_t *out) {
@@ -890,9 +890,9 @@ static FLATTEN void unmarshal_Tauth(struct _unmarshal_ctx *ctx, struct lib9p_msg
unmarshal_fid(ctx, &out->afid);
unmarshal_s(ctx, &out->uname);
unmarshal_s(ctx, &out->aname);
-#if defined(CONFIG_9P_ENABLE_9P2000_u)
+#if CONFIG_9P_ENABLE_9P2000_u
if ( (ctx->ctx->version==LIB9P_VER_9P2000_u) ) unmarshal_4(ctx, &out->n_uname);
-#endif /* defined(CONFIG_9P_ENABLE_9P2000_u) */
+#endif /* CONFIG_9P_ENABLE_9P2000_u */
}
static FLATTEN void unmarshal_Rauth(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rauth *out) {
@@ -912,9 +912,9 @@ static FLATTEN void unmarshal_Tattach(struct _unmarshal_ctx *ctx, struct lib9p_m
unmarshal_fid(ctx, &out->afid);
unmarshal_s(ctx, &out->uname);
unmarshal_s(ctx, &out->aname);
-#if defined(CONFIG_9P_ENABLE_9P2000_u)
+#if CONFIG_9P_ENABLE_9P2000_u
if ( (ctx->ctx->version==LIB9P_VER_9P2000_u) ) unmarshal_4(ctx, &out->n_uname);
-#endif /* defined(CONFIG_9P_ENABLE_9P2000_u) */
+#endif /* CONFIG_9P_ENABLE_9P2000_u */
}
static FLATTEN void unmarshal_Rattach(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rattach *out) {
@@ -931,9 +931,9 @@ static FLATTEN void unmarshal_Rerror(struct _unmarshal_ctx *ctx, struct lib9p_ms
ctx->net_offset += 1;
unmarshal_tag(ctx, &out->tag);
unmarshal_s(ctx, &out->ename);
-#if defined(CONFIG_9P_ENABLE_9P2000_u)
+#if CONFIG_9P_ENABLE_9P2000_u
if ( (ctx->ctx->version==LIB9P_VER_9P2000_u) ) unmarshal_4(ctx, &out->errno);
-#endif /* defined(CONFIG_9P_ENABLE_9P2000_u) */
+#endif /* CONFIG_9P_ENABLE_9P2000_u */
}
static FLATTEN void unmarshal_Tflush(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tflush *out) {
@@ -1115,8 +1115,8 @@ static FLATTEN void unmarshal_Rwstat(struct _unmarshal_ctx *ctx, struct lib9p_ms
unmarshal_tag(ctx, &out->tag);
}
-#endif /* defined(CONFIG_9P_ENABLE_9P2000) || defined(CONFIG_9P_ENABLE_9P2000_e) || defined(CONFIG_9P_ENABLE_9P2000_u) */
-#if defined(CONFIG_9P_ENABLE_9P2000_e)
+#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */
+#if CONFIG_9P_ENABLE_9P2000_e
static FLATTEN void unmarshal_Tsession(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tsession *out) {
memset(out, 0, sizeof(*out));
ctx->net_offset += 4;
@@ -1174,7 +1174,7 @@ static FLATTEN void unmarshal_Rswrite(struct _unmarshal_ctx *ctx, struct lib9p_m
unmarshal_tag(ctx, &out->tag);
unmarshal_4(ctx, &out->count);
}
-#endif /* defined(CONFIG_9P_ENABLE_9P2000_e) */
+#endif /* CONFIG_9P_ENABLE_9P2000_e */
/* marshal_* ******************************************************************/
@@ -1218,7 +1218,7 @@ static ALWAYS_INLINE bool marshal_8(struct _marshal_ctx *ctx, uint64_t *val) {
return false;
}
-#if defined(CONFIG_9P_ENABLE_9P2000) || defined(CONFIG_9P_ENABLE_9P2000_e) || defined(CONFIG_9P_ENABLE_9P2000_u)
+#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
static ALWAYS_INLINE bool marshal_tag(struct _marshal_ctx *ctx, lib9p_tag_t *val) {
return marshal_2(ctx, (uint16_t *)val);
}
@@ -1281,12 +1281,12 @@ static ALWAYS_INLINE bool marshal_stat(struct _marshal_ctx *ctx, struct lib9p_st
|| marshal_s(ctx, &val->file_owner_uid)
|| marshal_s(ctx, &val->file_owner_gid)
|| marshal_s(ctx, &val->file_last_modified_uid)
-#if defined(CONFIG_9P_ENABLE_9P2000_u)
+#if CONFIG_9P_ENABLE_9P2000_u
|| ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && marshal_s(ctx, &val->file_extension) )
|| ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && marshal_4(ctx, &val->file_owner_n_uid) )
|| ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && marshal_4(ctx, &val->file_owner_n_gid) )
|| ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && marshal_4(ctx, &val->file_last_modified_n_uid) )
-#endif /* defined(CONFIG_9P_ENABLE_9P2000_u) */
+#endif /* CONFIG_9P_ENABLE_9P2000_u */
|| ({ encode_u16le(ctx->net_offset - _kern_type_offset, &ctx->net_bytes[_stat_size_offset]); false; })
;
}
@@ -1334,9 +1334,9 @@ static FLATTEN bool marshal_Tauth(struct _marshal_ctx *ctx, struct lib9p_msg_Tau
|| marshal_fid(ctx, &val->afid)
|| marshal_s(ctx, &val->uname)
|| marshal_s(ctx, &val->aname)
-#if defined(CONFIG_9P_ENABLE_9P2000_u)
+#if CONFIG_9P_ENABLE_9P2000_u
|| ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && marshal_4(ctx, &val->n_uname) )
-#endif /* defined(CONFIG_9P_ENABLE_9P2000_u) */
+#endif /* CONFIG_9P_ENABLE_9P2000_u */
|| ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
|| ({ encode_u8le(102, &ctx->net_bytes[_typ_offset]); false; })
;
@@ -1366,9 +1366,9 @@ static FLATTEN bool marshal_Tattach(struct _marshal_ctx *ctx, struct lib9p_msg_T
|| marshal_fid(ctx, &val->afid)
|| marshal_s(ctx, &val->uname)
|| marshal_s(ctx, &val->aname)
-#if defined(CONFIG_9P_ENABLE_9P2000_u)
+#if CONFIG_9P_ENABLE_9P2000_u
|| ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && marshal_4(ctx, &val->n_uname) )
-#endif /* defined(CONFIG_9P_ENABLE_9P2000_u) */
+#endif /* CONFIG_9P_ENABLE_9P2000_u */
|| ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
|| ({ encode_u8le(104, &ctx->net_bytes[_typ_offset]); false; })
;
@@ -1395,9 +1395,9 @@ static FLATTEN bool marshal_Rerror(struct _marshal_ctx *ctx, struct lib9p_msg_Re
|| ({ _typ_offset = ctx->net_offset; ({ ctx->net_offset += 1; false; }); })
|| marshal_tag(ctx, &val->tag)
|| marshal_s(ctx, &val->ename)
-#if defined(CONFIG_9P_ENABLE_9P2000_u)
+#if CONFIG_9P_ENABLE_9P2000_u
|| ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && marshal_4(ctx, &val->errno) )
-#endif /* defined(CONFIG_9P_ENABLE_9P2000_u) */
+#endif /* CONFIG_9P_ENABLE_9P2000_u */
|| ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
|| ({ encode_u8le(107, &ctx->net_bytes[_typ_offset]); false; })
;
@@ -1688,8 +1688,8 @@ static FLATTEN bool marshal_Rwstat(struct _marshal_ctx *ctx, struct lib9p_msg_Rw
;
}
-#endif /* defined(CONFIG_9P_ENABLE_9P2000) || defined(CONFIG_9P_ENABLE_9P2000_e) || defined(CONFIG_9P_ENABLE_9P2000_u) */
-#if defined(CONFIG_9P_ENABLE_9P2000_e)
+#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */
+#if CONFIG_9P_ENABLE_9P2000_e
static FLATTEN bool marshal_Tsession(struct _marshal_ctx *ctx, struct lib9p_msg_Tsession *val) {
uint32_t _size_offset;
uint32_t _typ_offset;
@@ -1777,7 +1777,7 @@ static FLATTEN bool marshal_Rswrite(struct _marshal_ctx *ctx, struct lib9p_msg_R
|| ({ encode_u8le(155, &ctx->net_bytes[_typ_offset]); false; })
;
}
-#endif /* defined(CONFIG_9P_ENABLE_9P2000_e) */
+#endif /* CONFIG_9P_ENABLE_9P2000_e */
/* tables / exports ***********************************************************/
@@ -2051,7 +2051,7 @@ struct _table_version _lib9p_versions[LIB9P_VER_NUM] = {
_NONMSG(0xFE),
_NONMSG(0xFF),
}},
-#if defined(CONFIG_9P_ENABLE_9P2000)
+#if CONFIG_9P_ENABLE_9P2000
[LIB9P_VER_9P2000] = { .msgs = {
_NONMSG(0x00),
_NONMSG(0x01),
@@ -2310,8 +2310,8 @@ struct _table_version _lib9p_versions[LIB9P_VER_NUM] = {
_NONMSG(0xFE),
_NONMSG(0xFF),
}},
-#endif /* defined(CONFIG_9P_ENABLE_9P2000) */
-#if defined(CONFIG_9P_ENABLE_9P2000_e)
+#endif /* CONFIG_9P_ENABLE_9P2000 */
+#if CONFIG_9P_ENABLE_9P2000_e
[LIB9P_VER_9P2000_e] = { .msgs = {
_NONMSG(0x00),
_NONMSG(0x01),
@@ -2570,8 +2570,8 @@ struct _table_version _lib9p_versions[LIB9P_VER_NUM] = {
_NONMSG(0xFE),
_NONMSG(0xFF),
}},
-#endif /* defined(CONFIG_9P_ENABLE_9P2000_e) */
-#if defined(CONFIG_9P_ENABLE_9P2000_u)
+#endif /* CONFIG_9P_ENABLE_9P2000_e */
+#if CONFIG_9P_ENABLE_9P2000_u
[LIB9P_VER_9P2000_u] = { .msgs = {
_NONMSG(0x00),
_NONMSG(0x01),
@@ -2830,7 +2830,7 @@ struct _table_version _lib9p_versions[LIB9P_VER_NUM] = {
_NONMSG(0xFE),
_NONMSG(0xFF),
}},
-#endif /* defined(CONFIG_9P_ENABLE_9P2000_u) */
+#endif /* CONFIG_9P_ENABLE_9P2000_u */
};
FLATTEN bool _lib9p_validate_stat(struct _validate_ctx *ctx) {
diff --git a/lib9p/idl.gen b/lib9p/idl.gen
index 3be1d7e..e423196 100755
--- a/lib9p/idl.gen
+++ b/lib9p/idl.gen
@@ -463,7 +463,7 @@ def c_ver_enum(ver: str) -> str:
def c_ver_ifdef(versions: set[str]) -> str:
return " || ".join(
- f"defined(CONFIG_9P_ENABLE_{v.replace('.', '_')})" for v in sorted(versions)
+ f"CONFIG_9P_ENABLE_{v.replace('.', '_')}" for v in sorted(versions)
)
@@ -545,6 +545,17 @@ def gen_h(versions: set[str], typs: list[Type]) -> str:
"""
ret += f"""
+/* config *********************************************************************/
+
+#include "config.h"
+"""
+ for ver in sorted(versions):
+ ret += "\n"
+ ret += f"#ifndef {c_ver_ifdef({ver})}\n"
+ ret += f"\t#error config.h must define {c_ver_ifdef({ver})}\n"
+ ret += "#endif\n"
+
+ ret += f"""
/* versions *******************************************************************/
enum {idprefix}version {{
diff --git a/lib9p/include/lib9p/9p.generated.h b/lib9p/include/lib9p/9p.generated.h
index feca8c9..25aacfe 100644
--- a/lib9p/include/lib9p/9p.generated.h
+++ b/lib9p/include/lib9p/9p.generated.h
@@ -6,19 +6,35 @@
#include <stdint.h> /* for uint{n}_t types */
+/* config *********************************************************************/
+
+#include "config.h"
+
+#ifndef CONFIG_9P_ENABLE_9P2000
+ #error config.h must define CONFIG_9P_ENABLE_9P2000
+#endif
+
+#ifndef CONFIG_9P_ENABLE_9P2000_e
+ #error config.h must define CONFIG_9P_ENABLE_9P2000_e
+#endif
+
+#ifndef CONFIG_9P_ENABLE_9P2000_u
+ #error config.h must define CONFIG_9P_ENABLE_9P2000_u
+#endif
+
/* versions *******************************************************************/
enum lib9p_version {
LIB9P_VER_unknown = 0, /* "unknown" */
-#if defined(CONFIG_9P_ENABLE_9P2000)
+#if CONFIG_9P_ENABLE_9P2000
LIB9P_VER_9P2000, /* "9P2000" */
-#endif /* defined(CONFIG_9P_ENABLE_9P2000) */
-#if defined(CONFIG_9P_ENABLE_9P2000_e)
+#endif /* CONFIG_9P_ENABLE_9P2000 */
+#if CONFIG_9P_ENABLE_9P2000_e
LIB9P_VER_9P2000_e, /* "9P2000.e" */
-#endif /* defined(CONFIG_9P_ENABLE_9P2000_e) */
-#if defined(CONFIG_9P_ENABLE_9P2000_u)
+#endif /* CONFIG_9P_ENABLE_9P2000_e */
+#if CONFIG_9P_ENABLE_9P2000_u
LIB9P_VER_9P2000_u, /* "9P2000.u" */
-#endif /* defined(CONFIG_9P_ENABLE_9P2000_u) */
+#endif /* CONFIG_9P_ENABLE_9P2000_u */
LIB9P_VER_NUM,
};
@@ -26,7 +42,7 @@ const char *lib9p_version_str(enum lib9p_version);
/* non-message types **********************************************************/
-#if defined(CONFIG_9P_ENABLE_9P2000) || defined(CONFIG_9P_ENABLE_9P2000_e) || defined(CONFIG_9P_ENABLE_9P2000_u)
+#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
typedef uint16_t lib9p_tag_t;
typedef uint32_t lib9p_fid_t;
@@ -51,16 +67,16 @@ typedef uint32_t lib9p_dm_t;
#define LIB9P_DM_TMP ((lib9p_dm_t)(1<<26))
/* unused ((lib9p_dm_t)(1<<25)) */
/* unused ((lib9p_dm_t)(1<<24)) */
-#if defined(CONFIG_9P_ENABLE_9P2000_u)
+#if CONFIG_9P_ENABLE_9P2000_u
# define LIB9P_DM_DEVICE ((lib9p_dm_t)(1<<23))
-#endif /* defined(CONFIG_9P_ENABLE_9P2000_u) */
+#endif /* CONFIG_9P_ENABLE_9P2000_u */
/* unused ((lib9p_dm_t)(1<<22)) */
-#if defined(CONFIG_9P_ENABLE_9P2000_u)
+#if CONFIG_9P_ENABLE_9P2000_u
# define LIB9P_DM_NAMEDPIPE ((lib9p_dm_t)(1<<21))
# define LIB9P_DM_SOCKET ((lib9p_dm_t)(1<<20))
# define LIB9P_DM_SETUID ((lib9p_dm_t)(1<<19))
# define LIB9P_DM_SETGID ((lib9p_dm_t)(1<<18))
-#endif /* defined(CONFIG_9P_ENABLE_9P2000_u) */
+#endif /* CONFIG_9P_ENABLE_9P2000_u */
/* unused ((lib9p_dm_t)(1<<17)) */
/* unused ((lib9p_dm_t)(1<<16)) */
/* unused ((lib9p_dm_t)(1<<15)) */
@@ -90,9 +106,9 @@ typedef uint8_t lib9p_qt_t;
#define _LIB9P_QT_PLAN9_MOUNT ((lib9p_qt_t)(1<<4))
#define LIB9P_QT_AUTH ((lib9p_qt_t)(1<<3))
#define LIB9P_QT_TMP ((lib9p_qt_t)(1<<2))
-#if defined(CONFIG_9P_ENABLE_9P2000_u)
+#if CONFIG_9P_ENABLE_9P2000_u
# define LIB9P_QT_SYMLINK ((lib9p_qt_t)(1<<1))
-#endif /* defined(CONFIG_9P_ENABLE_9P2000_u) */
+#endif /* CONFIG_9P_ENABLE_9P2000_u */
/* unused ((lib9p_qt_t)(1<<0)) */
#define LIB9P_QT_FILE ((lib9p_qt_t)(0))
@@ -115,12 +131,12 @@ struct lib9p_stat {
struct lib9p_s file_owner_uid;
struct lib9p_s file_owner_gid;
struct lib9p_s file_last_modified_uid;
-#if defined(CONFIG_9P_ENABLE_9P2000_u)
+#if CONFIG_9P_ENABLE_9P2000_u
struct lib9p_s file_extension;
uint32_t file_owner_n_uid;
uint32_t file_owner_n_gid;
uint32_t file_last_modified_n_uid;
-#endif /* defined(CONFIG_9P_ENABLE_9P2000_u) */
+#endif /* CONFIG_9P_ENABLE_9P2000_u */
};
typedef uint8_t lib9p_o_t;
@@ -140,12 +156,12 @@ typedef uint8_t lib9p_o_t;
#define LIB9P_O_EXEC ((lib9p_o_t)(3))
#define LIB9P_O_MODE_MASK ((lib9p_o_t)(0b00000011))
#define LIB9P_O_FLAG_MASK ((lib9p_o_t)(0b11111100))
-#endif /* defined(CONFIG_9P_ENABLE_9P2000) || defined(CONFIG_9P_ENABLE_9P2000_e) || defined(CONFIG_9P_ENABLE_9P2000_u) */
+#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */
/* messages *******************************************************************/
enum lib9p_msg_type { /* uint8_t */
-#if defined(CONFIG_9P_ENABLE_9P2000) || defined(CONFIG_9P_ENABLE_9P2000_e) || defined(CONFIG_9P_ENABLE_9P2000_u)
+#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
LIB9P_TYP_Tversion = 100,
LIB9P_TYP_Rversion = 101,
LIB9P_TYP_Tauth = 102,
@@ -173,18 +189,18 @@ enum lib9p_msg_type { /* uint8_t */
LIB9P_TYP_Rstat = 125,
LIB9P_TYP_Twstat = 126,
LIB9P_TYP_Rwstat = 127,
-#endif /* defined(CONFIG_9P_ENABLE_9P2000) || defined(CONFIG_9P_ENABLE_9P2000_e) || defined(CONFIG_9P_ENABLE_9P2000_u) */
-#if defined(CONFIG_9P_ENABLE_9P2000_e)
+#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */
+#if CONFIG_9P_ENABLE_9P2000_e
LIB9P_TYP_Tsession = 150,
LIB9P_TYP_Rsession = 151,
LIB9P_TYP_Tsread = 152,
LIB9P_TYP_Rsread = 153,
LIB9P_TYP_Tswrite = 154,
LIB9P_TYP_Rswrite = 155,
-#endif /* defined(CONFIG_9P_ENABLE_9P2000_e) */
+#endif /* CONFIG_9P_ENABLE_9P2000_e */
};
-#if defined(CONFIG_9P_ENABLE_9P2000) || defined(CONFIG_9P_ENABLE_9P2000_e) || defined(CONFIG_9P_ENABLE_9P2000_u)
+#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
struct lib9p_msg_Tversion {
lib9p_tag_t tag;
uint32_t max_msg_size;
@@ -202,9 +218,9 @@ struct lib9p_msg_Tauth {
lib9p_fid_t afid;
struct lib9p_s uname;
struct lib9p_s aname;
-#if defined(CONFIG_9P_ENABLE_9P2000_u)
+#if CONFIG_9P_ENABLE_9P2000_u
uint32_t n_uname;
-#endif /* defined(CONFIG_9P_ENABLE_9P2000_u) */
+#endif /* CONFIG_9P_ENABLE_9P2000_u */
};
struct lib9p_msg_Rauth {
@@ -218,9 +234,9 @@ struct lib9p_msg_Tattach {
lib9p_fid_t afid;
struct lib9p_s uname;
struct lib9p_s aname;
-#if defined(CONFIG_9P_ENABLE_9P2000_u)
+#if CONFIG_9P_ENABLE_9P2000_u
uint32_t n_uname;
-#endif /* defined(CONFIG_9P_ENABLE_9P2000_u) */
+#endif /* CONFIG_9P_ENABLE_9P2000_u */
};
struct lib9p_msg_Rattach {
@@ -231,9 +247,9 @@ struct lib9p_msg_Rattach {
struct lib9p_msg_Rerror {
lib9p_tag_t tag;
struct lib9p_s ename;
-#if defined(CONFIG_9P_ENABLE_9P2000_u)
+#if CONFIG_9P_ENABLE_9P2000_u
uint32_t errno;
-#endif /* defined(CONFIG_9P_ENABLE_9P2000_u) */
+#endif /* CONFIG_9P_ENABLE_9P2000_u */
};
struct lib9p_msg_Tflush {
@@ -347,8 +363,8 @@ struct lib9p_msg_Rwstat {
lib9p_tag_t tag;
};
-#endif /* defined(CONFIG_9P_ENABLE_9P2000) || defined(CONFIG_9P_ENABLE_9P2000_e) || defined(CONFIG_9P_ENABLE_9P2000_u) */
-#if defined(CONFIG_9P_ENABLE_9P2000_e)
+#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */
+#if CONFIG_9P_ENABLE_9P2000_e
struct lib9p_msg_Tsession {
lib9p_tag_t tag;
uint64_t key;
@@ -382,4 +398,4 @@ struct lib9p_msg_Rswrite {
lib9p_tag_t tag;
uint32_t count;
};
-#endif /* defined(CONFIG_9P_ENABLE_9P2000_e) */
+#endif /* CONFIG_9P_ENABLE_9P2000_e */
diff --git a/lib9p/include/lib9p/9p.h b/lib9p/include/lib9p/9p.h
index 9d22354..fb1f97d 100644
--- a/lib9p/include/lib9p/9p.h
+++ b/lib9p/include/lib9p/9p.h
@@ -13,21 +13,13 @@
#include <libmisc/assert.h>
#include <lib9p/linux-errno.h>
-
-/* configuration **************************************************************/
-
-#include "config.h"
+#include <lib9p/9p.generated.h>
#ifndef CONFIG_9P_MAX_ERR_SIZE
#error config.h must define CONFIG_9P_MAX_ERR_SIZE
#endif
-#ifndef CONFIG_9P_ENABLE_9P2000
- #define CONFIG_9P_ENABLE_9P2000
-#endif
-
-/* protocol definitions *******************************************************/
-#include <lib9p/9p.generated.h> /* *after* config.h */
+/******************************************************************************/
#define LIB9P_NOTAG ((uint16_t)~0U)
#define LIB9P_NOFID ((uint32_t)~0U)
diff --git a/lib9p/srv.c b/lib9p/srv.c
index 608d470..5bec0d6 100644
--- a/lib9p/srv.c
+++ b/lib9p/srv.c
@@ -134,7 +134,7 @@ static uint32_t rerror_overhead_for_version(enum lib9p_version version,
}
static void respond_error(struct _lib9p_srv_req *req) {
-#ifdef CONFIG_9P_ENABLE_9P2000_u
+#if CONFIG_9P_ENABLE_9P2000_u
assert(req->ctx.basectx.err_num);
#endif
assert(req->ctx.basectx.err_msg[0]);
@@ -147,7 +147,7 @@ static void respond_error(struct _lib9p_srv_req *req) {
CONFIG_9P_MAX_ERR_SIZE),
.utf8 = req->ctx.basectx.err_msg,
},
-#ifdef CONFIG_9P_ENABLE_9P2000_u
+#if CONFIG_9P_ENABLE_9P2000_u
.errno = req->ctx.basectx.err_num,
#endif
};
@@ -334,7 +334,7 @@ _HANDLER_PROTO(clunk);
_HANDLER_PROTO(remove);
_HANDLER_PROTO(stat);
_HANDLER_PROTO(wstat);
-#ifdef CONFIG_9P_ENABLE_9P2000_e
+#if CONFIG_9P_ENABLE_9P2000_e
_HANDLER_PROTO(session);
_HANDLER_PROTO(sread);
_HANDLER_PROTO(swrite);
@@ -356,7 +356,7 @@ static tmessage_handler tmessage_handlers[0x100] = {
[LIB9P_TYP_Tremove] = (tmessage_handler)handle_Tremove,
[LIB9P_TYP_Tstat] = (tmessage_handler)handle_Tstat,
[LIB9P_TYP_Twstat] = (tmessage_handler)handle_Twstat,
-#ifdef CONFIG_9P_ENABLE_9P2000_e
+#if CONFIG_9P_ENABLE_9P2000_e
[LIB9P_TYP_Tsession] = (tmessage_handler)handle_Tsession,
[LIB9P_TYP_Tsread] = (tmessage_handler)handle_Tsread,
[LIB9P_TYP_Tswrite] = (tmessage_handler)handle_Tswrite,
@@ -450,11 +450,11 @@ static void handle_Tversion(struct _lib9p_srv_req *ctx,
'0' <= req->version.utf8[5] && req->version.utf8[5] <= '9' &&
(req->version.utf8[6] == '\0' || req->version.utf8[6] == '.')) {
version = LIB9P_VER_9P2000;
-#ifdef CONFIG_9P_ENABLE_9P2000_u
+#if CONFIG_9P_ENABLE_9P2000_u
if (strcmp(&req->version.utf8[6], ".u") == 0)
version = LIB9P_VER_9P2000_u;
#endif
-#ifdef CONFIG_9P_ENABLE_9P2000_e
+#if CONFIG_9P_ENABLE_9P2000_e
if (strcmp(&req->version.utf8[6], ".e") == 0)
version = LIB9P_VER_9P2000_e;
#endif
@@ -943,7 +943,7 @@ static void handle_Twstat(struct _lib9p_srv_req *ctx,
LINUX_EOPNOTSUPP, "wstat not (yet?) implemented");
}
-#ifdef CONFIG_9P_ENABLE_9P2000_e
+#if CONFIG_9P_ENABLE_9P2000_e
static void handle_Tsession(struct _lib9p_srv_req *ctx,
struct lib9p_msg_Tsession *req,
struct lib9p_msg_Rsession *resp) {
diff --git a/libdhcp/dhcp_client.c b/libdhcp/dhcp_client.c
index 3673d2c..a7b1d49 100644
--- a/libdhcp/dhcp_client.c
+++ b/libdhcp/dhcp_client.c
@@ -99,13 +99,13 @@
#include "config.h"
#ifndef CONFIG_DHCP_DEBUG
- #define CONFIG_DHCP_DEBUG 1
+ #error config.h must define CONFIG_DHCP_DEBUG
#endif
#ifndef CONFIG_DHCP_SELECTING_NS
- #define CONFIG_DHCP_SELECTING_NS (5*NS_PER_S)
+ #error config.h must define CONFIG_DHCP_SELECTING_NS
#endif
#ifndef CONFIG_DHCP_CAN_RECV_UNICAST_IP_WITHOUT_IP
- #define CONFIG_DHCP_CAN_RECV_UNICAST_IP_WITHOUT_IP false
+ #error config.h must define CONFIG_DHCP_CAN_RECV_UNICAST_IP_WITHOUT_IP
#endif
/* Implementation *************************************************************/
diff --git a/libdhcp/dhcp_common.h b/libdhcp/dhcp_common.h
index d400721..b265df3 100644
--- a/libdhcp/dhcp_common.h
+++ b/libdhcp/dhcp_common.h
@@ -74,7 +74,7 @@
#include "config.h"
#ifndef CONFIG_DHCP_OPT_SIZE
- #define CONFIG_DHCP_OPT_SIZE DHCP_MSG_MIN_MAX_OPT_SIZE
+ #error config.h must define CONFIG_DHCP_OPT_SIZE (minimum 312)
#endif
/* RFC 2131 definitions *******************************************************/
diff --git a/libhw/w5500.c b/libhw/w5500.c
index ae48a61..a998ccf 100644
--- a/libhw/w5500.c
+++ b/libhw/w5500.c
@@ -89,11 +89,11 @@
* net.ipv4.ip_local_port_range, so I figure they're probably good
* values to use. */
#ifndef CONFIG_W5500_LOCAL_PORT_MIN
- #define CONFIG_W5500_LOCAL_PORT_MIN 32768
+ #error config.h must define CONFIG_W5500_LOCAL_PORT_MIN
#endif
#ifndef CONFIG_W5500_LOCAL_PORT_MAX
- #define CONFIG_W5500_LOCAL_PORT_MAX 60999
+ #error config.h must define CONFIG_W5500_LOCAL_PORT_MAX
#endif
#ifndef CONFIG_W5500_NUM