Skip to content
Extraits de code Groupes Projets
receiver.h 1,2 ko
Newer Older
  • Learn to ignore specific revisions
  • /**
     * @file receiver.h
     * @brief   This header contains all the structures and functions definitions that ae going to be used by the receiver.c 
    
     */
    
    #ifndef __RECEIVER_UTILS_
    #define __RECEIVER_UTILS_
    
    /* We are using 8 bits to encode the seqnum therefore to fight redondance our window is of 2**(8)/2 */
    
    #define RECV_MAX_SLCTV_RPT_WDW 31
    #define TWO_EXP_EIGHT 256
    
    
    /* Represent the receiver's connection state */
    typedef struct __attribute__((__packed__))
    {
    
        uint8_t curr_recv_window;
        uint8_t recv_window_start;        
    
        pkt_t * recvd_buf[TWO_EXP_EIGHT]; 
        pkt_t * ack_to_send;
        pkt_t * nack_to_send[RECV_MAX_SLCTV_RPT_WDW];
    
    } con_state_t;
    
    
    /**
     * Loop reading on socket and printing to the stdout
     * @sfd : The socket file descriptor. It is both bound and connected.
     * @return: as soon as the whole transfer is done.
     */
    void receiver_read_write_loop(int sfd);
    
    
    /**
     * Creates and initialize a con_state_t structure
     * @return: a valid pointer upon success, else NULL
     */
    con_state_t * state_new();
    
    
    /**
     * Deletes the con_state_t structure pointed by the
     * state argument.
     * @state: the state to delete.
     * @return: / 
     */
    void state_del(con_state_t * state);