From patchwork Wed Oct 8 10:05:14 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacob Erlbeck X-Patchwork-Id: 397588 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from ganesha.gnumonks.org (ganesha.gnumonks.org [IPv6:2001:780:45:1d:225:90ff:fe52:c662]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 6E28A140077 for ; Wed, 8 Oct 2014 21:16:28 +1100 (EST) Received: from localhost ([127.0.0.1] helo=ganesha.gnumonks.org) by ganesha.gnumonks.org with esmtp (Exim 4.72) (envelope-from ) id 1XboHz-0001V6-KJ; Wed, 08 Oct 2014 12:16:12 +0200 Received: from mail.sysmocom.de ([2a01:4f8:191:444c::2:4]) by ganesha.gnumonks.org with esmtp (Exim 4.72) (envelope-from ) id 1Xbo8J-0001KD-6d for openbsc@lists.osmocom.org; Wed, 08 Oct 2014 12:06:13 +0200 Received: from sysmocom-tmp.lan (e178216153.adsl.alicedsl.de [85.178.216.153]) by mail.sysmocom.de (Postfix) with ESMTPSA id EC6567DD4A; Wed, 8 Oct 2014 10:06:07 +0000 (UTC) From: Jacob Erlbeck To: openbsc@lists.osmocom.org Subject: [PATCH 2/6] gprs-ns/test: Save the last PCU type sent Date: Wed, 8 Oct 2014 12:05:14 +0200 Message-Id: <1412762718-31961-2-git-send-email-jerlbeck@sysmocom.de> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1412762718-31961-1-git-send-email-jerlbeck@sysmocom.de> References: <1412762718-31961-1-git-send-email-jerlbeck@sysmocom.de> X-Spam-Score: 0.0 (/) Cc: Jacob Erlbeck X-BeenThere: openbsc@lists.osmocom.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Development of the OpenBSC GSM base station controller List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: openbsc-bounces@lists.osmocom.org Errors-To: openbsc-bounces@lists.osmocom.org This records the PCU type of the last message sent to the remote peer in the global variable sent_pdu_type, which can then be used in assertions. Note that sent_pdu_type will remain unchanged if no message has been sent via sendto. Sponsored-by: On-Waves ehf --- tests/gb/gprs_ns_test.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/gb/gprs_ns_test.c b/tests/gb/gprs_ns_test.c index 15e36ba..0b3a76c 100644 --- a/tests/gb/gprs_ns_test.c +++ b/tests/gb/gprs_ns_test.c @@ -32,6 +32,8 @@ #define SGSN_NSEI 0x0100 +static int sent_pdu_type = 0; + static int gprs_process_message(struct gprs_ns_inst *nsi, const char *text, struct sockaddr_in *peer, const unsigned char* data, size_t data_len); @@ -265,6 +267,8 @@ ssize_t sendto(int sockfd, const void *buf, size_t len, int flags, if (!real_sendto) real_sendto = dlsym(RTLD_NEXT, "sendto"); + sent_pdu_type = len > 0 ? ((uint8_t *)buf)[0] : -1; + if (dest_host == REMOTE_BSS_ADDR) printf("MESSAGE to BSS, msg length %d\n%s\n\n", len, osmo_hexdump(buf, len)); else if (dest_host == REMOTE_SGSN_ADDR)