Lines Matching +full:8 +full:- +full:ch

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
110 if (ah->dport == NULL || ah->sport == NULL || ah->lnk == NULL || in fingerprint_out()
111 ah->maxpktsize == 0) in fingerprint_out()
112 return (-1); in fingerprint_out()
113 if (ntohs(*ah->dport) == FTP_CONTROL_PORT_NUMBER || in fingerprint_out()
114 ntohs(*ah->sport) == FTP_CONTROL_PORT_NUMBER) in fingerprint_out()
116 return (-1); in fingerprint_out()
122 if (ah->dport == NULL || ah->sport == NULL || ah->lnk == NULL) in fingerprint_in()
123 return (-1); in fingerprint_in()
124 if (ntohs(*ah->dport) == FTP_CONTROL_PORT_NUMBER || in fingerprint_in()
125 ntohs(*ah->sport) == FTP_CONTROL_PORT_NUMBER) in fingerprint_in()
127 return (-1); in fingerprint_in()
133 AliasHandleFtpOut(la, pip, ah->lnk, ah->maxpktsize); in protohandler_out()
140 AliasHandleFtpIn(la, pip, ah->lnk); in protohandler_in()
230 hlen = (pip->ip_hl + tc->th_off) << 2; in AliasHandleFtpOut()
231 tlen = ntohs(pip->ip_len); in AliasHandleFtpOut()
232 dlen = tlen - hlen; in AliasHandleFtpOut()
246 if (ntohs(tc->th_dport) == FTP_CONTROL_PORT_NUMBER) { in AliasHandleFtpOut()
258 la->true_addr.s_addr = pip->ip_src.s_addr; in AliasHandleFtpOut()
269 tlen = ntohs(pip->ip_len); /* recalc tlen, pkt may have grown */ in AliasHandleFtpOut()
270 if (sptr[tlen - 2] == '\r' && sptr[tlen - 1] == '\n') in AliasHandleFtpOut()
289 hlen = (pip->ip_hl + tc->th_off) << 2; in AliasHandleFtpIn()
290 tlen = ntohs(pip->ip_len); in AliasHandleFtpIn()
291 dlen = tlen - hlen; in AliasHandleFtpIn()
303 ntohs(tc->th_dport) == FTP_CONTROL_PORT_NUMBER && in AliasHandleFtpIn()
308 * behind NAT. We need to alias server->client connection in AliasHandleFtpIn()
311 AddLink(la, GetOriginalAddress(lnk), la->true_addr, in AliasHandleFtpIn()
312 GetAliasAddress(lnk), htons(FTP_CONTROL_PORT_NUMBER - 1), in AliasHandleFtpIn()
313 htons(la->true_port), GET_ALIAS_PORT, IPPROTO_TCP); in AliasHandleFtpIn()
318 tlen = ntohs(pip->ip_len); /* recalc tlen, pkt may in AliasHandleFtpIn()
320 if (sptr[tlen - 2] == '\r' && sptr[tlen - 1] == '\n') in AliasHandleFtpIn()
331 char ch; in ParseFtpPortCommand() local
349 ch = sptr[i]; in ParseFtpPortCommand()
352 if (isspace(ch)) in ParseFtpPortCommand()
362 if (isdigit(ch)) { in ParseFtpPortCommand()
363 octet = ch - '0'; in ParseFtpPortCommand()
371 case 8: in ParseFtpPortCommand()
372 if (isdigit(ch)) in ParseFtpPortCommand()
373 octet = 10 * octet + ch - '0'; in ParseFtpPortCommand()
374 else if (ch == ',') { in ParseFtpPortCommand()
375 addr = (addr << 8) + octet; in ParseFtpPortCommand()
382 if (isdigit(ch)) in ParseFtpPortCommand()
383 octet = 10 * octet + ch - '0'; in ParseFtpPortCommand()
384 else if (ch == ',' || state == 12) { in ParseFtpPortCommand()
385 port = (port << 8) + octet; in ParseFtpPortCommand()
394 la->true_addr.s_addr = htonl(addr); in ParseFtpPortCommand()
395 la->true_port = port; in ParseFtpPortCommand()
404 char ch, delim; in ParseFtpEprtCommand() local
420 delim = '|'; /* XXX gcc -Wuninitialized */ in ParseFtpEprtCommand()
423 ch = sptr[i]; in ParseFtpEprtCommand()
426 if (!isspace(ch)) { in ParseFtpEprtCommand()
427 delim = ch; in ParseFtpEprtCommand()
432 if (ch == '1') /* IPv4 address */ in ParseFtpEprtCommand()
438 if (ch == delim) in ParseFtpEprtCommand()
447 if (isdigit(ch)) { in ParseFtpEprtCommand()
448 octet = ch - '0'; in ParseFtpEprtCommand()
455 case 8: in ParseFtpEprtCommand()
457 if (isdigit(ch)) in ParseFtpEprtCommand()
458 octet = 10 * octet + ch - '0'; in ParseFtpEprtCommand()
459 else if (ch == '.' || state == 10) { in ParseFtpEprtCommand()
460 addr = (addr << 8) + octet; in ParseFtpEprtCommand()
466 if (isdigit(ch)) { in ParseFtpEprtCommand()
467 port = ch - '0'; in ParseFtpEprtCommand()
473 if (isdigit(ch)) in ParseFtpEprtCommand()
474 port = 10 * port + ch - '0'; in ParseFtpEprtCommand()
475 else if (ch == delim) in ParseFtpEprtCommand()
484 la->true_addr.s_addr = htonl(addr); in ParseFtpEprtCommand()
485 la->true_port = port; in ParseFtpEprtCommand()
494 char ch; in ParseFtp227Reply() local
513 ch = sptr[i]; in ParseFtp227Reply()
516 if (ch == '(') in ParseFtp227Reply()
525 if (isdigit(ch)) { in ParseFtp227Reply()
526 octet = ch - '0'; in ParseFtp227Reply()
534 case 8: in ParseFtp227Reply()
535 if (isdigit(ch)) in ParseFtp227Reply()
536 octet = 10 * octet + ch - '0'; in ParseFtp227Reply()
537 else if (ch == ',') { in ParseFtp227Reply()
538 addr = (addr << 8) + octet; in ParseFtp227Reply()
545 if (isdigit(ch)) in ParseFtp227Reply()
546 octet = 10 * octet + ch - '0'; in ParseFtp227Reply()
547 else if (ch == ',' || (state == 12 && ch == ')')) { in ParseFtp227Reply()
548 port = (port << 8) + octet; in ParseFtp227Reply()
557 la->true_port = port; in ParseFtp227Reply()
558 la->true_addr.s_addr = htonl(addr); in ParseFtp227Reply()
567 char ch, delim; in ParseFtp229Reply() local
581 delim = '|'; /* XXX gcc -Wuninitialized */ in ParseFtp229Reply()
585 ch = sptr[i]; in ParseFtp229Reply()
588 if (ch == '(') in ParseFtp229Reply()
592 delim = ch; in ParseFtp229Reply()
597 if (ch == delim) in ParseFtp229Reply()
603 if (isdigit(ch)) { in ParseFtp229Reply()
604 port = ch - '0'; in ParseFtp229Reply()
610 if (isdigit(ch)) in ParseFtp229Reply()
611 port = 10 * port + ch - '0'; in ParseFtp229Reply()
612 else if (ch == delim) in ParseFtp229Reply()
618 if (ch == ')') in ParseFtp229Reply()
627 la->true_port = port; in ParseFtp229Reply()
642 if (pip->ip_src.s_addr != la->true_addr.s_addr) in NewFtpMessage()
645 if (la->true_port < IPPORT_RESERVED) in NewFtpMessage()
649 ftp_lnk = AddLink(la, la->true_addr, GetDestAddress(lnk), in NewFtpMessage()
650 GetAliasAddress(lnk), htons(la->true_port), 0, GET_ALIAS_PORT, in NewFtpMessage()
664 hlen = (pip->ip_hl + tc->th_off) << 2; in NewFtpMessage()
665 tlen = ntohs(pip->ip_len); in NewFtpMessage()
666 dlen = tlen - hlen; in NewFtpMessage()
725 strncpy(sptr, stemp, maxpacketsize - hlen); in NewFtpMessage()
734 delta = GetDeltaSeqOut(tc->th_seq, lnk); in NewFtpMessage()
735 AddSeq(lnk, delta + slen - dlen, pip->ip_hl, in NewFtpMessage()
736 pip->ip_len, tc->th_seq, tc->th_off); in NewFtpMessage()
744 MIN(slen, maxpacketsize - hlen)); in NewFtpMessage()
745 DifferentialChecksum(&pip->ip_sum, in NewFtpMessage()
747 &pip->ip_len, in NewFtpMessage()
749 pip->ip_len = new_len; in NewFtpMessage()
753 tc->th_sum = 0; in NewFtpMessage()
757 tc->th_sum = TcpChecksum(pip); in NewFtpMessage()