MCPcopy Create free account
hub / github.com/F-Stack/f-stack / NewFtpMessage

Function NewFtpMessage

freebsd/netinet/libalias/alias_ftp.c:645–777  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

643}
644
645static void
646NewFtpMessage(struct libalias *la, struct ip *pip,
647 struct alias_link *lnk,
648 int maxpacketsize,
649 int ftp_message_type)
650{
651 struct alias_link *ftp_lnk;
652
653/* Security checks. */
654 if (pip->ip_src.s_addr != la->true_addr.s_addr)
655 return;
656
657 if (la->true_port < IPPORT_RESERVED)
658 return;
659
660 /* Establish link to address and port found in FTP control message. */
661 ftp_lnk = AddLink(la, la->true_addr, GetDestAddress(lnk),
662 GetAliasAddress(lnk), htons(la->true_port), 0, GET_ALIAS_PORT,
663 IPPROTO_TCP);
664
665 if (ftp_lnk != NULL) {
666 int slen, hlen, tlen, dlen;
667 struct tcphdr *tc;
668
669#ifndef NO_FW_PUNCH
670 /* Punch hole in firewall */
671 PunchFWHole(ftp_lnk);
672#endif
673
674/* Calculate data length of TCP packet */
675 tc = (struct tcphdr *)ip_next(pip);
676 hlen = (pip->ip_hl + tc->th_off) << 2;
677 tlen = ntohs(pip->ip_len);
678 dlen = tlen - hlen;
679
680/* Create new FTP message. */
681 {
682 char stemp[MAX_MESSAGE_SIZE + 1];
683 char *sptr;
684 u_short alias_port;
685 u_char *ptr;
686 int a1, a2, a3, a4, p1, p2;
687 struct in_addr alias_address;
688
689/* Decompose alias address into quad format */
690 alias_address = GetAliasAddress(lnk);
691 ptr = (u_char *) & alias_address.s_addr;
692 a1 = *ptr++;
693 a2 = *ptr++;
694 a3 = *ptr++;
695 a4 = *ptr;
696
697 alias_port = GetAliasPort(ftp_lnk);
698
699/* Prepare new command */
700 switch (ftp_message_type) {
701 case FTP_PORT_COMMAND:
702 case FTP_227_REPLY:

Callers 1

AliasHandleFtpOutFunction · 0.85

Calls 13

AddLinkFunction · 0.85
GetDestAddressFunction · 0.85
GetAliasAddressFunction · 0.85
PunchFWHoleFunction · 0.85
ip_nextFunction · 0.85
GetAliasPortFunction · 0.85
sprintfFunction · 0.85
strncpyFunction · 0.85
SetAckModifiedFunction · 0.85
GetDeltaSeqOutFunction · 0.85
AddSeqFunction · 0.85
DifferentialChecksumFunction · 0.85

Tested by

no test coverage detected