xref: /freebsd/lib/libiscsiutil/connection.c (revision 4d846d26)
163783933SJohn Baldwin /*-
24d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
363783933SJohn Baldwin  *
463783933SJohn Baldwin  * Copyright (c) 2012 The FreeBSD Foundation
563783933SJohn Baldwin  *
663783933SJohn Baldwin  * This software was developed by Edward Tomasz Napierala under sponsorship
763783933SJohn Baldwin  * from the FreeBSD Foundation.
863783933SJohn Baldwin  *
963783933SJohn Baldwin  * Redistribution and use in source and binary forms, with or without
1063783933SJohn Baldwin  * modification, are permitted provided that the following conditions
1163783933SJohn Baldwin  * are met:
1263783933SJohn Baldwin  * 1. Redistributions of source code must retain the above copyright
1363783933SJohn Baldwin  *    notice, this list of conditions and the following disclaimer.
1463783933SJohn Baldwin  * 2. Redistributions in binary form must reproduce the above copyright
1563783933SJohn Baldwin  *    notice, this list of conditions and the following disclaimer in the
1663783933SJohn Baldwin  *    documentation and/or other materials provided with the distribution.
1763783933SJohn Baldwin  *
1863783933SJohn Baldwin  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1963783933SJohn Baldwin  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2063783933SJohn Baldwin  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2163783933SJohn Baldwin  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
2263783933SJohn Baldwin  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2363783933SJohn Baldwin  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2463783933SJohn Baldwin  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2563783933SJohn Baldwin  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2663783933SJohn Baldwin  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2763783933SJohn Baldwin  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2863783933SJohn Baldwin  * SUCH DAMAGE.
2963783933SJohn Baldwin  */
3063783933SJohn Baldwin 
3163783933SJohn Baldwin #include <string.h>
3263783933SJohn Baldwin 
3363783933SJohn Baldwin #include "libiscsiutil.h"
3463783933SJohn Baldwin 
3563783933SJohn Baldwin void
connection_init(struct connection * conn,const struct connection_ops * ops,bool use_proxy)3663783933SJohn Baldwin connection_init(struct connection *conn, const struct connection_ops *ops,
3763783933SJohn Baldwin 	bool use_proxy)
3863783933SJohn Baldwin {
3963783933SJohn Baldwin 	memset(conn, 0, sizeof(*conn));
4063783933SJohn Baldwin 	conn->conn_ops = ops;
4163783933SJohn Baldwin 	conn->conn_use_proxy = use_proxy;
4263783933SJohn Baldwin 
4363783933SJohn Baldwin 	/*
4463783933SJohn Baldwin 	 * Default values, from RFC 3720, section 12.
4563783933SJohn Baldwin 	 */
4663783933SJohn Baldwin 	conn->conn_header_digest = CONN_DIGEST_NONE;
4763783933SJohn Baldwin 	conn->conn_data_digest = CONN_DIGEST_NONE;
4863783933SJohn Baldwin 	conn->conn_immediate_data = true;
4963783933SJohn Baldwin 	conn->conn_max_recv_data_segment_length = 8192;
5063783933SJohn Baldwin 	conn->conn_max_send_data_segment_length = 8192;
5163783933SJohn Baldwin 	conn->conn_max_burst_length = 262144;
5263783933SJohn Baldwin 	conn->conn_first_burst_length = 65536;
5363783933SJohn Baldwin }
54