/** * Set RADIUS attributes for RADIUS authentication request. * Return 0 on success. */ int ppp_set_radius_attrs_for_authreq(npppd_ppp *_this, radius_req_setting *rad_setting, RADIUS_PACKET *radpkt) { /* RFC 2865 "5.4 NAS-IP-Address" or RFC3162 "2.1. NAS-IPv6-Address" */ if (radius_prepare_nas_address(rad_setting, radpkt) != 0) goto fail; /* RFC 2865 "5.6. Service-Type" */ if (radius_put_uint32_attr(radpkt, RADIUS_TYPE_SERVICE_TYPE, RADIUS_SERVICE_TYPE_FRAMED) != 0) goto fail; /* RFC 2865 "5.7. Framed-Protocol" */ if (radius_put_uint32_attr(radpkt, RADIUS_TYPE_FRAMED_PROTOCOL, RADIUS_FRAMED_PROTOCOL_PPP) != 0) goto fail; if (_this->calling_number[0] != '\0') { if (radius_put_string_attr(radpkt, RADIUS_TYPE_CALLING_STATION_ID, _this->calling_number) != 0) return 1; } return 0; fail: return 1; }
void test06(void) { RADIUS_PACKET *pkt; u_char data[] = { RADIUS_CODE_ACCESS_ACCEPT, 0x01, 0, 20, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; pkt = radius_convert_packet(data, sizeof(data)); CHECK(pkt != NULL); CHECK(!radius_has_attr(pkt, RADIUS_TYPE_MESSAGE_AUTHENTICATOR)); CHECK(!radius_put_uint32_attr(pkt, RADIUS_TYPE_MESSAGE_AUTHENTICATOR, 1)); //CHECK(memcmp(radius_get_data(pkt), data, sizeof(data)) == 0); radius_delete_packet(pkt); }