
radius_get_vendor_attr 함수는 radius 서버에서 vendor-specific attribute를 얻어오는 함수입니다.
이 함수의 파라미터는 다음과 같습니다.
- vendor_id: vendor ID
- attr_type: attribute type
- attr_value: attribute value
반환값은 성공 시 attribute value를, 실패 시 NULL을 반환합니다.
특정 attribute를 얻을 때는 다음과 같이 사용할 수 있습니다.
#hostingforum.kr
c
char *attr_value = radius_get_vendor_attr(vendor_id, attr_type);
if (attr_value != NULL) {
// attribute value를 사용할 수 있습니다.
printf("%sn", attr_value);
free(attr_value); // attribute value를 free해야 합니다.
} else {
// attribute value를 얻을 수 없습니다.
}
이 함수를 사용하여 attribute를 얻어올 때 발생할 수 있는 오류는 다음과 같습니다.
- vendor_id가 유효하지 않은 경우
- attr_type이 유효하지 않은 경우
- attribute value를 얻을 수 없는 경우
이러한 오류를 처리하기 위해서는 다음과 같이 코드를 작성할 수 있습니다.
#hostingforum.kr
c
int ret = radius_get_vendor_attr(vendor_id, attr_type, &attr_value);
if (ret == RADIUS_SUCCESS) {
// attribute value를 사용할 수 있습니다.
printf("%sn", attr_value);
free(attr_value); // attribute value를 free해야 합니다.
} else {
// 오류를 처리합니다.
if (ret == RADIUS_INVALID_VENDOR_ID) {
// vendor_id가 유효하지 않은 경우
} else if (ret == RADIUS_INVALID_ATTR_TYPE) {
// attr_type이 유효하지 않은 경우
} else {
// attribute value를 얻을 수 없는 경우
}
}
radius_get_vendor_attr 함수는 radius 서버의 vendor-specific attribute를 얻어오는 함수이므로, radius 서버가 vendor-specific attribute를 지원하는지 확인해야 합니다.
2025-05-30 22:31