kernels/linux-2.4.0/drivers/net/wan/sdla_fr.c
/*============================================================================
 * Reply to UDP Management system.
 * Return nothing.
 */
Reply to UDP Management system.
Return nothing.
Reply to UDP Management system . Return nothing .
static int reply_udp( unsigned char *data, unsigned int mbox_len ) 
{
	unsigned short len, udp_length, temp, ip_length;
	unsigned long ip_temp;
	int even_bound = 0;
	fr_udp_pkt_t *fr_udp_pkt = (fr_udp_pkt_t *)data; 
	len = sizeof(fr_encap_hdr_t)+
	      sizeof(ip_pkt_t)+ 
	      sizeof(udp_pkt_t)+
	      sizeof(wp_mgmt_t)+
	      sizeof(cblock_t)+
	      mbox_len;
	fr_udp_pkt->wp_mgmt.request_reply = UDPMGMT_REPLY;
	udp_length = sizeof(udp_pkt_t)+ 
		     sizeof(wp_mgmt_t)+
		     sizeof(cblock_t)+
		     mbox_len; 
	if ( udp_length & 0x0001 ) {
		udp_length += 1;
		len += 1;
		even_bound = 1;
	}
	temp = (udp_length<<8)|(udp_length>>8);
	fr_udp_pkt->udp_pkt.udp_length = temp;
	temp = fr_udp_pkt->udp_pkt.udp_src_port;
	fr_udp_pkt->udp_pkt.udp_src_port = 
			fr_udp_pkt->udp_pkt.udp_dst_port; 
	fr_udp_pkt->udp_pkt.udp_dst_port = temp;
	temp = 0x1100;
	*((unsigned short *)
		(fr_udp_pkt->data+mbox_len+even_bound)) = temp;	
	temp = (udp_length<<8)|(udp_length>>8);
	*((unsigned short *)
		(fr_udp_pkt->data+mbox_len+even_bound+2)) = temp;
	fr_udp_pkt->udp_pkt.udp_checksum = 0;
	fr_udp_pkt->udp_pkt.udp_checksum = 
		calc_checksum(&data[UDP_OFFSET+sizeof(fr_encap_hdr_t)],
			      udp_length+UDP_OFFSET);
	ip_length = udp_length + sizeof(ip_pkt_t);
	temp = (ip_length<<8)|(ip_length>>8);
	fr_udp_pkt->ip_pkt.total_length = temp;
	ip_temp = fr_udp_pkt->ip_pkt.ip_src_address;
	fr_udp_pkt->ip_pkt.ip_src_address = 
				fr_udp_pkt->ip_pkt.ip_dst_address;
	fr_udp_pkt->ip_pkt.ip_dst_address = ip_temp;
	fr_udp_pkt->ip_pkt.hdr_checksum = 0;
	fr_udp_pkt->ip_pkt.hdr_checksum = 
		calc_checksum(&data[sizeof(fr_encap_hdr_t)],
		      	      sizeof(ip_pkt_t));
	return len;
}
static int reply_udp ( unsigned char * data , unsigned int mbox_len ) { unsigned short len , udp_length , temp , ip_length ; unsigned long ip_temp ; int even_bound = 0 ; fr_udp_pkt_t * fr_udp_pkt = ( fr_udp_pkt_t * ) data ; len = sizeof ( fr_encap_hdr_t ) + sizeof ( ip_pkt_t ) + sizeof ( udp_pkt_t ) + sizeof ( wp_mgmt_t ) + sizeof ( cblock_t ) + mbox_len ; fr_udp_pkt -> wp_mgmt . request_reply = UDPMGMT_REPLY ; udp_length = sizeof ( udp_pkt_t ) + sizeof ( wp_mgmt_t ) + sizeof ( cblock_t ) + mbox_len ; if ( udp_length & 0x0001 ) { udp_length += 1 ; len += 1 ; even_bound = 1 ; } temp = ( udp_length << 8 ) | ( udp_length >> 8 ) ; fr_udp_pkt -> udp_pkt . udp_length = temp ; temp = fr_udp_pkt -> udp_pkt . udp_src_port ; fr_udp_pkt -> udp_pkt . udp_src_port = fr_udp_pkt -> udp_pkt . udp_dst_port ; fr_udp_pkt -> udp_pkt . udp_dst_port = temp ; temp = 0x1100 ; * ( ( unsigned short * ) ( fr_udp_pkt -> data + mbox_len + even_bound ) ) = temp ; temp = ( udp_length << 8 ) | ( udp_length >> 8 ) ; * ( ( unsigned short * ) ( fr_udp_pkt -> data + mbox_len + even_bound + 2 ) ) = temp ; fr_udp_pkt -> udp_pkt . udp_checksum = 0 ; fr_udp_pkt -> udp_pkt . udp_checksum = calc_checksum ( & data [ UDP_OFFSET + sizeof ( fr_encap_hdr_t ) ] , udp_length + UDP_OFFSET ) ; ip_length = udp_length + sizeof ( ip_pkt_t ) ; temp = ( ip_length << 8 ) | ( ip_length >> 8 ) ; fr_udp_pkt -> ip_pkt . total_length = temp ; ip_temp = fr_udp_pkt -> ip_pkt . ip_src_address ; fr_udp_pkt -> ip_pkt . ip_src_address = fr_udp_pkt -> ip_pkt . ip_dst_address ; fr_udp_pkt -> ip_pkt . ip_dst_address = ip_temp ; fr_udp_pkt -> ip_pkt . hdr_checksum = 0 ; fr_udp_pkt -> ip_pkt . hdr_checksum = calc_checksum ( & data [ sizeof ( fr_encap_hdr_t ) ] , sizeof ( ip_pkt_t ) ) ; return len ; }
Reply to UDP Management system.
Reply to UDP Management system .
/* Set length of packet */ /* fill in UDP reply */ /* fill in UDP length */ /* put it on an even boundary */ /* swap UDP ports */ /* add UDP pseudo header */ /* calculate UDP checksum */ /* fill in IP length */ /* swap IP addresses */ /* fill in IP checksum */