#3 IpAddress encoding is wrong

closed-fixed
Michael
General (5)
5
2003-03-03
2003-03-02
No

when I try to encode the following IP
"10.4.16.106" you will the following result 10.4.4.4
that is not the expected result ;-)

here is a fix for the constructor methods that takes a
char*

<snip>
EraseData();
string data_string;

char *tmp_string = new char[4];
int index, oldindex;

index = ns.find(".");
oldindex = 0;
for(int i=0; i < 4; i++) {
tmp_string[i] = (char) atoi(ns.substr(oldindex,
index - oldindex).data());

oldindex = index +1;
index = ns.find(".", oldindex +1);
}
data_string.assign(tmp_string,4);

<snip>

this one behave as expected.

Ps: I've seen another "bug" there is no trap-pdu (yet?)
I'll send the fix as soon as it's working and clean ;-)

Cheers,
Oppo.

Discussion

  • Michael

    Michael - 2003-03-03

    Logged In: YES
    user_id=70433

    Thanks, a fix has been added. It should be noted though that IpAddress generally shouldn't be
    used, e.g. for an old MIB that has it. (if I can remember which rfc it is in),
    rfc2578: "Note that the IpAddress type is a tagged type for historical reasons. Network
    addresses should be represented using an invocation of the TEXTUAL-CONVENTION macro"

     
  • Michael

    Michael - 2003-03-03
    • labels: --> General
    • assigned_to: nobody --> baerm
    • status: open --> closed-fixed
     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks