err = datagram_send_ctl(msg, &fl, opt, &hlimit); 
err = datagram_send_ctl(msg, &fl, opt, &hlimit, &tclass); 
static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,		   struct msghdr *msg, size_t len){	struct ipv6_txoptions opt_space;	struct sockaddr_in6 * sin6 = (struct sockaddr_in6 *) msg->msg_name;	struct in6_addr *daddr, *final_p = NULL, final;	struct inet_sock *inet = inet_sk(sk);	struct ipv6_pinfo *np = inet6_sk(sk);	struct raw6_sock *rp = raw6_sk(sk);	struct ipv6_txoptions *opt = NULL;	struct ip6_flowlabel *flowlabel = NULL;	struct dst_entry *dst = NULL;	struct flowi fl;	int addr_len = msg->msg_namelen;	int hlimit = -1;	u16 proto;	int err;	/* Rough check on arithmetic overflow,	   better check is made in ip6_build_xmit	 */	if (len < 0)		return -EMSGSIZE;	/* Mirror BSD error message compatibility */	if (msg->msg_flags & MSG_OOB)				return -EOPNOTSUPP;	/*	 *	Get and verify the address. 	 */	memset(&fl, 0, sizeof(fl));	if (sin6) {		if (addr_len < SIN6_LEN_RFC2133) 			return -EINVAL;		if (sin6->sin6_family && sin6->sin6_family != AF_INET6) 			return(-EAFNOSUPPORT);		/* port is the proto value [0..255] carried in nexthdr */		proto = ntohs(sin6->sin6_port);		if (!proto)			proto = inet->num;		else if (proto != inet->num)			return(-EINVAL);		if (proto > 255)			return(-EINVAL);		daddr = &sin6->sin6_addr;		if (np->sndflow) {			fl.fl6_flowlabel = sin6->sin6_flowinfo&IPV6_FLOWINFO_MASK;			if (fl.fl6_flowlabel&IPV6_FLOWLABEL_MASK) {				flowlabel = fl6_sock_lookup(sk, fl.fl6_flowlabel);				if (flowlabel == NULL)					return -EINVAL;				daddr = &flowlabel->dst;			}		}		/*		 * Otherwise it will be difficult to maintain		 * sk->sk_dst_cache.		 */		if (sk->sk_state == TCP_ESTABLISHED &&		    ipv6_addr_equal(daddr, &np->daddr))			daddr = &np->daddr;		if (addr_len >= sizeof(struct sockaddr_in6) &&		    sin6->sin6_scope_id &&		    ipv6_addr_type(daddr)&IPV6_ADDR_LINKLOCAL)			fl.oif = sin6->sin6_scope_id;	} else {		if (sk->sk_state != TCP_ESTABLISHED) 			return -EDESTADDRREQ;				proto = inet->num;		daddr = &np->daddr;		fl.fl6_flowlabel = np->flow_label;	}	if (ipv6_addr_any(daddr)) {		/* 		 * unspecified destination address 		 * treated as error... is this correct ?		 */		fl6_sock_release(flowlabel);		return(-EINVAL);	}	if (fl.oif == 0)		fl.oif = sk->sk_bound_dev_if;	if (msg->msg_controllen) {		opt = &opt_space;		memset(opt, 0, sizeof(struct ipv6_txoptions));		opt->tot_len = sizeof(struct ipv6_txoptions);		err = datagram_send_ctl(msg, &fl, opt, &hlimit);		if (err < 0) {			fl6_sock_release(flowlabel);			return err;		}		if ((fl.fl6_flowlabel&IPV6_FLOWLABEL_MASK) && !flowlabel) {			flowlabel = fl6_sock_lookup(sk, fl.fl6_flowlabel);			if (flowlabel == NULL)				return -EINVAL;		}		if (!(opt->opt_nflen|opt->opt_flen))			opt = NULL;	}	if (opt == NULL)		opt = np->opt;	opt = fl6_merge_options(&opt_space, flowlabel, opt);	fl.proto = proto;	rawv6_probe_proto_opt(&fl, msg); 	ipv6_addr_copy(&fl.fl6_dst, daddr);	if (ipv6_addr_any(&fl.fl6_src) && !ipv6_addr_any(&np->saddr))		ipv6_addr_copy(&fl.fl6_src, &np->saddr);	/* merge ip6_build_xmit from ip6_output */	if (opt && opt->srcrt) {		struct rt0_hdr *rt0 = (struct rt0_hdr *) opt->srcrt;		ipv6_addr_copy(&final, &fl.fl6_dst);		ipv6_addr_copy(&fl.fl6_dst, rt0->addr);		final_p = &final;	}	if (!fl.oif && ipv6_addr_is_multicast(&fl.fl6_dst))		fl.oif = np->mcast_oif;	err = ip6_dst_lookup(sk, &dst, &fl);	if (err)		goto out;	if (final_p)		ipv6_addr_copy(&fl.fl6_dst, final_p);	if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) {		dst_release(dst);		goto out;	}	if (hlimit < 0) {		if (ipv6_addr_is_multicast(&fl.fl6_dst))			hlimit = np->mcast_hops;		else			hlimit = np->hop_limit;		if (hlimit < 0)			hlimit = dst_metric(dst, RTAX_HOPLIMIT);		if (hlimit < 0)			hlimit = ipv6_get_hoplimit(dst->dev);	}	if (msg->msg_flags&MSG_CONFIRM)		goto do_confirm;back_from_confirm:	if (inet->hdrincl) {		err = rawv6_send_hdrinc(sk, msg->msg_iov, len, &fl, (struct rt6_info*)dst, msg->msg_flags);	} else {		lock_sock(sk);		err = ip6_append_data(sk, ip_generic_getfrag, msg->msg_iov, len, 0,					hlimit, opt, &fl, (struct rt6_info*)dst, msg->msg_flags);		if (err)			ip6_flush_pending_frames(sk);		else if (!(msg->msg_flags & MSG_MORE))			err = rawv6_push_pending_frames(sk, &fl, rp);	}done:	ip6_dst_store(sk, dst,		      ipv6_addr_equal(&fl.fl6_dst, &np->daddr) ?		      &np->daddr : NULL);	release_sock(sk);out:		fl6_sock_release(flowlabel);	return err<0?err:len;do_confirm:	dst_confirm(dst);	if (!(msg->msg_flags & MSG_PROBE) || len)		goto back_from_confirm;	err = 0;	goto done;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/41a1f8ea4fbfcdc4232f023732584aae2220de31/raw.c/clean/net/ipv6/raw.c