summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/sccp/sccp.h3
-rw-r--r--src/sccp.c24
-rw-r--r--tests/sccp/sccp_test.c6
3 files changed, 17 insertions, 16 deletions
diff --git a/include/sccp/sccp.h b/include/sccp/sccp.h
index ed833e3..9e692cf 100644
--- a/include/sccp/sccp.h
+++ b/include/sccp/sccp.h
@@ -106,8 +106,9 @@ struct sccp_connection {
* system functionality to implement on top of any other transport layer:
* call sccp_system_incoming for incoming data (from the network)
* sccp will call outgoing whenever outgoing data exists
+ * The conn is NULL for UDT and other messages without a connection
*/
-int sccp_system_init(void (*outgoing)(struct msgb *data, void *ctx), void *context);
+int sccp_system_init(void (*outgoing)(struct sccp_connection *conn, struct msgb *data, void *ctx), void *context);
int sccp_system_incoming(struct msgb *data);
/**
diff --git a/src/sccp.c b/src/sccp.c
index 97e19bd..9a988de 100644
--- a/src/sccp.c
+++ b/src/sccp.c
@@ -47,7 +47,7 @@ const struct sockaddr_sccp sccp_ssn_bssap = {
struct sccp_system {
/* layer3 -> layer2 */
- void (*write_data)(struct msgb *data, void *context);
+ void (*write_data)(struct sccp_connection *conn, struct msgb *data, void *context);
void *write_context;
};
@@ -93,9 +93,9 @@ static struct sccp_data_callback *_find_ssn(uint8_t ssn)
}
-static void _send_msg(struct msgb *msg)
+static void _send_msg(struct sccp_connection *conn, struct msgb *msg)
{
- sccp_system.write_data(msg, sccp_system.write_context);
+ sccp_system.write_data(conn, msg, sccp_system.write_context);
}
/*
@@ -558,7 +558,7 @@ static int _sccp_send_data(int class, const struct sockaddr_sccp *in,
if (!msg)
return -1;
- _send_msg(msg);
+ _send_msg(NULL, msg);
return 0;
}
@@ -685,7 +685,7 @@ static int _sccp_send_refuse(struct sccp_source_reference *src_ref, int cause)
if (!msgb)
return -1;
- _send_msg(msgb);
+ _send_msg(NULL, msgb);
return 0;
}
@@ -732,7 +732,7 @@ static int _sccp_send_connection_confirm(struct sccp_connection *connection)
if (!response)
return -1;
- _send_msg(response);
+ _send_msg(connection, response);
_sccp_set_connection_state(connection, SCCP_CONNECTION_STATE_ESTABLISHED);
return 0;
}
@@ -790,7 +790,7 @@ static int _sccp_send_connection_request(struct sccp_connection *connection,
llist_add_tail(&connection->list, &sccp_connections);
_sccp_set_connection_state(connection, SCCP_CONNECTION_STATE_REQUEST);
- _send_msg(request);
+ _send_msg(connection, request);
return 0;
}
@@ -838,7 +838,7 @@ static int _sccp_send_connection_data(struct sccp_connection *conn, struct msgb
if (!msgb)
return -1;
- _send_msg(msgb);
+ _send_msg(conn, msgb);
return 0;
}
@@ -861,7 +861,7 @@ static int _sccp_send_connection_it(struct sccp_connection *conn)
it->sequencing[0] = it->sequencing[1] = 0;
it->credit = 0;
- _send_msg(msgb);
+ _send_msg(conn, msgb);
return 0;
}
@@ -906,7 +906,7 @@ static int _sccp_send_connection_released(struct sccp_connection *conn, int caus
return -1;
_sccp_set_connection_state(conn, SCCP_CONNECTION_STATE_RELEASE);
- _send_msg(msg);
+ _send_msg(conn, msg);
return 0;
}
@@ -1066,7 +1066,7 @@ static int _sccp_send_connection_release_complete(struct sccp_connection *connec
memcpy(&rlc->source_local_reference,
&connection->source_local_reference, sizeof(struct sccp_source_reference));
- _send_msg(msgb);
+ _send_msg(connection, msgb);
/*
* Remove from the list of active connections and set the state. User code
@@ -1187,7 +1187,7 @@ found:
}
-int sccp_system_init(void (*outgoing)(struct msgb *data, void *ctx), void *ctx)
+int sccp_system_init(void (*outgoing)(struct sccp_connection *conn, struct msgb *data, void *ctx), void *ctx)
{
sccp_system.write_data = outgoing;
sccp_system.write_context = ctx;
diff --git a/tests/sccp/sccp_test.c b/tests/sccp/sccp_test.c
index f10caea..c5c6f4f 100644
--- a/tests/sccp/sccp_test.c
+++ b/tests/sccp/sccp_test.c
@@ -427,7 +427,7 @@ int sccp_read_cb(struct msgb *data, unsigned len, void *context)
return 0;
}
-void sccp_write_cb(struct msgb *data, void *ctx)
+void sccp_write_cb(struct sccp_connection *conn, struct msgb *data, void *ctx)
{
int i = 0;
const uint8_t *got, *wanted;
@@ -479,7 +479,7 @@ int sccp_accept_cb(struct sccp_connection *connection, void *user_data)
return 0;
}
-static void sccp_udt_write_cb(struct msgb *data, void *context)
+static void sccp_udt_write_cb(struct sccp_connection *conn, struct msgb *data, void *context)
{
const uint8_t *got, *wanted;
int i;
@@ -570,7 +570,7 @@ static int sccp_udt_read(struct msgb *data, unsigned int len, void *context)
return 0;
}
-static void sccp_write_loop(struct msgb *data, void *context)
+static void sccp_write_loop(struct sccp_connection *conn, struct msgb *data, void *context)
{
/* send it back to us */
sccp_system_incoming(data);