FreeBSD/libexec/tftpd/tftp-io.c
/*
 * Send an OACK packet (option acknowledgement).
 */
Send an OACK packet (option acknowledgement).
Send an OACK packet ( option acknowledgement ) .
int
send_oack(int peer)
{
	struct tftphdr *tp;
	int size, i, n;
	char *bp;
	char buf[MAXPKTSIZE];
	if (debug&DEBUG_PACKETS)
		tftp_log(LOG_DEBUG, "Sending OACK");
	DROPPACKETn("send_oack", 0);
	tp = (struct tftphdr *)buf;
	bp = buf + 2;
	size = sizeof(buf) - 2;
	tp->th_opcode = htons((u_short)OACK);
	for (i = 0; options[i].o_type != NULL; i++) {
		if (options[i].o_reply != NULL) {
			n = snprintf(bp, size, "%s%c%s", options[i].o_type,
				     0, options[i].o_reply);
			bp += n+1;
			size -= n+1;
			if (size < 0) {
				tftp_log(LOG_ERR, "oack: buffer overflow");
				exit(1);
			}
		}
	}
	size = bp - buf;
	if (sendto(peer, buf, size, 0,
		(struct sockaddr *)&peer_sock, peer_sock.ss_len) != size) {
		tftp_log(LOG_INFO, "send_oack: %s", strerror(errno));
		return (1);
	}
	return (0);
}
int send_oack ( int peer ) { struct tftphdr * tp ; int size , i , n ; char * bp ; char buf [ MAXPKTSIZE ] ; if ( debug & DEBUG_PACKETS ) tftp_log ( LOG_DEBUG , " " ) ; DROPPACKETn ( " " , 0 ) ; tp = ( struct tftphdr * ) buf ; bp = buf + 2 ; size = sizeof ( buf ) - 2 ; tp -> th_opcode = htons ( ( u_short ) OACK ) ; for ( i = 0 ; options [ i ] . o_type != NULL ; i ++ ) { if ( options [ i ] . o_reply != NULL ) { n = snprintf ( bp , size , " " , options [ i ] . o_type , 0 , options [ i ] . o_reply ) ; bp += n + 1 ; size -= n + 1 ; if ( size < 0 ) { tftp_log ( LOG_ERR , " " ) ; exit ( 1 ) ; } } } size = bp - buf ; if ( sendto ( peer , buf , size , 0 , ( struct sockaddr * ) & peer_sock , peer_sock . ss_len ) != size ) { tftp_log ( LOG_INFO , " " , strerror ( errno ) ) ; return ( 1 ) ; } return ( 0 ) ; }
Send an OACK packet (option acknowledgement).
Send an OACK packet ( option acknowledgement ) .
/*
	 * Send back an options acknowledgement (only the ones with
	 * a reply for)
	 */