aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2009-12-19 16:20:53 +0200
committerJouni Malinen <j@w1.fi>2009-12-19 16:20:53 +0200
commitd94f86d85ef1a846ff91fe3c66b368c1d535352c (patch)
treeb01f92bf16474b65daf29f22cead67c91d783a9a /src
parentd04a96b0d64c0bf6a1ab7527c24e2c8359349313 (diff)
downloadexternal_wpa_supplicant_8_ti-d94f86d85ef1a846ff91fe3c66b368c1d535352c.zip
external_wpa_supplicant_8_ti-d94f86d85ef1a846ff91fe3c66b368c1d535352c.tar.gz
external_wpa_supplicant_8_ti-d94f86d85ef1a846ff91fe3c66b368c1d535352c.tar.bz2
RADIUS message initialization cleanup
Diffstat (limited to 'src')
-rw-r--r--src/radius/radius.c46
1 files changed, 21 insertions, 25 deletions
diff --git a/src/radius/radius.c b/src/radius/radius.c
index c3ce86d..7b69c9b 100644
--- a/src/radius/radius.c
+++ b/src/radius/radius.c
@@ -20,9 +20,6 @@
#include "radius.h"
-static int radius_msg_initialize(struct radius_msg *msg, size_t init_len);
-
-
static struct radius_attr_hdr *
radius_get_attr_hdr(struct radius_msg *msg, int idx)
{
@@ -37,31 +34,11 @@ static void radius_msg_set_hdr(struct radius_msg *msg, u8 code, u8 identifier)
}
-struct radius_msg *radius_msg_new(u8 code, u8 identifier)
-{
- struct radius_msg *msg;
-
- msg = os_malloc(sizeof(*msg));
- if (msg == NULL)
- return NULL;
-
- if (radius_msg_initialize(msg, RADIUS_DEFAULT_MSG_SIZE)) {
- os_free(msg);
- return NULL;
- }
-
- radius_msg_set_hdr(msg, code, identifier);
-
- return msg;
-}
-
-
static int radius_msg_initialize(struct radius_msg *msg, size_t init_len)
{
- if (msg == NULL || init_len < sizeof(struct radius_hdr))
+ if (init_len < sizeof(struct radius_hdr))
return -1;
- os_memset(msg, 0, sizeof(*msg));
msg->buf = os_zalloc(init_len);
if (msg->buf == NULL)
return -1;
@@ -86,6 +63,25 @@ static int radius_msg_initialize(struct radius_msg *msg, size_t init_len)
}
+struct radius_msg * radius_msg_new(u8 code, u8 identifier)
+{
+ struct radius_msg *msg;
+
+ msg = os_zalloc(sizeof(*msg));
+ if (msg == NULL)
+ return NULL;
+
+ if (radius_msg_initialize(msg, RADIUS_DEFAULT_MSG_SIZE)) {
+ os_free(msg);
+ return NULL;
+ }
+
+ radius_msg_set_hdr(msg, code, identifier);
+
+ return msg;
+}
+
+
void radius_msg_free(struct radius_msg *msg)
{
os_free(msg->buf);
@@ -480,7 +476,7 @@ struct radius_msg *radius_msg_parse(const u8 *data, size_t len)
(unsigned long) len - msg_len);
}
- msg = os_malloc(sizeof(*msg));
+ msg = os_zalloc(sizeof(*msg));
if (msg == NULL)
return NULL;