-
Notifications
You must be signed in to change notification settings - Fork 84
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
sipsess: refactor and simplify SDP negotiation state #1016
Conversation
da089a3
to
30c31d6
Compare
@@ -74,3 +83,4 @@ void sipsess_close_all(struct sipsess_sock *sock); | |||
struct sip_dialog *sipsess_dialog(const struct sipsess *sess); | |||
void sipsess_abort(struct sipsess *sess); | |||
bool sipsess_ack_pending(const struct sipsess *sess); | |||
enum sdp_neg_state sipsess_sdp_neg_state(const struct sipsess *sess); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the state have to be exposed to the application?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe so. E.g. the application can check if the state is SDP_NEG_PREVIEW_ANSWER
(unreliable SDP answer was sent in 1XX response) and in this case it MUST send the exact same SDP in the 200 OK. Ideally, re would not allow non RFC conformant usage, but we're not there yet. That would take more refactoring that could be done in a subsequent step.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The following BareSIP PR makes use of the state:
30c31d6
to
811668a
Compare
5e945aa
to
daae405
Compare
daae405
to
755bdb7
Compare
755bdb7
to
4ff4bab
Compare
4ff4bab
to
a55bdba
Compare
Looks good now. |
SDP_NEG_REMOTE_OFFER = (1 << 1), /** SDP offer received */ | ||
SDP_NEG_PREVIEW_ANSWER = (1 << 2), /** SDP preview answer sent */ | ||
SDP_NEG_DONE = (1 << 3) /** SDP negotiation done */ | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this a "state" or "flags" ?
If it is flags then the stored value can contain a bitmask of many values ORed together.
If it is a state, the value can only contain one value and the states values 1<<N
is not needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initially I thought it could be useful in some cases to OR the values (like flags), but I didn't end up using it anywhere. I have removed the explicit enum values.
5dff203
to
f03d626
Compare
f03d626
to
8c7d2e6
Compare
The SDP negotiation state is now tracked in a single enum which is used as a state machine to keep track of the current state of the SDP negotiation.
8c7d2e6
to
776c8c9
Compare
The SDP negotiation state is now tracked in a single enum which is used as a state machine to keep track of the current state of the SDP negotiation. This makes reasoning about the SDP negotiation much easier and less error prone.
Some details about SDP offer/answer are now enforced more strictly, e.g. the first reliable non-failure response to an INVITE MUST contain an SDP offer, if the INVITE contained no offer.
Read about SDP negotiation in the excellent informational RFC 6337.