Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation is unclear on how vendor specific attributes are handled #27

Open
Kilobyte22 opened this issue Jul 31, 2021 · 1 comment

Comments

@Kilobyte22
Copy link

The documentation does not specify how vendor specific attributes are encoded/accessed. In Particular RFC2865 specifies a format for encoding multiple attributes by a single vendor in a single Attribute 26. I do not see how i would get those.

@ivanovuri
Copy link
Contributor

Hi friend,
Looks like library simply misses this logic and to create VSA containing reply we should craft packet manually.
To create this type of reply:
Снимок экрана от 2023-04-11 17-42-21
We need something like this:

fn hardcode_bytes_vsa() -> Vec<u8> {
    // let avp_type = 26 as u8;
    // let avp_length = 23 as u8;
    let mut avp_vendor_id = 4874_i32.to_be_bytes().to_vec();
    let vsa_type = 65 as u8;
    let vsa_length = 17 as u8;
    let vsa_tag = 5 as u8;
    let mut vsa_usa = "bar(1000,5441)".as_bytes().to_vec();

    let mut vsa: Vec<u8> = Vec::new();

    vsa.append(&mut avp_vendor_id);
    vsa.push(vsa_type);
    vsa.push(vsa_length);
    vsa.push(vsa_tag);
    vsa.append(&mut vsa_usa);

    vsa
}

After that construct with the help of from_bytes function:

let vsa = AVP::from_bytes(VENDOR_SPECIFIC_TYPE, &hardcode_bytes_vsa());
_ = p.add(vsa);

Please note that you should omit type and length values. Type is specified as first parameter and length is calculated automatically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants