return rp;
}
-
-/*
- * Get one of User-Name or Stripped-User-Name attributes
- * from the request packet, preferably Stripped-User-Name.
- */
-VALUE_PAIR *rad_get_username(REQUEST *request)
-{
- VALUE_PAIR *namepair;
- VALUE_PAIR *pair;
-
- namepair = NULL;
-
- for (pair = request->packet->vps; pair; pair = pair->next) {
- if (pair->attribute == PW_USER_NAME) {
- namepair = pair;
-
- } else if (pair->attribute == PW_STRIPPED_USER_NAME) {
- return pair;
- }
- }
-
- return namepair;
-}
-
-/*
- * Put a user name into the request packet. This user name
- * will go into a Stripped-User-Name attribute, if it exists.
- * If not, one will be created.
- */
-int rad_put_username(REQUEST *request, const char *username, int length)
-{
- VALUE_PAIR **tail;
- VALUE_PAIR *pair;
-
- if (length >= sizeof(pair->strvalue)) return -1;
-
- tail = &request->packet->vps;
- for (pair = request->packet->vps; pair; pair = pair->next) {
- if (pair->attribute == PW_STRIPPED_USER_NAME) {
- break;
- }
- tail = &pair->next;
- }
-
- if (pair) {
- strncpy(pair->strvalue, username, length);
- } else {
- *tail = pairmake("Stripped-User-Name", username, 0);
- if (*tail == NULL) return -1;
- }
-
- return 0;
-}