2 * Copyright (c) 2017 SUSE LLC.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
15 #include <vnet/sctp/sctp.h>
16 #include <vnet/sctp/sctp_debug.h>
18 sctp_main_t sctp_main;
21 sctp_connection_bind (u32 session_index, transport_endpoint_t * tep)
23 sctp_main_t *tm = &sctp_main;
24 sctp_connection_t *listener;
27 pool_get (tm->listener_pool, listener);
28 memset (listener, 0, sizeof (*listener));
30 listener->sub_conn[MAIN_SCTP_SUB_CONN_IDX].parent = listener;
31 listener->sub_conn[MAIN_SCTP_SUB_CONN_IDX].c_c_index =
32 listener - tm->listener_pool;
33 listener->sub_conn[MAIN_SCTP_SUB_CONN_IDX].connection.lcl_port = tep->port;
35 /* If we are provided a sw_if_index, bind using one of its IPs */
36 if (ip_is_zero (&tep->ip, 1) && tep->sw_if_index != ENDPOINT_INVALID_INDEX)
38 if ((iface_ip = ip_interface_get_first_ip (tep->sw_if_index,
40 ip_set (&tep->ip, iface_ip, tep->is_ip4);
42 ip_copy (&listener->sub_conn[MAIN_SCTP_SUB_CONN_IDX].connection.lcl_ip,
43 &tep->ip, tep->is_ip4);
45 listener->sub_conn[MAIN_SCTP_SUB_CONN_IDX].connection.is_ip4 = tep->is_ip4;
46 listener->sub_conn[MAIN_SCTP_SUB_CONN_IDX].connection.proto =
48 listener->sub_conn[MAIN_SCTP_SUB_CONN_IDX].c_s_index = session_index;
49 listener->sub_conn[MAIN_SCTP_SUB_CONN_IDX].connection.fib_index =
51 listener->state = SCTP_STATE_CLOSED;
53 sctp_connection_timers_init (listener);
55 return listener->sub_conn[MAIN_SCTP_SUB_CONN_IDX].c_c_index;
59 sctp_session_bind (u32 session_index, transport_endpoint_t * tep)
61 return sctp_connection_bind (session_index, tep);
65 sctp_connection_unbind (u32 listener_index)
67 sctp_main_t *tm = vnet_get_sctp_main ();
68 sctp_connection_t *tc;
70 tc = pool_elt_at_index (tm->listener_pool, listener_index);
72 /* Poison the entry */
74 memset (tc, 0xFA, sizeof (*tc));
76 pool_put_index (tm->listener_pool, listener_index);
80 sctp_session_unbind (u32 listener_index)
82 sctp_connection_unbind (listener_index);
87 sctp_punt_unknown (vlib_main_t * vm, u8 is_ip4, u8 is_add)
89 sctp_main_t *tm = &sctp_main;
91 tm->punt_unknown4 = is_add;
93 tm->punt_unknown6 = is_add;
97 sctp_alloc_custom_local_endpoint (sctp_main_t * tm, ip46_address_t * lcl_addr,
98 u16 * lcl_port, u8 is_ip4)
103 index = tm->last_v4_address_rotor++;
104 if (tm->last_v4_address_rotor >= vec_len (tm->ip4_src_addresses))
105 tm->last_v4_address_rotor = 0;
106 lcl_addr->ip4.as_u32 = tm->ip4_src_addresses[index].as_u32;
110 index = tm->last_v6_address_rotor++;
111 if (tm->last_v6_address_rotor >= vec_len (tm->ip6_src_addresses))
112 tm->last_v6_address_rotor = 0;
113 clib_memcpy (&lcl_addr->ip6, &tm->ip6_src_addresses[index],
114 sizeof (ip6_address_t));
116 port = transport_alloc_local_port (TRANSPORT_PROTO_SCTP, lcl_addr);
119 clib_warning ("Failed to allocate src port");
127 * Initialize all connection timers as invalid
130 sctp_connection_timers_init (sctp_connection_t * tc)
134 /* Set all to invalid */
135 for (i = 0; i < MAX_SCTP_CONNECTIONS; i++)
136 for (j = 0; j < SCTP_N_TIMERS; j++)
138 tc->sub_conn[i].timers[j] = SCTP_TIMER_HANDLE_INVALID;
141 tc->rto = SCTP_RTO_INIT;
145 * Stop all connection timers
148 sctp_connection_timers_reset (sctp_connection_t * tc)
151 for (i = 0; i < MAX_SCTP_CONNECTIONS; i++)
153 for (j = 0; j < SCTP_N_TIMERS; j++)
154 sctp_timer_reset (tc, i, j);
158 const char *sctp_fsm_states[] = {
159 #define _(sym, str) str,
160 foreach_sctp_fsm_state
165 format_sctp_state (u8 * s, va_list * args)
167 u32 state = va_arg (*args, u32);
169 if (state < SCTP_N_STATES)
170 s = format (s, "%s", sctp_fsm_states[state]);
172 s = format (s, "UNKNOWN (%d (0x%x))", state, state);
177 format_sctp_connection_id (u8 * s, va_list * args)
180 sctp_connection_t *tc = va_arg (*args, sctp_connection_t *);
185 s = format (s, "[#%d][%s] %U:%d->%U:%d", tc->c_thread_index, "T",
186 format_ip4_address, &tc->c_lcl_ip4,
187 clib_net_to_host_u16 (tc->c_lcl_port), format_ip4_address,
188 &tc->c_rmt_ip4, clib_net_to_host_u16 (tc->c_rmt_port));
192 s = format (s, "[#%d][%s] %U:%d->%U:%d", tc->c_thread_index, "T",
193 format_ip6_address, &tc->c_lcl_ip6,
194 clib_net_to_host_u16 (tc->c_lcl_port), format_ip6_address,
195 &tc->c_rmt_ip6, clib_net_to_host_u16 (tc->c_rmt_port));
202 format_sctp_connection (u8 * s, va_list * args)
204 sctp_connection_t *tc = va_arg (*args, sctp_connection_t *);
205 u32 verbose = va_arg (*args, u32);
209 s = format (s, "%-50U", format_sctp_connection_id, tc);
212 s = format (s, "%-15U", format_sctp_state, tc->state);
219 * Initialize connection send variables.
222 sctp_init_snd_vars (sctp_connection_t * tc)
227 * We use the time to randomize iss and for setting up the initial
228 * timestamp. Make sure it's updated otherwise syn and ack in the
229 * handshake may make it look as if time has flown in the opposite
232 sctp_set_time_now (vlib_get_thread_index ());
233 time_now = sctp_time_now ();
235 tc->iss = random_u32 (&time_now);
236 tc->snd_una = tc->iss;
237 tc->snd_nxt = tc->iss + 1;
238 tc->snd_una_max = tc->snd_nxt;
242 * Update max segment size we're able to process.
244 * The value is constrained by our interface's MTU and IP options. It is
245 * also what we advertise to our peer.
248 sctp_update_rcv_mss (sctp_connection_t * tc)
250 /* TODO find our iface MTU */
251 tc->a_rwnd = DEFAULT_A_RWND - sizeof (sctp_full_hdr_t);
252 tc->rcv_opts.a_rwnd = tc->a_rwnd;
253 tc->rcv_a_rwnd = tc->a_rwnd; /* This will be updated by our congestion algos */
257 sctp_init_mss (sctp_connection_t * tc)
259 SCTP_DBG ("CONN_INDEX = %u",
260 tc->sub_conn[MAIN_SCTP_SUB_CONN_IDX].connection.c_index);
262 u16 default_a_rwnd = 536;
263 sctp_update_rcv_mss (tc);
265 /* TODO cache mss and consider PMTU discovery */
266 tc->snd_a_rwnd = clib_min (tc->rcv_opts.a_rwnd, tc->a_rwnd);
268 if (tc->snd_a_rwnd < sizeof (sctp_full_hdr_t))
270 SCTP_ADV_DBG ("tc->snd_a_rwnd < sizeof(sctp_full_hdr_t)");
271 /* Assume that at least the min default mss works */
272 tc->snd_a_rwnd = default_a_rwnd;
273 tc->rcv_opts.a_rwnd = default_a_rwnd;
276 ASSERT (tc->snd_a_rwnd > sizeof (sctp_full_hdr_t));
279 /** Initialize sctp connection variables
281 * Should be called after having received a msg from the peer, i.e., a SYN or
282 * a SYNACK, such that connection options have already been exchanged. */
284 sctp_connection_init_vars (sctp_connection_t * tc)
287 sctp_init_snd_vars (tc);
290 always_inline sctp_connection_t *
291 sctp_sub_connection_add (u8 thread_index)
293 sctp_main_t *tm = vnet_get_sctp_main ();
294 sctp_connection_t *tc = tm->connections[thread_index];
296 tc->sub_conn[tc->next_avail_sub_conn].connection.c_index =
297 tc->sub_conn[MAIN_SCTP_SUB_CONN_IDX].connection.c_index;
298 tc->sub_conn[tc->next_avail_sub_conn].connection.thread_index =
300 tc->sub_conn[tc->next_avail_sub_conn].parent = tc;
302 tc->next_avail_sub_conn += 1;
308 sctp_sub_connection_add_ip4 (u8 thread_index,
309 sctp_ipv4_addr_param_t * ipv4_addr)
311 sctp_connection_t *tc = sctp_sub_connection_add (thread_index);
313 clib_memcpy (&tc->sub_conn[tc->next_avail_sub_conn].connection.lcl_ip.ip4,
314 &ipv4_addr->address, sizeof (ipv4_addr->address));
318 sctp_sub_connection_add_ip6 (u8 thread_index,
319 sctp_ipv6_addr_param_t * ipv6_addr)
321 sctp_connection_t *tc = sctp_sub_connection_add (thread_index);
323 clib_memcpy (&tc->sub_conn[tc->next_avail_sub_conn].connection.lcl_ip.ip6,
324 &ipv6_addr->address, sizeof (ipv6_addr->address));
328 sctp_connection_new (u8 thread_index)
330 sctp_main_t *tm = vnet_get_sctp_main ();
331 sctp_connection_t *tc;
333 pool_get (tm->connections[thread_index], tc);
334 memset (tc, 0, sizeof (*tc));
335 tc->sub_conn[MAIN_SCTP_SUB_CONN_IDX].parent = tc;
336 tc->sub_conn[MAIN_SCTP_SUB_CONN_IDX].c_c_index =
337 tc - tm->connections[thread_index];
338 tc->sub_conn[MAIN_SCTP_SUB_CONN_IDX].c_thread_index = thread_index;
340 tc->next_avail_sub_conn = 1;
346 sctp_half_open_connection_new (u8 thread_index)
348 sctp_main_t *tm = vnet_get_sctp_main ();
349 sctp_connection_t *tc = 0;
350 ASSERT (vlib_get_thread_index () == 0);
351 pool_get (tm->half_open_connections, tc);
352 memset (tc, 0, sizeof (*tc));
353 tc->sub_conn[MAIN_SCTP_SUB_CONN_IDX].c_c_index =
354 tc - tm->half_open_connections;
355 tc->sub_conn[MAIN_SCTP_SUB_CONN_IDX].parent = tc;
360 sctp_connection_open (transport_endpoint_t * rmt)
362 sctp_main_t *tm = vnet_get_sctp_main ();
363 sctp_connection_t *tc;
364 ip46_address_t lcl_addr;
369 u8 idx = sctp_pick_conn_idx_on_state (SCTP_STATE_CLOSED);
372 * Allocate local endpoint
374 if ((rmt->is_ip4 && vec_len (tm->ip4_src_addresses))
375 || (!rmt->is_ip4 && vec_len (tm->ip6_src_addresses)))
376 rv = sctp_alloc_custom_local_endpoint (tm, &lcl_addr, &lcl_port,
379 rv = transport_alloc_local_endpoint (TRANSPORT_PROTO_SCTP,
380 rmt, &lcl_addr, &lcl_port);
386 * Create connection and send INIT CHUNK
388 thread_id = vlib_get_thread_index ();
389 ASSERT (thread_id == 0);
391 clib_spinlock_lock_if_init (&tm->half_open_lock);
392 tc = sctp_half_open_connection_new (thread_id);
394 transport_connection_t *t_conn = &tc->sub_conn[idx].connection;
395 ip_copy (&t_conn->rmt_ip, &rmt->ip, rmt->is_ip4);
396 ip_copy (&t_conn->lcl_ip, &lcl_addr, rmt->is_ip4);
397 tc->sub_conn[idx].parent = tc;
398 t_conn->rmt_port = rmt->port;
399 t_conn->lcl_port = clib_host_to_net_u16 (lcl_port);
400 t_conn->is_ip4 = rmt->is_ip4;
401 t_conn->proto = TRANSPORT_PROTO_SCTP;
402 t_conn->fib_index = rmt->fib_index;
404 sctp_connection_timers_init (tc);
405 /* The other connection vars will be initialized after INIT_ACK chunk received */
406 sctp_init_snd_vars (tc);
410 clib_spinlock_unlock_if_init (&tm->half_open_lock);
412 return tc->sub_conn[idx].connection.c_index;
416 * Cleans up connection state.
421 sctp_connection_cleanup (sctp_connection_t * tc)
423 sctp_main_t *tm = &sctp_main;
426 /* Cleanup local endpoint if this was an active connect */
427 for (i = 0; i < MAX_SCTP_CONNECTIONS; i++)
428 transport_endpoint_cleanup (TRANSPORT_PROTO_SCTP,
429 &tc->sub_conn[i].connection.lcl_ip,
430 tc->sub_conn[i].connection.lcl_port);
432 /* Check if connection is not yet fully established */
433 if (tc->state == SCTP_STATE_COOKIE_WAIT)
440 tc->sub_conn[MAIN_SCTP_SUB_CONN_IDX].connection.thread_index;
442 /* Make sure all timers are cleared */
443 sctp_connection_timers_reset (tc);
445 /* Poison the entry */
447 memset (tc, 0xFA, sizeof (*tc));
448 pool_put (tm->connections[thread_index], tc);
453 sctp_session_open (transport_endpoint_t * tep)
455 return sctp_connection_open (tep);
459 sctp_check_outstanding_data_chunks (sctp_connection_t * tc)
461 return 0; /* Indicates no more data to be read/sent */
465 sctp_connection_close (sctp_connection_t * tc)
467 SCTP_DBG ("Closing connection %u...",
468 tc->sub_conn[MAIN_SCTP_SUB_CONN_IDX].connection.c_index);
470 tc->state = SCTP_STATE_SHUTDOWN_PENDING;
472 sctp_send_shutdown (tc);
476 sctp_session_close (u32 conn_index, u32 thread_index)
478 ASSERT (thread_index == 0);
480 sctp_connection_t *tc;
481 tc = sctp_connection_get (conn_index, thread_index);
482 sctp_connection_close (tc);
486 sctp_session_cleanup (u32 conn_index, u32 thread_index)
488 sctp_connection_t *tc;
489 tc = sctp_connection_get (conn_index, thread_index);
490 sctp_connection_timers_reset (tc);
492 /* Wait for the session tx events to clear */
493 tc->state = SCTP_STATE_CLOSED;
497 * Update snd_mss to reflect the effective segment size that we can send
500 sctp_update_snd_mss (sctp_connection_t * tc)
502 /* The overhead for the sctp_header_t and sctp_chunks_common_hdr_t
503 * (the sum equals to sctp_full_hdr_t) is already taken into account
504 * for the tc->a_rwnd computation.
505 * So let's not account it again here.
508 sizeof (sctp_payload_data_chunk_t) - sizeof (sctp_full_hdr_t);
510 clib_min (tc->a_rwnd, tc->rcv_opts.a_rwnd) - tc->snd_hdr_length;
512 SCTP_DBG ("tc->snd_a_rwnd = %u, tc->snd_hdr_length = %u ",
513 tc->snd_a_rwnd, tc->snd_hdr_length);
515 ASSERT (tc->snd_a_rwnd > 0);
519 sctp_session_send_mss (transport_connection_t * trans_conn)
521 SCTP_DBG ("CONN_INDEX: %u", trans_conn->c_index);
523 sctp_connection_t *tc = sctp_get_connection_from_transport (trans_conn);
525 if (trans_conn == NULL)
527 SCTP_DBG ("trans_conn == NULL");
533 SCTP_DBG ("tc == NULL");
536 /* Ensure snd_mss does accurately reflect the amount of data we can push
537 * in a segment. This also makes sure that options are updated according to
538 * the current state of the connection. */
539 sctp_update_snd_mss (tc);
541 return tc->snd_a_rwnd;
545 sctp_snd_space (sctp_connection_t * sctp_conn)
547 /* TODO: This requires a real implementation */
548 if (sctp_conn == NULL)
550 SCTP_DBG ("sctp_conn == NULL");
554 if (sctp_conn->state != SCTP_STATE_ESTABLISHED)
556 SCTP_DBG_STATE_MACHINE
557 ("Trying to send DATA while not in SCTP_STATE_ESTABLISHED");
561 return sctp_conn->snd_a_rwnd;
565 sctp_session_send_space (transport_connection_t * trans_conn)
567 SCTP_DBG ("CONN_INDEX: %u", trans_conn->c_index);
569 sctp_connection_t *tc = sctp_get_connection_from_transport (trans_conn);
571 return sctp_snd_space (tc);
575 sctp_session_tx_fifo_offset (transport_connection_t * trans_conn)
577 SCTP_DBG ("CONN_INDEX: %u", trans_conn->c_index);
579 sctp_connection_t *tc = sctp_get_connection_from_transport (trans_conn);
583 SCTP_DBG ("tc == NULL");
587 /* This still works if fast retransmit is on */
588 return (tc->snd_nxt - tc->snd_una);
591 transport_connection_t *
592 sctp_session_get_transport (u32 conn_index, u32 thread_index)
594 sctp_connection_t *tc = sctp_connection_get (conn_index, thread_index);
595 return &tc->sub_conn[MAIN_SCTP_SUB_CONN_IDX].connection;
598 transport_connection_t *
599 sctp_session_get_listener (u32 listener_index)
601 sctp_main_t *tm = vnet_get_sctp_main ();
602 sctp_connection_t *tc;
603 tc = pool_elt_at_index (tm->listener_pool, listener_index);
604 return &tc->sub_conn[MAIN_SCTP_SUB_CONN_IDX].connection;
608 format_sctp_session (u8 * s, va_list * args)
614 format_sctp_listener_session (u8 * s, va_list * args)
620 sctp_timer_init_handler (u32 conn_index)
622 sctp_connection_t *tc;
624 tc = sctp_connection_get (conn_index, vlib_get_thread_index ());
625 /* note: the connection may have already disappeared */
626 if (PREDICT_FALSE (tc == 0))
628 ASSERT (tc->state == SCTP_STATE_COOKIE_ECHOED);
629 /* Start cleanup. App wasn't notified yet so use delete notify as
630 * opposed to delete to cleanup session layer state. */
631 stream_session_delete_notify (&tc->
632 sub_conn[MAIN_SCTP_SUB_CONN_IDX].connection);
633 tc->sub_conn[MAIN_SCTP_SUB_CONN_IDX].timers[SCTP_TIMER_T1_INIT] =
634 SCTP_TIMER_HANDLE_INVALID;
636 sctp_connection_cleanup (tc);
640 static timer_expiration_handler *sctp_timer_expiration_handlers[SCTP_N_TIMERS]
642 sctp_timer_init_handler
648 sctp_expired_timers_dispatch (u32 * expired_timers)
651 u32 connection_index, timer_id;
653 for (i = 0; i < vec_len (expired_timers); i++)
655 /* Get session index and timer id */
656 connection_index = expired_timers[i] & 0x0FFFFFFF;
657 timer_id = expired_timers[i] >> 28;
659 /* Handle expiration */
660 (*sctp_timer_expiration_handlers[timer_id]) (connection_index);
665 sctp_initialize_timer_wheels (sctp_main_t * tm)
667 tw_timer_wheel_16t_2w_512sl_t *tw;
669 foreach_vlib_main (({
670 tw = &tm->timer_wheels[ii];
671 tw_timer_wheel_init_16t_2w_512sl (tw, sctp_expired_timers_dispatch,
672 100e-3 /* timer period 100ms */ , ~0);
673 tw->last_run_time = vlib_time_now (this_vlib_main);
679 sctp_main_enable (vlib_main_t * vm)
681 sctp_main_t *tm = vnet_get_sctp_main ();
682 vlib_thread_main_t *vtm = vlib_get_thread_main ();
683 clib_error_t *error = 0;
686 sctp_connection_t *tc __attribute__ ((unused));
687 u32 preallocated_connections_per_thread;
689 if ((error = vlib_call_init_function (vm, ip_main_init)))
691 if ((error = vlib_call_init_function (vm, ip4_lookup_init)))
693 if ((error = vlib_call_init_function (vm, ip6_lookup_init)))
700 ip4_register_protocol (IP_PROTOCOL_SCTP, sctp4_input_node.index);
701 ip6_register_protocol (IP_PROTOCOL_SCTP, sctp6_input_node.index);
704 * Initialize data structures
707 num_threads = 1 /* main thread */ + vtm->n_threads;
708 vec_validate (tm->connections, num_threads - 1);
711 * Preallocate connections. Assume that thread 0 won't
712 * use preallocated threads when running multi-core
714 if (num_threads == 1)
717 preallocated_connections_per_thread = tm->preallocated_connections;
722 preallocated_connections_per_thread =
723 tm->preallocated_connections / (num_threads - 1);
725 for (; thread < num_threads; thread++)
727 if (preallocated_connections_per_thread)
728 pool_init_fixed (tm->connections[thread],
729 preallocated_connections_per_thread);
732 /* Initialize per worker thread tx buffers (used for control messages) */
733 vec_validate (tm->tx_buffers, num_threads - 1);
735 /* Initialize timer wheels */
736 vec_validate (tm->timer_wheels, num_threads - 1);
737 sctp_initialize_timer_wheels (tm);
739 /* Initialize clocks per tick for SCTP timestamp. Used to compute
740 * monotonically increasing timestamps. */
741 tm->tstamp_ticks_per_clock = vm->clib_time.seconds_per_clock
742 / SCTP_TSTAMP_RESOLUTION;
748 vec_validate (tm->tx_frames[0], num_threads - 1);
749 vec_validate (tm->tx_frames[1], num_threads - 1);
750 vec_validate (tm->ip_lookup_tx_frames[0], num_threads - 1);
751 vec_validate (tm->ip_lookup_tx_frames[1], num_threads - 1);
753 tm->bytes_per_buffer = vlib_buffer_free_list_buffer_size
754 (vm, VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX);
756 vec_validate (tm->time_now, num_threads - 1);
761 sctp_enable_disable (vlib_main_t * vm, u8 is_en)
765 if (sctp_main.is_enabled)
768 return sctp_main_enable (vm);
772 sctp_main.is_enabled = 0;
778 transport_connection_t *
779 sctp_half_open_session_get_transport (u32 conn_index)
781 sctp_connection_t *tc = sctp_half_open_connection_get (conn_index);
782 return &tc->sub_conn[MAIN_SCTP_SUB_CONN_IDX].connection;
786 format_sctp_half_open (u8 * s, va_list * args)
788 u32 tci = va_arg (*args, u32);
789 sctp_connection_t *tc = sctp_half_open_connection_get (tci);
790 return format (s, "%U", format_sctp_connection_id, tc);
794 const static transport_proto_vft_t sctp_proto = {
795 .enable = sctp_enable_disable,
796 .bind = sctp_session_bind,
797 .unbind = sctp_session_unbind,
798 .open = sctp_session_open,
799 .close = sctp_session_close,
800 .cleanup = sctp_session_cleanup,
801 .push_header = sctp_push_header,
802 .send_mss = sctp_session_send_mss,
803 .send_space = sctp_session_send_space,
804 .tx_fifo_offset = NULL, //sctp_session_tx_fifo_offset,
805 .get_connection = sctp_session_get_transport,
806 .get_listener = sctp_session_get_listener,
807 .get_half_open = sctp_half_open_session_get_transport,
808 .format_connection = format_sctp_session,
809 .format_listener = format_sctp_listener_session,
810 .format_half_open = format_sctp_half_open,
816 sctp_init (vlib_main_t * vm)
818 sctp_main_t *tm = vnet_get_sctp_main ();
819 ip_main_t *im = &ip_main;
820 ip_protocol_info_t *pi;
821 /* Session layer, and by implication SCTP, are disabled by default */
824 /* Register with IP for header parsing */
825 pi = ip_get_protocol_info (im, IP_PROTOCOL_SCTP);
827 return clib_error_return (0, "SCTP protocol info AWOL");
828 pi->format_header = format_sctp_header;
829 pi->unformat_pg_edit = unformat_pg_sctp_header;
831 /* Register as transport with session layer */
832 transport_register_protocol (TRANSPORT_PROTO_SCTP, &sctp_proto,
833 FIB_PROTOCOL_IP4, sctp4_output_node.index);
834 transport_register_protocol (TRANSPORT_PROTO_SCTP, &sctp_proto,
835 FIB_PROTOCOL_IP6, sctp6_output_node.index);
840 VLIB_INIT_FUNCTION (sctp_init);
843 * fd.io coding-style-patch-verification: ON
846 * eval: (c-set-style "gnu")