It's been noticed that the SDP body gets missing
after multipart body arrives with quoted boundaries.
The reason for that is the multi-part body,
which has boundaries quoted at both beginning and the end.
As a result 'AmMimeBody::findNextBoundary()' is not able
to parse/find next boundary, and the multi-part body
entirely gets stripped.
This commit fixes this misbehavior.
Change-Id: I73beab32ea97a8ed148180ab6b149f84fe8c0ac1
Don't check the SDP body length by NULL pointer,
but actually by this AmMimeBody where we currently are.
Change-Id: I86a65eec82c0f5c73eb3f2653c0c27aae7f1cb7f
Add parsing of Content-Length, for cases
were this length matters (e.g. ct length > 0,
but suddenly there is no SDP body).
Also add a getter for the AmContentType's length.
Change-Id: I92cdd19319c6f4a4edcfbaeec7bad1be12c8a0b1
Rework the payload to be a string instead of the raw char array.
This eliminates cases when we actually need to track that this char array
is indeed null-terminated and deprives us from doing other tricks to
properly maintain this char array.
Also no need to return const of payload anymore, because simply copied
during return. Data protection ensured by not giving a reference to the payload,
modifiable still during the first time setting this payload.
Rework also other users, such as nested call into AmSdp provided `parse()`.
Now `parse()` takes a string, and already in a local scope handles a char array
copy of this given string. This is only because the `parse_sdp_line_ex()` still
requires a refactor to be working with strings instead of char array.
Additionally: move parser helpers of AmSdp to const char pointers,
instead of working on a plain char pointer. This is because the SDP body
parser has been moved from the referenced pointer `char *&`
to the `const char *` pointer. This allows to not have additionally
heap allocated SDP body C-string for parsing purposes.
No functional change.
Change-Id: Ic3ee6c349b62e7e5e0cd4de722f9ed923862a7cb
Preamble: no functional changes.
AmSdp::parse() mixes int values with bool,
what makes the behavior not really clear, not defined
and can lead to the unpredicted result (even though the
compiler *should* actually fix that, but one ought to
not rely on this).
Hence make the parse method only be working with bool values.
Then, reverse the return value so that it's clear
that wrongly parsed is `false`, and good parsed is `true`.
Refactor all users accordingly.
Also rework those users, who indeed need `int` value
be returned, e.g. when having -1.
Do the same thing with the `parse_sdp_line_ex()` helper,
whereas parse() is the only user of it. And also reverse
the interpretation of true/false.
Then, make `parse()` working with a plain `char*`, so not a const.
Because doing a tricks like:
cast `char*` to const (user level) -> cast `const char*` to non-const
in a function (in a old C-like manner), has really no sense.
Refactor everything accordingly.
Other than that, refactor AmMimeBody:
Refactor it to work with a plain `char *` pointer instead of working
with `unsigned char *`, which nowadays has really no sense and
rather is a rudiment of C-like code base coming from the past.
Convert `payload` from `unsigned char*` to `char *` accordingly.
Refactor everything in AmMimeBody implementation accordingly.
Remove rudiment C-like casting everywhere, where possible.
Update `parseMultipart()` to work with a plain `const char *`
instead of `const unsigned char*`
P.S.: leave a list of TODO's for further rework, which
is not directly related to this scope of rework.
Change-Id: Ie1e132429245e0d2cc740d5b1c1fc17cf037a820
The fix for:
AmMimeBody.cpp: In member function 'void AmContentType::resetBoundary()':
AmMimeBody.cpp:122:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
122 | if ((*l_it)->type == Param::BOUNDARY)
| ^~
AmMimeBody.cpp:124:7: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
124 | params.erase(l_it);
| ^~~~~~
Change-Id: I96ff98ff20c83949f294fd863e5d6d3880ece9d8
Eliminate the `auto_ptr` usage for core/* ,
since this pointer type has been deprecated in C++11.
Use, as recommended, `unique_ptr` instead.
Change-Id: I352e03bd0c8401d9a4890d8a1845913e4c22dab3
Strip doublequotes on SDP boundary when the Content-Type header
contains them.
for example:
Content-Type: multipart/mixed;boundary="unique-boundary-1"
will now produce something like that
--unique-boundary-1
Content-Type: application/sdp
v=0
o=user1 53655765 2353687637 IN IP4 10.0.0.179
s=-
c=IN IP4 10.0.0.179
t=0 0
m=audio 30000 RTP/AVP 8
a=rtpmap:8 PCMA/8000
a=sendrecv
a=rtcp:30001
a=ptime:50
--unique-boundary-1
Content-Type: application/vnd.cirpack.isdn-ext
Content-Disposition: signal;handling=required
...
and not
--"unique-boundary-1"
Change-Id: I2efb749c6ff9be4e8ccde62bcf544c72cdb5ad6e
We have to improve AmOfferAnswer functions in terms of adding
more logging, to let the debug of the OA be more clear.
Also in parallel the refactoring is done in scope of AmOfferAnswer
in order to make reading more convenient.
Change-Id: If7353f1285057760dd5fbeada984a5ef96af9854