1 /*
   2  * This file and its contents are supplied under the terms of the
   3  * Common Development and Distribution License ("CDDL"), version 1.0.
   4  * You may only use this file in accordance with the terms of version
   5  * 1.0 of the CDDL.
   6  *
   7  * A full copy of the text of the CDDL should have accompanied this
   8  * source.  A copy of the CDDL is also available via the Internet at
   9  * http://www.illumos.org/license/CDDL.
  10  */
  11 
  12 /*
  13  * Copyright 2012 David Hoeppner. All rights reserved.
  14  */
  15 
  16 #include <sys/types.h> 
  17 #include <sys/stream.h> 
  18 #include <sys/debug.h> 
  19 #include <sys/cmn_err.h>
  20 #include <inet/dccp_impl.h>
  21 #include <inet/dccp_stack.h>
  22 
  23 /*
  24  * This file contains functions to parse and process DCCP features.
  25  */
  26 
  27 /*
  28  * Feature handling.
  29  */
  30 int
  31 dccp_parse_feature(dccp_t *dccp, uint8_t option, uint8_t length, uchar_t *up,
  32     boolean_t mandatory)
  33 {
  34         dccp_feature_t  *feature;
  35         uint64_t        feature_value;
  36         uint8_t         feature_type;
  37         uint8_t         feature_length = length - 1;
  38 
  39         cmn_err(CE_NOTE, "dccp_features.c: dccp_parse_feature");
  40 
  41         feature_type = *up;
  42         up++;
  43 
  44         switch (feature_type) {
  45         case DCCP_FEATURE_CCID:
  46                 cmn_err(CE_NOTE, "DCCP_FEATURE_CCID");
  47                 break;
  48         case DCCP_FEATURE_ALLOW_SHORT_SEQNOS:
  49                 cmn_err(CE_NOTE, "DCCP_FEATURE_ALLOW_SHORT_SEQNOS");
  50                 break;
  51         case DCCP_FEATURE_SEQUENCE_WINDOW:
  52                 cmn_err(CE_NOTE, "DCCP_FEATURE_SEQUENCE_WINDOW");
  53                 if (feature_length != 6)
  54                         return (DCCP_RESET_MANDATORY_ERROR);
  55 
  56                 feature_value = (uint64_t)up[0] << 40;
  57                 feature_value += ((uint64_t)up[1] << 32);
  58                 feature_value += ((uint64_t)up[2] << 24);
  59                 feature_value += ((uint64_t)up[3] << 16);
  60                 feature_value += ((uint64_t)up[4] << 8);
  61                 feature_value += (uint64_t)up[5];
  62 
  63                 if (feature_value < 32 || feature_value > 70368744177663)
  64                         return (DCCP_RESET_MANDATORY_ERROR);
  65                 dccp->dccp_sequence_window = feature_value;
  66                 break;
  67         case DCCP_FEATURE_ECN_INCAPABLE:
  68                 cmn_err(CE_NOTE, "DCCP_FEATURE_ECN_INCAPABLE");
  69                 break;
  70         case DCCP_FEATURE_ACK_RATIO:
  71                 cmn_err(CE_NOTE, "DCCP_FEATURE_ACK_RATIO");
  72                 break;
  73         case DCCP_FEATURE_SEND_ACK_VECTOR:
  74                 cmn_err(CE_NOTE, "DCCP_FEATURE_SEND_ACK_VECTOR");
  75                 break;
  76         case DCCP_FEATURE_SEND_NDP_COUNT:
  77                 cmn_err(CE_NOTE, "DCCP_FEATURE_SEND_NDP_COUNT");
  78                 break;
  79         case DCCP_FEATURE_MIN_CHECKSUM_COVERAGE:
  80                 cmn_err(CE_NOTE, "DCCP_FEATURE_MIN_CHECKSUM_COVERAGE");
  81                 break;
  82         case DCCP_FEATURE_CHECK_DATA_CHECKSUM:
  83                 cmn_err(CE_NOTE, "DCCP_FEATURE_CHECK_DATA_CHECKSUM");
  84                 break;
  85         default:
  86                 cmn_err(CE_NOTE, "ERROR DEFAULT");
  87                 break;
  88         }
  89 
  90         cmn_err(CE_NOTE, "feature len: %d", feature_length);
  91 
  92         feature = (dccp_feature_t *)kmem_alloc(sizeof (dccp_feature_t),
  93             KM_SLEEP);
  94         if (feature == NULL) {
  95                 return (0);
  96         }
  97 
  98         feature->df_option = option;
  99         feature->df_type = feature_type;
 100         feature->df_mandatory = mandatory;
 101 
 102         list_insert_tail(&dccp->dccp_features, feature);
 103 
 104         return (0);
 105 }
 106 
 107 void
 108 dccp_features_init(void)
 109 {
 110 }
 111 
 112 void
 113 dccp_features_destroy(void)
 114 {
 115 }