Skip to content

Conversation

brummer-simon
Copy link
Member

This PR introduces the abort() function call to GNRC TCP.

In contrast to gnrc_close() (terminates a connection gracefully) gnrc_abort() resets a function immediately.

@miri64 miri64 added Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation GNRC Area: network Area: Networking labels May 3, 2017
@miri64 miri64 requested a review from smlng May 3, 2017 13:01
{
gnrc_pktsnip_t *out_pkt = NULL; /* Outgoing packet */
uint16_t seq_con = 0; /* Sequence number consumption of outgoing packet */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scope of both variables can be reduced, move into if below.

Docu of such internal variables is not necessary, especially when obvious 😉

return -EOPNOTSUPP;

/* A reset must be sent in case the TCB state is in one of those cases */
if (tcb->state == FSM_STATE_SYN_RCVD || tcb->state == FSM_STATE_ESTABLISHED ||
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this might look nicer:

switch (tcb->state) {
case FSM_STATE_SYN_RECV:
case FSM_STATE_ESTABLISHED:
...
case FSM_STATE_CLOSE_WAIT:
    gnrc_pktsnip_t *out_pkt = NULL; 
    uint16_t seq_con = 0;   
    /* Send RST packet without retransmit */
    _pkt_build(tcb, &out_pkt, &seq_con, MSK_RST, tcb->snd_nxt, tcb->rcv_nxt, NULL, 0);
    _pkt_send(tcb, out_pkt, seq_con, false);
    break;
default:
    break;
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I though about it, but it would look inconsistent with all the other cases where I do the state checking.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be something to consider for later on

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm is a switch case more efficient? In one of my earlier semesters, I think that a professor claimed that the switch case solution is in those cases more efficient.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah right, not sure if that matters here - and who knows what modern compiler optimize away anyway 😉 My point rather was, that it might be more readable and extensible (if required in the future) using switch-case over if-else.

But as said, not in this PR - as it is not related ...

*
* @returns Zero on success.
*/
int gnrc_tcp_abort(gnrc_tcp_tcb_t *tcb);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not void as it only returns 0 anyway?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I should change it on close call too then.

@brummer-simon brummer-simon force-pushed the gnrc_tcp-abort_call branch from 92f9648 to 8868204 Compare May 9, 2017 07:29
@smlng
Copy link
Member

smlng commented May 12, 2017

ACK, though changing scope of variables is unrelated to the rest. Let's see what Murdock has to say ...

@smlng smlng added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label May 12, 2017
@smlng
Copy link
Member

smlng commented May 17, 2017

please squash

@brummer-simon brummer-simon force-pushed the gnrc_tcp-abort_call branch from 532d1ba to b08b12e Compare May 17, 2017 11:01
@brummer-simon
Copy link
Member Author

Done

@smlng smlng merged commit 9944642 into RIOT-OS:master May 17, 2017
@brummer-simon brummer-simon deleted the gnrc_tcp-abort_call branch May 17, 2017 13:18
@aabadie aabadie modified the milestone: Release 2017.07 Jun 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: network Area: Networking CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants