/*----------------------------------------------------------------
|
/*----------------------------------------------------------------
|
// //
|
// //
|
// boot-loader.h //
|
// boot-loader.h //
|
// //
|
// //
|
// This file is part of the Amber project //
|
// This file is part of the Amber project //
|
// http://www.opencores.org/project,amber //
|
// http://www.opencores.org/project,amber //
|
// //
|
// //
|
// Description //
|
// Description //
|
// Defines for the boot-loader application. //
|
// Defines for the boot-loader application. //
|
// //
|
// //
|
// Author(s): //
|
// Author(s): //
|
// - Conor Santifort, csantifort.amber@gmail.com //
|
// - Conor Santifort, csantifort.amber@gmail.com //
|
// //
|
// //
|
//////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////
|
// //
|
// //
|
// Copyright (C) 2010 Authors and OPENCORES.ORG //
|
// Copyright (C) 2010 Authors and OPENCORES.ORG //
|
// //
|
// //
|
// This source file may be used and distributed without //
|
// This source file may be used and distributed without //
|
// restriction provided that this copyright statement is not //
|
// restriction provided that this copyright statement is not //
|
// removed from the file and that any derivative work contains //
|
// removed from the file and that any derivative work contains //
|
// the original copyright notice and the associated disclaimer. //
|
// the original copyright notice and the associated disclaimer. //
|
// //
|
// //
|
// This source file is free software; you can redistribute it //
|
// This source file is free software; you can redistribute it //
|
// and/or modify it under the terms of the GNU Lesser General //
|
// and/or modify it under the terms of the GNU Lesser General //
|
// Public License as published by the Free Software Foundation; //
|
// Public License as published by the Free Software Foundation; //
|
// either version 2.1 of the License, or (at your option) any //
|
// either version 2.1 of the License, or (at your option) any //
|
// later version. //
|
// later version. //
|
// //
|
// //
|
// This source is distributed in the hope that it will be //
|
// This source is distributed in the hope that it will be //
|
// useful, but WITHOUT ANY WARRANTY; without even the implied //
|
// useful, but WITHOUT ANY WARRANTY; without even the implied //
|
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //
|
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //
|
// PURPOSE. See the GNU Lesser General Public License for more //
|
// PURPOSE. See the GNU Lesser General Public License for more //
|
// details. //
|
// details. //
|
// //
|
// //
|
// You should have received a copy of the GNU Lesser General //
|
// You should have received a copy of the GNU Lesser General //
|
// Public License along with this source; if not, download it //
|
// Public License along with this source; if not, download it //
|
// from http://www.opencores.org/lgpl.shtml //
|
// from http://www.opencores.org/lgpl.shtml //
|
// //
|
// //
|
----------------------------------------------------------------*/
|
----------------------------------------------------------------*/
|
|
|
|
|
enum tcp_state {
|
enum tcp_state {
|
TCP_CLOSED = 0,
|
TCP_CLOSED = 0,
|
TCP_PENDING = 1,
|
TCP_LISTENING = 1,
|
TCP_OPEN = 2
|
TCP_PENDING = 2,
|
|
TCP_OPEN = 3
|
};
|
};
|
|
|
|
|
enum tcp_options {
|
enum tcp_options {
|
TCP_NEW = 0,
|
TCP_NEW = 0,
|
TCP_NORMAL = 1,
|
TCP_NORMAL = 1,
|
TCP_RESET = 2
|
TCP_RESET = 2
|
};
|
};
|
|
|
|
|
|
enum app_type {
|
|
APP_TELNET = 0,
|
|
APP_HTTPD = 1,
|
|
APP_FTPD = 2
|
|
};
|
|
|
|
|
|
typedef struct {
|
|
/* socket associated with this application */
|
|
void* socket;
|
|
void* telnet;
|
|
int type;
|
|
} app_t;
|
|
|
|
|
|
|
typedef struct {
|
typedef struct {
|
|
|
packet_buffer_t** tcp_buf;
|
packet_buffer_t** tcp_buf;
|
int tcp_current_buf;
|
int tcp_current_buf;
|
|
|
/* Telnet rx and tx line buffers */
|
|
line_buf_t* telnet_rxbuf;
|
|
line_buf_t* telnet_txbuf;
|
|
|
|
int telnet_sent_opening_message;
|
|
int telnet_echo_mode;
|
|
int telnet_connection_state;
|
|
int telnet_options_sent;
|
|
|
|
int packets_sent;
|
int packets_sent;
|
int packets_received;
|
int packets_received;
|
int packets_resent;
|
int packets_resent;
|
|
|
int tcp_connection_state;
|
int tcp_connection_state;
|
int tcp_reset;
|
int tcp_reset;
|
int tcp_disconnect;
|
int tcp_disconnect;
|
int tcp_seq; /* should be random initial seq number for tcp */
|
|
int tcp_last_seq;
|
|
unsigned int tcp_last_ack;
|
|
|
|
|
/* byte sequence numbers */
|
|
unsigned int tcp_tx_seq; /* initial value should be random initial seq number for tcp */
|
|
|
|
unsigned int tcp_rx_init_seq; /* Initial byte sequence number received from client */
|
|
unsigned int tcp_rx_seq; /* is equivalent to tcp_tx_ack */
|
|
unsigned int tcp_rx_ack;
|
|
|
|
unsigned int tcp_bytes_received;
|
|
unsigned int tcp_bytes_acked;
|
|
|
|
ip_t dest_ip; /* IP address of the far end */
|
|
mac_t dest_mac; /* MAC address of the far end */
|
|
unsigned int listen_port; /* Listen on this port for connection requests */
|
int id;
|
int id;
|
|
|
packet_t* rx_packet; /* Header info from last packet received */
|
packet_t* rx_packet; /* Header info from last packet received */
|
|
|
/* pointers to the next socket in the chain and the first socket in the chain */
|
/* pointers to the next socket in the chain and the first socket in the chain */
|
void* next;
|
void* next;
|
void* first;
|
void* first;
|
|
|
|
/* pointer to generic application object */
|
|
app_t* app;
|
} socket_t;
|
} socket_t;
|
|
|
|
|
|
|
|
|
/* Global Variables */
|
/* Global Variables */
|
extern socket_t* first_socket_g;
|
extern socket_t* first_socket_g;
|
extern int tcp_checksum_errors_g;
|
extern int tcp_checksum_errors_g;
|
|
|
|
|
/* Function prototypes */
|
/* Function prototypes */
|
socket_t* new_socket (socket_t* prev);
|
socket_t* new_socket (socket_t* prev);
|
|
int listen_socket (unsigned int, app_t*);
|
|
void process_sockets ();
|
|
|
unsigned short tcp_checksum (unsigned char *, packet_t*, unsigned short);
|
unsigned short tcp_checksum (unsigned char*, packet_t*, unsigned short);
|
unsigned int tcp_header (char *, socket_t*, int, int);
|
unsigned int tcp_header (char*, socket_t*, int, int);
|
void tcp_reply (socket_t*, char*, int);
|
void tcp_reply (socket_t*, char*, int);
|
void tcp_open (socket_t*);
|
void tcp_open (socket_t*);
|
void tcp_retransmit (socket_t*);
|
void tcp_retransmit (socket_t*);
|
void tcp_ack (socket_t*);
|
void tcp_ack (socket_t*);
|
void tcp_response (char*, socket_t*);
|
void tcp_response (char*, socket_t*);
|
void tcp_disconnect (socket_t*);
|
void tcp_disconnect (socket_t*);
|
void tcp_tx (socket_t*, char*, int);
|
void tcp_tx (socket_t*, char*, int);
|
void parse_tcp_options (char*, packet_t*);
|
void parse_tcp_options (char*, packet_t*);
|
void parse_tcp_packet (char*, packet_t*);
|
void parse_tcp_packet (char*, packet_t*);
|
void process_tcp (socket_t*);
|
void process_tcp (socket_t*);
|
|
|
|
|
|
|
No newline at end of file
|
No newline at end of file
|