Lines Matching defs:opt

44 void ip_options_build(struct sk_buff *skb, struct ip_options *opt,
49 memcpy(&(IPCB(skb)->opt), opt, sizeof(struct ip_options));
50 memcpy(iph + sizeof(struct iphdr), opt->__data, opt->optlen);
51 opt = &(IPCB(skb)->opt);
53 if (opt->srr)
54 memcpy(iph + opt->srr + iph[opt->srr + 1] - 4, &daddr, 4);
56 if (opt->rr_needaddr)
57 ip_rt_get_source(iph + opt->rr + iph[opt->rr + 2] - 5, skb, rt);
58 if (opt->ts_needaddr)
59 ip_rt_get_source(iph + opt->ts + iph[opt->ts + 2] - 9, skb, rt);
60 if (opt->ts_needtime) {
64 memcpy(iph + opt->ts + iph[opt->ts + 2] - 5, &midtime, 4);
198 struct ip_options *opt = &(IPCB(skb)->opt);
199 int l = opt->optlen;
219 opt->ts = 0;
220 opt->rr = 0;
221 opt->rr_needaddr = 0;
222 opt->ts_needaddr = 0;
223 opt->ts_needtime = 0;
237 * Caller should clear *opt, and set opt->data.
238 * If opt == NULL, then skb->data should point to IP header.
242 struct ip_options *opt, struct sk_buff *skb,
256 optptr = opt->__data;
259 for (l = opt->optlen; l > 0; ) {
265 opt->is_changed = 1;
295 if (opt->srr) {
304 memcpy(&opt->faddr, &optptr[3], 4);
308 opt->is_strictroute = (optptr[0] == IPOPT_SSRR);
309 opt->srr = optptr - iph;
312 if (opt->rr) {
332 opt->is_changed = 1;
335 opt->rr_needaddr = 1;
337 opt->rr = optptr - iph;
340 if (opt->ts) {
362 opt->ts_needtime = 1;
375 opt->ts_needaddr = 1;
376 opt->ts_needtime = 1;
392 opt->ts_needtime = 1;
407 opt->is_changed = 1;
417 opt->is_changed = 1;
420 opt->ts = optptr - iph;
428 opt->router_alert = optptr - iph;
431 if ((!skb && !ns_capable(net->user_ns, CAP_NET_RAW)) || opt->cipso) {
435 opt->cipso = optptr - iph;
466 struct ip_options *opt, struct sk_buff *skb)
471 ret = __ip_options_compile(net, opt, skb, &info);
482 void ip_options_undo(struct ip_options *opt)
484 if (opt->srr) {
485 unsigned char *optptr = opt->__data + opt->srr - sizeof(struct iphdr);
488 memcpy(optptr + 3, &opt->faddr, 4);
490 if (opt->rr_needaddr) {
491 unsigned char *optptr = opt->__data + opt->rr - sizeof(struct iphdr);
496 if (opt->ts) {
497 unsigned char *optptr = opt->__data + opt->ts - sizeof(struct iphdr);
499 if (opt->ts_needtime) {
505 if (opt->ts_needaddr) {
515 struct ip_options_rcu *opt;
517 opt = kzalloc(sizeof(struct ip_options_rcu) + ((optlen + 3) & ~3),
519 if (!opt)
521 if (optlen && copy_from_sockptr(opt->opt.__data, data, optlen)) {
522 kfree(opt);
527 opt->opt.__data[optlen++] = IPOPT_END;
528 opt->opt.optlen = optlen;
529 if (optlen && ip_options_compile(net, &opt->opt, NULL)) {
530 kfree(opt);
534 *optp = opt;
540 struct ip_options *opt = &(IPCB(skb)->opt);
545 if (opt->rr_needaddr) {
546 optptr = (unsigned char *)raw + opt->rr;
548 opt->is_changed = 1;
550 if (opt->srr_is_hit) {
553 optptr = raw + opt->srr;
561 if (memcmp(&opt->nexthop, &optptr[srrptr-1], 4) == 0)
565 opt->is_changed = 1;
566 ip_hdr(skb)->daddr = opt->nexthop;
573 if (opt->ts_needaddr) {
574 optptr = raw + opt->ts;
576 opt->is_changed = 1;
579 if (opt->is_changed) {
580 opt->is_changed = 0;
587 struct ip_options *opt = &(IPCB(skb)->opt);
591 unsigned char *optptr = skb_network_header(skb) + opt->srr;
603 if (!opt->is_strictroute)
613 icmp_send(skb, ICMP_PARAMETERPROB, 0, htonl((opt->srr+2)<<24));
632 opt->is_changed = 1;
635 opt->srr_is_hit = 1;
636 opt->nexthop = nexthop;
637 opt->is_changed = 1;