From 0e1c3ebe509531fa2f805534af67fb7c67c0f8b2 Mon Sep 17 00:00:00 2001
From: Ken Bannister <kb2ma@runbox.com>
Date: Wed, 16 Jan 2019 12:41:06 -0500
Subject: [PATCH] net/gcoap: make options buf macros configurable

---
 sys/include/net/gcoap.h                 | 30 +++++++++++++++++++++++++
 sys/net/application_layer/gcoap/gcoap.c |  9 --------
 2 files changed, 30 insertions(+), 9 deletions(-)

diff --git a/sys/include/net/gcoap.h b/sys/include/net/gcoap.h
index 1059d656ce..9bff25d526 100644
--- a/sys/include/net/gcoap.h
+++ b/sys/include/net/gcoap.h
@@ -258,6 +258,36 @@ extern "C" {
 #define GCOAP_PDU_BUF_SIZE      (128)
 #endif
 
+/**
+ * @brief   Reduce payload length by this value for a request
+ *
+ * Accommodates writing Content-Format option in gcoap_finish(). May set to
+ * zero if function not used.
+ */
+#ifndef GCOAP_REQ_OPTIONS_BUF
+#define GCOAP_REQ_OPTIONS_BUF   (4)
+#endif
+
+/**
+ * @brief   Reduce payload length by this value for a response
+ *
+ * Accommodates writing Content-Format option in gcoap_finish(). May set to
+ * zero if function not used.
+ */
+#ifndef GCOAP_RESP_OPTIONS_BUF
+#define GCOAP_RESP_OPTIONS_BUF  (4)
+#endif
+
+/**
+ * @brief   Reduce payload length by this value for an observe notification
+ *
+ * Accommodates writing Content-Format option in gcoap_finish(). May set to
+ * zero if function not used.
+ */
+#ifndef GCOAP_OBS_OPTIONS_BUF
+#define GCOAP_OBS_OPTIONS_BUF   (4)
+#endif
+
 /**
  * @brief   Maximum number of requests awaiting a response
  */
diff --git a/sys/net/application_layer/gcoap/gcoap.c b/sys/net/application_layer/gcoap/gcoap.c
index 119a7aaa66..3313db4af1 100644
--- a/sys/net/application_layer/gcoap/gcoap.c
+++ b/sys/net/application_layer/gcoap/gcoap.c
@@ -38,15 +38,6 @@
 #define GCOAP_RESOURCE_WRONG_METHOD -1
 #define GCOAP_RESOURCE_NO_PATH -2
 
-/*
- * Reduce payload length by this value for a request created with
- * gcoap_req_init(), gcoap_resp_init(), and gcoap_obs_init(), respectively.
- * Accommodates writing Content-Format option in gcoap_finish().
- */
-#define GCOAP_REQ_OPTIONS_BUF   (4)
-#define GCOAP_RESP_OPTIONS_BUF  (4)
-#define GCOAP_OBS_OPTIONS_BUF   (4)
-
 /* Internal functions */
 static void *_event_loop(void *arg);
 static void _listen(sock_udp_t *sock);
-- 
GitLab