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

Subversion Repositories amber

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

Show entire file | Details | Blame | View Log

Rev 80 Rev 81
Line 93... Line 93...
 
 
 
 
 
 
void udp_reply(packet_t* rx_packet, int udp_src_port, int udp_dst_port, int block, int reply_type)
void udp_reply(packet_t* rx_packet, int udp_src_port, int udp_dst_port, int block, int reply_type)
{
{
    char* buf = (char*)ETHMAC_TX_BUFFER;
    char buf[96];
    unsigned short checksum;
    unsigned short checksum;
    unsigned short prot_udp=17;
    unsigned short prot_udp=17;
    unsigned short udp_len;
    unsigned short udp_len;
    unsigned short word16;
    unsigned short word16;
    unsigned long  sum = 0;
    unsigned long  sum = 0;
    int i;
    int i;
    mac_ip_t target;
 
 
 
    target.mac[0] = rx_packet->src_mac[0];
 
    target.mac[1] = rx_packet->src_mac[1];
 
    target.mac[2] = rx_packet->src_mac[2];
 
    target.mac[3] = rx_packet->src_mac[3];
 
    target.mac[4] = rx_packet->src_mac[4];
 
    target.mac[5] = rx_packet->src_mac[5];
 
    target.ip[0]  = rx_packet->src_ip[0];
 
    target.ip[1]  = rx_packet->src_ip[1];
 
    target.ip[2]  = rx_packet->src_ip[2];
 
    target.ip[3]  = rx_packet->src_ip[3];
 
 
 
    /* udp header */
    /* udp header */
    buf[34] = (udp_src_port & 0xff00)>>8;
    buf[34] = (udp_src_port & 0xff00)>>8;
    buf[35] =  udp_src_port & 0xff;
    buf[35] =  udp_src_port & 0xff;
    buf[36] = (udp_dst_port & 0xff00)>>8;
    buf[36] = (udp_dst_port & 0xff00)>>8;
Line 170... Line 158...
 
 
    checksum = header_checksum16(&buf[34], udp_len, sum);
    checksum = header_checksum16(&buf[34], udp_len, sum);
    buf[40] = (checksum & 0xff00)>>8;  // checksum
    buf[40] = (checksum & 0xff00)>>8;  // checksum
    buf[41] =  checksum & 0xff;        // checksum
    buf[41] =  checksum & 0xff;        // checksum
 
 
    ip_header(&buf[14], &target, 20+udp_len, 17); /* 20 byes of tcp  options, bytes 14 to 33, ip_proto = 17, UDP */
    ip_header(&buf[14], (ip_t*) rx_packet->src_ip, 20+udp_len, 17); /* 20 byes of tcp  options, bytes 14 to 33, ip_proto = 17, UDP */
    ethernet_header(buf, &target, 0x0800);  /*bytes 0 to 13*/
    ethernet_header(buf, (mac_t*) rx_packet->src_mac, 0x0800);  /*bytes 0 to 13*/
    tx_packet(34+udp_len);  // packet length in bytes
 
 
    ethmac_tx_packet(buf, 34+udp_len);  // packet length in bytes
}
}
 
 
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

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