From: Mark S. <mar...@di...> - 2003-06-14 14:28:36
|
No, it was nasty to start with and this just makes it even nastier. I think the cleaner way would be to do something like this: struct sillystruct { struct iax2_frame fr2; unsigned char buffer[4096]; } tmp; and then reference tmp.fr2 and tmp.buffer; Mark On 12 Jun 2003, Steve Kann wrote: > > Mark, > > Here's a good one, that took a bit to figure out also. This problem > only occurs with MacOSX, although it just depends on which way the stack > grows.. > > in iax_send, you have the following code: > unsigned char buffer[4096]; /* Buffer -- must > preceed fr2 */ > struct iax_frame fr2; > struct iax_frame *fr; > > and later, you do this: > if (now) { > fr = &fr2; > } else > fr = iax_frame_new(DIRECTION_OUTGRESS, f->datalen); > if (!fr) { > IAXERROR "Out of memory\n"); > return -1; > } > > fprintf(stderr, "now=%d, fr=%x, &fr2=%x\n", now, fr, &fr2); > fprintf(stderr, "f->datalen=%d\n", f->datalen); > > /* Copy our prospective frame into our immediate or > retransmitted wrapper */ > iax_frame_wrap(fr, f); > > fprintf(stderr, "now=%d, fr=%x, &fr2=%x\n", now, fr, &fr2); > > > (fprintfs are mine) which if (now=1) and f has data, copies some items > from f into fr2, and then copies data to from f to fr. This data ends > up past the end of fr2, which you account for, on machines with one > stack direction, with the buffer on the stack. > > So, I think it would be better to just do this instead: > double buffer[1024]; /* Buffer -- does double > guarantee us proper alignment? */ > struct iax_frame *fr; > > [...] > > if (now) { > fr = (struct iax_frame *)&buffer; > } else > fr = iax_frame_new(DIRECTION_OUTGRESS, f->datalen); > if (!fr) { > IAXERROR "Out of memory\n"); > return -1; > } > > fprintf(stderr, "now=%d, fr=%x\n", now, fr); > fprintf(stderr, "f->datalen=%d\n", f->datalen); > > /* Copy our prospective frame into our immediate or > retransmitted wrapper */ > iax_frame_wrap(fr, f); > > fprintf(stderr, "now=%d, fr=%x\n", now, fr); > > > Does this seem like it will be more portable? > > It works for me on MacOSX/PPC, Linux/x86, Win2K/x86. > > Attached also please find my current diff between my local libiax2 and > digium's CVS. It is still mostly portability fixes, plus the two > bugfixes (this one, and the buf[len-1] = 0 issue). > > Next on the list: using IAX2, for some reason the DNID isn't being > honored. This is kinda strange, because using "iax2 debug" on the > console of a * server, it shows the DNID properly, but I still end up in > the "s" extension for the context, instead of the requested extension.. > > > -SteveK > > > > > -- > Steve Kann - Chief Engineer - 520 8th Ave #2300 NY 10018 - (212) 533-1775 > HorizonLive.com - collaborate . interact . learn > "The box said 'Requires Windows 95, NT, or better,' so I installed Linux." > |