]> www.infradead.org Git - users/dwmw2/openconnect.git/commitdiff
make buf_append_{be16,be32,le16} global
authorDaniel Lenski <dlenski@gmail.com>
Fri, 8 May 2020 07:11:51 +0000 (00:11 -0700)
committerDavid Woodhouse <dwmw2@infradead.org>
Sun, 28 Mar 2021 09:30:25 +0000 (10:30 +0100)
These functions are already used by both oNCP and Pulse protocols,
and will be used by PPP protocols as well. Make them shared/global.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
http.c
oncp.c
openconnect-internal.h
pulse.c

diff --git a/http.c b/http.c
index ace81e0ba132adb36ee62aa97f8be5d35b36b0a7..1fa301428ccaa5787e745eb5f580a758ff203d15 100644 (file)
--- a/http.c
+++ b/http.c
@@ -68,6 +68,33 @@ void buf_append_xmlescaped(struct oc_text_buf *buf, const char *str)
        }
 }
 
+void buf_append_be16(struct oc_text_buf *buf, uint16_t val)
+{
+       unsigned char b[2];
+
+       store_be16(b, val);
+
+       buf_append_bytes(buf, b, 2);
+}
+
+void buf_append_be32(struct oc_text_buf *buf, uint32_t val)
+{
+       unsigned char b[4];
+
+       store_be32(b, val);
+
+       buf_append_bytes(buf, b, 4);
+}
+
+void buf_append_le16(struct oc_text_buf *buf, uint16_t val)
+{
+       unsigned char b[2];
+
+       store_le16(b, val);
+
+       buf_append_bytes(buf, b, 2);
+}
+
 void buf_append_hex(struct oc_text_buf *buf, const void *str, unsigned len)
 {
        const unsigned char *data = str;
diff --git a/oncp.c b/oncp.c
index f268eaf1d9d8a64af69c37e32e1122f31b00c75c..188fd68c916f2fb0bd36a0f2dca60ebf10150810 100644 (file)
--- a/oncp.c
+++ b/oncp.c
@@ -72,24 +72,6 @@ static int parse_cookie(struct openconnect_info *vpninfo)
        return 0;
 }
 
-static void buf_append_be16(struct oc_text_buf *buf, uint16_t val)
-{
-       unsigned char b[2];
-
-       store_be16(b, val);
-
-       buf_append_bytes(buf, b, 2);
-}
-
-static void buf_append_le16(struct oc_text_buf *buf, uint16_t val)
-{
-       unsigned char b[2];
-
-       store_le16(b, val);
-
-       buf_append_bytes(buf, b, 2);
-}
-
 static void buf_append_tlv(struct oc_text_buf *buf, uint16_t val, uint32_t len, void *data)
 {
        unsigned char b[6];
index 50fa043ceb5b7936d7edf6a49ebe9c486f82b8f4..2f5e9e63e7957642d6555d13b9e2c4d71907df39 100644 (file)
@@ -1129,6 +1129,9 @@ int buf_ensure_space(struct oc_text_buf *buf, int len);
 void  __attribute__ ((format (printf, 2, 3)))
        buf_append(struct oc_text_buf *buf, const char *fmt, ...);
 void buf_append_bytes(struct oc_text_buf *buf, const void *bytes, int len);
+void buf_append_be16(struct oc_text_buf *buf, uint16_t val);
+void buf_append_be32(struct oc_text_buf *buf, uint32_t val);
+void buf_append_le16(struct oc_text_buf *buf, uint16_t val);
 void buf_append_hex(struct oc_text_buf *buf, const void *str, unsigned len);
 int buf_append_utf16le(struct oc_text_buf *buf, const char *utf8);
 int get_utf8char(const char **utf8);
diff --git a/pulse.c b/pulse.c
index 582cbdceaa86f0796036520d01b08cb78f6b9ba2..fbe62c766baa8f526a1ef1d5225eb82666afaba0 100644 (file)
--- a/pulse.c
+++ b/pulse.c
 #define TTLS_MOREFRAGS (1<<6)
 #define TTLS_START     (1<<5)
 
-static void buf_append_be16(struct oc_text_buf *buf, uint16_t val)
-{
-       unsigned char b[2];
-
-       store_be16(b, val);
-
-       buf_append_bytes(buf, b, 2);
-}
-
-static void buf_append_be32(struct oc_text_buf *buf, uint32_t val)
-{
-       unsigned char b[4];
-
-       store_be32(b, val);
-
-       buf_append_bytes(buf, b, 4);
-}
-
 static void buf_append_ift_hdr(struct oc_text_buf *buf, uint32_t vendor, uint32_t type)
 {
        uint32_t b[4];