| 410 | } |
| 411 | |
| 412 | int pinghttpsend(packet_t *packet,mg_con_t *mgp,int sfd,struct sockaddr *toaddr) |
| 413 | { |
| 414 | int rc; |
| 415 | usleep(100000); |
| 416 | if (options.v) ip_hdr_dump(packet->storage,"sending:"); |
| 417 | //struct iphdr *pip = (struct iphdr*)packet->s; |
| 418 | //printf("packet->len = %d tot_len=%d\n",packet->tot_len,ntohs(pip->tot_len)); |
| 419 | if (options.use_tunnel) { |
| 420 | rc = write(tun_fd,packet->storage,packet->tot_len); |
| 421 | } else if (mgp) { |
| 422 | #ifndef STANDALONE |
| 423 | rc = miniggsn_snd_npdu_by_mgc(mgp,packet->storage,packet->tot_len); |
| 424 | #endif |
| 425 | } else { |
| 426 | // Note: when I left the non-raw socket connected above and fell through |
| 427 | // to this code, it looked like the raw socket may not receive on this port until |
| 428 | // the connected socket is closed, not sure. |
| 429 | rc = sendto(sfd,packet->storage,packet->tot_len,0,toaddr,sizeof(struct sockaddr)); |
| 430 | } |
| 431 | if (rc < 0) { |
| 432 | printf("sendto failed: %s\n",strerror(errno)); |
| 433 | return 2; |
| 434 | } |
| 435 | return 0; |
| 436 | } |
| 437 | |
| 438 | |
| 439 |
no test coverage detected