udp.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 1991-2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
* udp.c, Code implementing the UDP internet protocol.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <socket_impl.h>
#include <socket_inet.h>
#include <netinet/in_systm.h>
#include "udp_inet.h"
#include "ipv4.h"
#include "ipv4_impl.h"
#include "mac.h"
#include "mac_impl.h"
#include "v4_sum_impl.h"
#include <sys/bootdebug.h>
/* Checksum all architectures */
/*
* Initialize the udp-specific parts of a socket.
*/
void
{
}
/*
* Return the size of an UDP header
*/
/* ARGSUSED */
int
{
return (sizeof (struct udphdr));
}
/*
* Return the requested port number in network order.
*/
{
}
/*
* Process the IPv4 datagram that IPv4 has given us. We:
*
* 1) Checksum the datagram if checksum is turned on.
* 2) Strip the udp header from the inetgram.
* 3) Return the number of TRANSPORT frames for success, -1 if a
* failure occurred.
*
* Arguments: index: index into the open socket table, ip is the inetgram
* we got from IPv4, which will contain the udp header and all the data.
*/
int
{
int frames = 0, header_len;
#ifdef DEBUG
#endif
#ifdef DEBUG
printf("udp_input(%d): level %d datagram discarded.\n",
#endif /* DEBUG */
continue;
}
/* generate checksum */
dprintf("udp_input(%d): bad udp chksum "
"from %s.\n", index,
continue;
}
}
/* validate port number */
dprintf("udp_input(%d): Unexpected port number: "
"%d != %d from %s.\n", index,
continue;
}
frames++;
}
return (frames);
}
/*
* Create a UDP datagram given the data and sockaddr_in we got from sendto().
* We will calculate the checksum if checksumming is turned on, and fill in
* appropriate length and port fields. We convert the inetgram from a
* block of data into a udp datagram... Returns the number of bytes contained
* in the udp datagram (including header).
*
* Arguments: index: index into the open socket table, ogp is the inetgram
* we got from sendto(), which will contain just the data and sockaddr_in.
*/
int
{
#ifdef DEBUG
#endif /* DEBUG */
else
if (udp_cksum_flag) {
}
return (0);
}