From: cparker Date: Fri, 26 Oct 2001 00:24:12 +0000 (+0000) Subject: Preliminary support for displaying Tunnel attributes as defined in X-Git-Tag: debian_version_0_3-2~59 X-Git-Url: http://www.project-moonshot.org/gitweb/?a=commitdiff_plain;h=003cf41d29ae56569eef54f0c87672eb4dc2ca21;p=freeradius.git Preliminary support for displaying Tunnel attributes as defined in RFC 2868. Tag is properly printed for both string and integer attributes when server or radclient displays A/V debugging pairs. raddb/dictionary.tunnel is not changed yet. Type will need to updated for the tunnel attributes to t_string or t_integer for these changes to be displayed. --- diff --git a/src/include/radius.h b/src/include/radius.h index 626acc8..0d399ea 100644 --- a/src/include/radius.h +++ b/src/include/radius.h @@ -12,6 +12,8 @@ #define PW_TYPE_DATE 3 #define PW_TYPE_ABINARY 4 #define PW_TYPE_OCTETS 5 +#define PW_TYPE_T_STRING 6 +#define PW_TYPE_T_INTEGER 7 #define PW_AUTHENTICATION_REQUEST 1 #define PW_AUTHENTICATION_ACK 2 diff --git a/src/lib/dict.c b/src/lib/dict.c index 7ab8ff4..71ea5c9 100644 --- a/src/lib/dict.c +++ b/src/lib/dict.c @@ -32,6 +32,8 @@ static const char *dtypes[] = { "date", "abinary", "octets", + "t_string", + "t_integer", NULL, }; diff --git a/src/lib/print.c b/src/lib/print.c index ec0d5a8..5c12bcd 100644 --- a/src/lib/print.c +++ b/src/lib/print.c @@ -88,6 +88,7 @@ int vp_prints_value(char * out, int outlen, VALUE_PAIR *vp, int delimitst) char buf[1024]; char *a; time_t t; + int offset; out[0] = 0; if (!vp) return 0; @@ -154,6 +155,43 @@ int vp_prints_value(char * out, int outlen, VALUE_PAIR *vp, int delimitst) a = buf; break; + case PW_TYPE_T_STRING: + if (delimitst) { + offset = snprintf(buf, sizeof(buf), + "\"%u:", vp->strvalue[0]); + librad_safeprint((char *)(vp->strvalue + 1), + vp->length - 1, + buf + offset, + sizeof(buf) - offset); + strcat(buf, "\""); + } else { + offset = snprintf(buf, sizeof(buf), + "%u:", vp->strvalue[0]); + librad_safeprint((char *)(vp->strvalue + 1), + vp->length - 1, + buf + offset, + sizeof(buf) - offset); + } + + a = buf; + + break; + + case PW_TYPE_T_INTEGER: + offset = snprintf(buf, sizeof(buf), "%u:", (vp->lvalue >> 24)); + if ((v = dict_valbyattr(vp->attribute, (vp->lvalue))) + != NULL) + snprintf(buf + offset, sizeof(buf) - offset, + "%s", v->name); + else { + snprintf(buf + offset, sizeof(buf) - offset, + "%u", vp->lvalue); + + } + + a = buf; + + break; default: a = 0; break; diff --git a/src/lib/radius.c b/src/lib/radius.c index 2bca33b..36cc103 100644 --- a/src/lib/radius.c +++ b/src/lib/radius.c @@ -987,6 +987,7 @@ int rad_decode(RADIUS_PACKET *packet, RADIUS_PACKET *original, const char *secre case PW_TYPE_OCTETS: case PW_TYPE_ABINARY: case PW_TYPE_STRING: + case PW_TYPE_T_STRING: /* * Hmm... this is based on names right * now. We really shouldn't do this. @@ -1009,6 +1010,7 @@ int rad_decode(RADIUS_PACKET *packet, RADIUS_PACKET *original, const char *secre case PW_TYPE_INTEGER: case PW_TYPE_DATE: case PW_TYPE_IPADDR: + case PW_TYPE_T_INTEGER: /* * Check for RFC compliance. If the * attribute isn't compliant, turn it