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

Subversion Repositories amber

[/] [amber/] [trunk/] [sw/] [boot-loader-ethmac/] [packet.c] - Diff between revs 61 and 80

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 61 Rev 80
Line 54... Line 54...
/* Global variables */
/* Global variables */
mac_ip_t self_g = { {0x00, 0x0e, 0x70, 0x70, 0x70, 0x70},  /* MAC Address  */
mac_ip_t self_g = { {0x00, 0x0e, 0x70, 0x70, 0x70, 0x70},  /* MAC Address  */
                    {192, 168, 0, 17}                      /* IPv4 address */
                    {192, 168, 0, 17}                      /* IPv4 address */
                  };
                  };
 
 
 
 
packet_t*   rx_packet_g;
packet_t*   rx_packet_g;
socket_t*   socket0_g;
 
socket_t*   socket1_g;
 
 
 
 
 
 
 
socket_t* init_socket(int socket_id)
void init_packet()
{
{
    socket_t* socket;
    /* receive packet buffer */
 
    rx_packet_g = malloc(sizeof(packet_t));
    socket = (socket_t*) malloc(sizeof(socket_t));
 
    socket->rx_packet =(packet_t*) malloc(sizeof(packet_t));
 
    init_packet_buffers(socket);
 
 
 
    socket->telnet_txbuf = init_line_buffer(0x80000);
 
    socket->telnet_rxbuf = init_line_buffer(0x1000);
 
 
 
    socket->id = socket_id;
 
 
 
    socket->packets_sent = 0;
 
    socket->packets_received = 0;
 
    socket->packets_resent = 0;
 
 
 
    socket->telnet_sent_opening_message = 0;
 
    socket->telnet_echo_mode = 0;
 
    socket->telnet_connection_state = TELNET_CLOSED;
 
    socket->telnet_options_sent = 0;
 
 
 
    socket->tcp_current_buf = 0;
 
    socket->tcp_reset = 0;
 
    socket->tcp_connection_state = TCP_CLOSED;
 
    socket->tcp_disconnect = 0;
 
    socket->tcp_seq = 0x100;  /* should be random initial seq number for tcp */
 
    socket->tcp_last_seq = socket->tcp_seq;
 
    socket->tcp_last_ack = 0;
 
 
 
    return socket;
 
}
}
 
 
 
 
void init_packet_buffers (socket_t* socket)
 
{
 
    int i;
 
 
 
    /* Create space for an array of pointers */
 
    socket->tcp_buf = malloc (TCP_TX_BUFFERS * sizeof (void *));
 
 
 
    /* Create space for a set of buffers, each pointed to by an element of the array */
 
    for (i=0;i<TCP_TX_BUFFERS;i=i+1) {
 
        socket->tcp_buf[i] = (packet_buffer_t*) malloc (sizeof (packet_buffer_t));
 
        socket->tcp_buf[i]->payload_valid = 0;
 
        socket->tcp_buf[i]->starting_seq = 0;
 
        socket->tcp_buf[i]->ending_seq   = 0;
 
        socket->tcp_buf[i]->len_bytes    = 0;
 
        socket->tcp_buf[i]->ack_received = 0;
 
        }
 
}
 
 
 
 
 
void ethernet_header(char *buf, mac_ip_t* target, unsigned short type)
void ethernet_header(char *buf, mac_ip_t* target, unsigned short type)
{
{
    /* ethernet header */
    /* ethernet header */
    /* DA */
    /* DA */

powered by: WebSVN 2.1.0

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