OpenCores
URL https://opencores.org/ocsvn/amber/amber/trunk

Subversion Repositories amber

[/] [amber/] [trunk/] [sw/] [boot-loader-ethmac/] [tcp.h] - Blame information for rev 81

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 61 csantifort
/*----------------------------------------------------------------
2
//                                                              //
3
//  boot-loader.h                                               //
4
//                                                              //
5
//  This file is part of the Amber project                      //
6
//  http://www.opencores.org/project,amber                      //
7
//                                                              //
8
//  Description                                                 //
9
//  Defines for the boot-loader application.                    //
10
//                                                              //
11
//  Author(s):                                                  //
12
//      - Conor Santifort, csantifort.amber@gmail.com           //
13
//                                                              //
14
//////////////////////////////////////////////////////////////////
15
//                                                              //
16
// Copyright (C) 2010 Authors and OPENCORES.ORG                 //
17
//                                                              //
18
// This source file may be used and distributed without         //
19
// restriction provided that this copyright statement is not    //
20
// removed from the file and that any derivative work contains  //
21
// the original copyright notice and the associated disclaimer. //
22
//                                                              //
23
// This source file is free software; you can redistribute it   //
24
// and/or modify it under the terms of the GNU Lesser General   //
25
// Public License as published by the Free Software Foundation; //
26
// either version 2.1 of the License, or (at your option) any   //
27
// later version.                                               //
28
//                                                              //
29
// This source is distributed in the hope that it will be       //
30
// useful, but WITHOUT ANY WARRANTY; without even the implied   //
31
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //
32
// PURPOSE.  See the GNU Lesser General Public License for more //
33
// details.                                                     //
34
//                                                              //
35
// You should have received a copy of the GNU Lesser General    //
36
// Public License along with this source; if not, download it   //
37
// from http://www.opencores.org/lgpl.shtml                     //
38
//                                                              //
39
----------------------------------------------------------------*/
40
 
41
 
42
enum tcp_state {
43
        TCP_CLOSED    = 0,
44 81 csantifort
    TCP_LISTENING = 1,
45
        TCP_PENDING   = 2,
46
        TCP_OPEN      = 3
47 61 csantifort
};
48
 
49
 
50
enum tcp_options {
51
        TCP_NEW         = 0,
52
        TCP_NORMAL      = 1,
53
        TCP_RESET       = 2
54
};
55
 
56
 
57 81 csantifort
enum app_type {
58
        APP_TELNET      = 0,
59
        APP_HTTPD       = 1,
60
        APP_FTPD        = 2
61
};
62
 
63
 
64 80 csantifort
typedef struct {
65 81 csantifort
    /* socket associated with this application */
66
    void*               socket;
67
    void*               telnet;
68
    int                 type;
69
} app_t;
70 80 csantifort
 
71
 
72
 
73 81 csantifort
typedef struct {
74 80 csantifort
 
75 81 csantifort
    packet_buffer_t**   tcp_buf;
76
    int                 tcp_current_buf;
77 80 csantifort
 
78 81 csantifort
    int                 packets_sent;
79
    int                 packets_received;
80
    int                 packets_resent;
81 80 csantifort
 
82 81 csantifort
    int                 tcp_connection_state;
83
    int                 tcp_reset;
84
    int                 tcp_disconnect;
85 80 csantifort
 
86 81 csantifort
    /* byte sequence numbers */
87
    unsigned int        tcp_tx_seq;             /* initial value should be random initial seq number for tcp */
88 80 csantifort
 
89 81 csantifort
    unsigned int        tcp_rx_init_seq;        /* Initial byte sequence number received from client */
90
    unsigned int        tcp_rx_seq;             /* is equivalent to tcp_tx_ack */
91
    unsigned int        tcp_rx_ack;
92
 
93
    unsigned int        tcp_bytes_received;
94
    unsigned int        tcp_bytes_acked;
95
 
96
    ip_t                dest_ip;                /* IP address of the far end */
97
    mac_t               dest_mac;               /* MAC address of the far end */
98
    unsigned int        listen_port;            /* Listen on this port for connection requests */
99
    int                 id;
100
 
101
    packet_t*           rx_packet;              /* Header info from last packet received */
102
 
103 80 csantifort
    /* pointers to the next socket in the chain and the first socket in the chain */
104 81 csantifort
    void*               next;
105
    void*               first;
106
 
107
    /* pointer to generic application object */
108
    app_t*              app;
109 80 csantifort
} socket_t;
110
 
111
 
112 81 csantifort
 
113
 
114 80 csantifort
/* Global Variables */
115
extern socket_t*    first_socket_g;
116
extern int          tcp_checksum_errors_g;
117
 
118
 
119
/* Function prototypes */
120
socket_t*       new_socket              (socket_t* prev);
121 81 csantifort
int             listen_socket           (unsigned int, app_t*);
122
void            process_sockets         ();
123 80 csantifort
 
124 81 csantifort
unsigned short  tcp_checksum            (unsigned char*, packet_t*, unsigned short);
125
unsigned int    tcp_header              (char*, socket_t*, int, int);
126 61 csantifort
void            tcp_reply               (socket_t*, char*, int);
127
void            tcp_open                (socket_t*);
128
void            tcp_retransmit          (socket_t*);
129
void            tcp_ack                 (socket_t*);
130
void            tcp_response            (char*, socket_t*);
131
void            tcp_disconnect          (socket_t*);
132
void            tcp_tx                  (socket_t*, char*, int);
133
void            parse_tcp_options       (char*, packet_t*);
134
void            parse_tcp_packet        (char*, packet_t*);
135 80 csantifort
void            process_tcp             (socket_t*);
136 61 csantifort
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.