sftd.h

Go to the documentation of this file.
00001 
00013 #ifndef SFTD_H_
00014 #define SFTD_H_
00015 
00016 #include "uipopt.h"
00017 #include "uip-conf.h"
00018 #include "../mult/api_services.h"
00019 
00023 #define SFTD_BUFFER_DATA 1500
00024 
00030 typedef enum {
00031         ST_INIT=0,              //ESTADO INICIAL
00032         ST_RECV,                //RECEBENDO PACOTE DO HOST
00033         ST_WAIT_RECV,   //AGUARDANDO PARTES DO ARQUIVO QUE ESTÁ SENDO RECEBIDO
00034         ST_FINISHED_RECV,//FINALIVOU O RECEBIMENTO
00035         ST_SEND,                //ENVIANDO PACOTES PARA O HOST
00036         ST_WAIT_SEND,   //AGUARDANDO CONFIRMAÇÃO PARA ENVIO DE OUTRA PARTE DO PACOTE
00037         ST_FINISHED_SEND,//TERMINOU O ENVIO O PACOTE
00038         ST_STOP,
00039         ST_RECVU,               //RECEBENDO PACOTES DO HOST SEM SEGURANCA
00040         ST_CLOSE
00041 } sft_st;
00042 
00048 typedef enum {
00049         CMD_RECV =0,
00050         CMD_RECV_ANS,
00051         CMD_STOP,
00052         CMD_RECV_SEQ,
00053         CMD_FINISHED,
00054         CMD_RECV_X,
00055         CMD_RECVU,
00056         CMD_ERROR,
00057         CMD_MSG
00058 } cmd_sft;
00059 
00066 struct sftd_state {
00067   char buff[SFTD_BUFFER_DATA];
00068   int len_buff;
00069   char data_send[SFTD_BUFFER_DATA];
00070   int len_send;
00071   int mf;
00072   int nr_pkt;
00073   int id;
00074   cmd_sft cmd;
00075   cmd_sft cmd_answer;
00076   sft_st state;
00077 };
00078 
00079 
00084 struct sft_hdr_uip{
00085         char cmd[3];
00086         char len[5];
00087         char mf[2];
00088         char nro_pkt[3];
00089         char id[4];
00090         char buff_send[SFTD_BUFFER_DATA+1];
00091 };
00092 
00093 
00094 void sftd_init(void);
00095 
00096 void sftd_appcall(void);
00097 void sft_senddata(struct sftd_state *s);
00098 int sft_trata(struct sftd_state *s);
00099 void sft_closed(struct sftd_state *s);
00100 
00101 
00102 //funcoes para os comandos
00103 
00104 void carrega_img(struct sftd_state *s);
00105 void carrega_imgu(struct sftd_state *s);
00106 void carrega_img_old(struct sftd_state *s);
00107 void info_host_ans(struct sftd_state *s, int cmd);
00108 void envia_msg(struct sftd_state *s);
00109 
00110 
00111 
00112 #endif /* SFTD_H_ */