Code in src/lib shouldn't reference the REQUEST structure
authorAlan T. DeKok <aland@freeradius.org>
Fri, 8 Oct 2010 15:31:54 +0000 (17:31 +0200)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 8 Oct 2010 15:32:21 +0000 (17:32 +0200)
src/include/soh.h
src/lib/soh.c
src/modules/rlm_eap/types/rlm_eap_peap/peap.c
src/modules/rlm_soh/rlm_soh.c

index 8a8c1f4..8585e64 100644 (file)
@@ -28,7 +28,7 @@ RCSIDH(soh_h, "$Id$")
 
 #include <freeradius-devel/libradius.h>
 
-int soh_verify(REQUEST *request, VALUE_PAIR *sohvp, const uint8_t *data, unsigned int data_len);
+int soh_verify(VALUE_PAIR *sohvp, const uint8_t *data, unsigned int data_len);
 uint16_t soh_pull_be_16(const uint8_t *p);
 uint32_t soh_pull_be_24(const uint8_t *p);
 uint32_t soh_pull_be_32(const uint8_t *p);
index c0bd9f9..3e8af78 100644 (file)
@@ -101,7 +101,7 @@ uint32_t soh_pull_be_32(const uint8_t *p) {
  * unknown types; we need to know their length ahead of time. Therefore, we abort
  * if we find an unknown type.
  */
-static int eapsoh_mstlv(REQUEST *request, VALUE_PAIR *sohvp, const uint8_t *p, unsigned int data_len) {
+static int eapsoh_mstlv(VALUE_PAIR *sohvp, const uint8_t *p, unsigned int data_len) {
        VALUE_PAIR *vp;
        uint8_t c;
        int t;
@@ -116,7 +116,7 @@ static int eapsoh_mstlv(REQUEST *request, VALUE_PAIR *sohvp, const uint8_t *p, u
                                 * MS-SOH section 2.2.4.1
                                 */
                                if (data_len < 18) {
-                                       RDEBUG("insufficient data for MS-Machine-Inventory-Packet");
+                                       DEBUG("insufficient data for MS-Machine-Inventory-Packet");
                                        return 0;
                                }
                                data_len -= 18;
@@ -171,7 +171,7 @@ static int eapsoh_mstlv(REQUEST *request, VALUE_PAIR *sohvp, const uint8_t *p, u
                                /* MS-Packet-Info
                                 * MS-SOH 2.2.4.3
                                 */
-                               RDEBUG("SoH MS-Packet-Info %s vers=%i", *p & 0x10 ? "request" : "response", *p & 0xf);
+                               DEBUG("SoH MS-Packet-Info %s vers=%i", *p & 0x10 ? "request" : "response", *p & 0xf);
                                p++;
                                data_len--;
                                break;
@@ -252,7 +252,7 @@ static int eapsoh_mstlv(REQUEST *request, VALUE_PAIR *sohvp, const uint8_t *p, u
                                break;
 
                        default:
-                               RDEBUG("SoH Unknown MS TV %i stopping", c);
+                               DEBUG("SoH Unknown MS TV %i stopping", c);
                                return 0;
                }
        }
@@ -304,28 +304,28 @@ static const char* healthclass2str(uint8_t hc) {
        return NULL;
 }
 
-int soh_verify(REQUEST *request, VALUE_PAIR *sohvp, const uint8_t *data, unsigned int data_len) {
+int soh_verify(VALUE_PAIR *sohvp, const uint8_t *data, unsigned int data_len) {
 
        VALUE_PAIR *vp;
        eap_soh hdr;
        soh_response resp;
        soh_mode_subheader mode;
        soh_tlv tlv;
-       int i, curr_shid=-1, curr_shid_c=-1, curr_hc=-1;
+       int curr_shid=-1, curr_shid_c=-1, curr_hc=-1;
 
        hdr.tlv_type = soh_pull_be_16(data); data += 2;
        hdr.tlv_len = soh_pull_be_16(data); data += 2;
        hdr.tlv_vendor = soh_pull_be_32(data); data += 4;
 
        if (hdr.tlv_type != 7 || hdr.tlv_vendor != 0x137) {
-               RDEBUG("SoH payload is %i %08x not a ms-vendor packet", hdr.tlv_type, hdr.tlv_vendor);
+               fr_strerror_printf("SoH payload is %i %08x not a ms-vendor packet", hdr.tlv_type, hdr.tlv_vendor);
                return -1;
        }
 
        hdr.soh_type = soh_pull_be_16(data); data += 2;
        hdr.soh_len = soh_pull_be_16(data); data += 2;
        if (hdr.soh_type != 1) {
-               RDEBUG("SoH tlv %04x is not a response", hdr.soh_type);
+               fr_strerror_printf("SoH tlv %04x is not a response", hdr.soh_type);
                return -1;
        }
 
@@ -338,13 +338,13 @@ int soh_verify(REQUEST *request, VALUE_PAIR *sohvp, const uint8_t *data, unsigne
 
 
        if (resp.outer_type!=7 || resp.vendor != 0x137) {
-               RDEBUG("SoH response outer type %i/vendor %08x not recognised", resp.outer_type, resp.vendor);
+               fr_strerror_printf("SoH response outer type %i/vendor %08x not recognised", resp.outer_type, resp.vendor);
                return -1;
        }
        switch (resp.inner_type) {
                case 1:
                        /* no mode sub-header */
-                       RDEBUG("SoH without mode subheader");
+                       fr_strerror_printf("SoH without mode subheader");
                        break;
                case 2:
                        mode.outer_type = soh_pull_be_16(data); data += 2;
@@ -356,13 +356,13 @@ int soh_verify(REQUEST *request, VALUE_PAIR *sohvp, const uint8_t *data, unsigne
                        data += 2;
 
                        if (mode.outer_type != 7 || mode.vendor != 0x137 || mode.content_type != 0) {
-                               RDEBUG("SoH mode subheader outer type %i/vendor %08x/content type %i invalid", mode.outer_type, mode.vendor, mode.content_type);
+                               fr_strerror_printf("SoH mode subheader outer type %i/vendor %08x/content type %i invalid", mode.outer_type, mode.vendor, mode.content_type);
                                return -1;
                        }
-                       RDEBUG("SoH with mode subheader");
+                       DEBUG("SoH with mode subheader");
                        break;
                default:
-                       RDEBUG("SoH invalid inner type %i", resp.inner_type);
+                       fr_strerror_printf("SoH invalid inner type %i", resp.inner_type);
                        return -1;
        }
 
@@ -400,7 +400,7 @@ int soh_verify(REQUEST *request, VALUE_PAIR *sohvp, const uint8_t *data, unsigne
                                 */
                                curr_shid = soh_pull_be_24(data);
                                curr_shid_c = data[3];
-                               RDEBUG2("SoH System-Health-ID vendor %08x component=%i", curr_shid, curr_shid_c);
+                               DEBUG("SoH System-Health-ID vendor %08x component=%i", curr_shid, curr_shid_c);
                                break;
 
                        case 7:
@@ -411,10 +411,10 @@ int soh_verify(REQUEST *request, VALUE_PAIR *sohvp, const uint8_t *data, unsigne
                                 * N bytes payload; for Microsoft component#0 this is the MS TV stuff
                                 */
                                if (curr_shid==0x137 && curr_shid_c==0) {
-                                       RDEBUG2("SoH MS type-value payload");
-                                       eapsoh_mstlv(request, sohvp, data + 4, tlv.tlv_len - 4);
+                                       DEBUG("SoH MS type-value payload");
+                                       eapsoh_mstlv(sohvp, data + 4, tlv.tlv_len - 4);
                                } else {
-                                       RDEBUG2("SoH unhandled vendor-specific TLV %08x/component=%i %i bytes payload", curr_shid, curr_shid_c, tlv.tlv_len);
+                                       fr_strerror_printf("SoH unhandled vendor-specific TLV %08x/component=%i %i bytes payload", curr_shid, curr_shid_c, tlv.tlv_len);
                                }
                                break;
 
@@ -424,7 +424,7 @@ int soh_verify(REQUEST *request, VALUE_PAIR *sohvp, const uint8_t *data, unsigne
                                 *
                                 * 1 byte integer
                                 */
-                               RDEBUG2("SoH Health-Class %i", data[0]);
+                               DEBUG("SoH Health-Class %i", data[0]);
                                curr_hc = data[0];
                                break;
 
@@ -434,7 +434,7 @@ int soh_verify(REQUEST *request, VALUE_PAIR *sohvp, const uint8_t *data, unsigne
                                 *
                                 * 1 byte integer
                                 */
-                               RDEBUG2("SoH Software-Version %i", data[0]);
+                               DEBUG("SoH Software-Version %i", data[0]);
                                break;
 
                        case 11:
@@ -450,14 +450,14 @@ int soh_verify(REQUEST *request, VALUE_PAIR *sohvp, const uint8_t *data, unsigne
                                 *  1 bit - 1==product up-to-date
                                 *  1 bit - 1==product enabled
                                 */
-                               RDEBUG2("SoH Health-Class-Status - current shid=%08x component=%i", curr_shid, curr_shid_c);
+                               DEBUG("SoH Health-Class-Status - current shid=%08x component=%i", curr_shid, curr_shid_c);
 
                                if (curr_shid==0x137 && curr_shid_c==128) {
 
                                        const char *s, *t;
                                        uint32_t hcstatus = soh_pull_be_32(data);
 
-                                       RDEBUG2("SoH Health-Class-Status microsoft DWORD=%08x", hcstatus);
+                                       DEBUG("SoH Health-Class-Status microsoft DWORD=%08x", hcstatus);
 
                                        vp = pairmake("SoH-MS-Windows-Health-Status", NULL, T_OP_EQ);
                                        switch (curr_hc) {
@@ -566,7 +566,7 @@ int soh_verify(REQUEST *request, VALUE_PAIR *sohvp, const uint8_t *data, unsigne
                                break;
 
                        default:
-                               RDEBUG2("SoH Unknown TLV %i len=%i", tlv.tlv_type, tlv.tlv_len);
+                               DEBUG("SoH Unknown TLV %i len=%i", tlv.tlv_type, tlv.tlv_len);
                                break;
                }
 
index 9917800..52db997 100644 (file)
@@ -194,9 +194,9 @@ static VALUE_PAIR* eapsoh_verify(REQUEST *request, const uint8_t *data, unsigned
        }
 
 
-       rv = soh_verify(request, vp, data, data_len - 8);
+       rv = soh_verify(vp, data, data_len - 8);
        if (rv<0) {
-               RDEBUG("SoH - error decoding payload");
+               RDEBUG("SoH - error decoding payload: %s", fr_strerror());
        } else {
                vp->vp_integer = 1;
        }
index 4cb7aad..c5aa1fe 100644 (file)
@@ -176,7 +176,7 @@ static int soh_postauth(UNUSED void * instance, REQUEST *request)
                                        } else {
                                                RDEBUG("SoH decoding NAP from DHCP request");
                                                /* SoH payload */
-                                               soh_verify(request, request->packet->vps, data, vlen);
+                                               soh_verify(request->packet->vps, data, vlen);
                                        }
                                        break;
                                default: