I'm working with Cortex M3, Stellaris® LM3S6965 Evaluation Board. I'm sending an UDP packet to my pc. That works because I checked it with wireshark. But what I do see is that I don't have a source port. And I have no clue how so solve this.
I call this function to sent the a udp packet
void send_udp(){
RIT128x96x4Enable(1000000);
RIT128x96x4StringDraw("UDP data verzonden..", 0, 40, 15);
struct ip_addr serverIp;
IP4_ADDR(&serverIp,192,168,1,100);
u16_t port;
port = 64000;
struct udp_pcb * pcb;
pcb = udp_new();
udp_bind(pcb, &serverIp, port);
udp_recv(pcb, udp_echo_recv, NULL);
struct pbuf *p;
char msg[]="request";
//Allocate packet buffer
p = pbuf_alloc(PBUF_TRANSPORT,sizeof(msg),PBUF_RAM);
memcpy (p->payload, msg, sizeof(msg));
udp_sendto(pcb, p, &serverIp, port);
pbuf_free(p); //De-allocate packet buffer
}
Wireshark example of packet: (click here to enlarge)
I also saw that "time to live" in the ipv4 pcb was 0. So I added this line,
pcb->ttl = UDP_TTL; // Time to live
This solved my issue