Project

General

Profile

Feature #3624 » 0001-WIP.patch

pespin, 11/06/2018 05:35 PM

View differences:

include/osmocom/bsc/abis_nm.h
1
/* GSM Network Management messages on the A-bis interface 
1
/* GSM Network Management messages on the A-bis interface
2 2
 * 3GPP TS 12.21 version 8.0.0 Release 1999 / ETSI TS 100 623 V8.0.0 */
3 3

  
4 4
/* (C) 2008-2009 by Harald Welte <laforge@gnumonks.org>
......
145 145
int abis_nm_ipaccess_set_nvattr(struct gsm_bts_trx *trx, uint8_t *attr,
146 146
				int attr_len);
147 147
int abis_nm_ipaccess_restart(struct gsm_bts_trx *trx);
148
int abis_nm_ipaccess_get_nvattr(struct gsm_bts_trx *trx, uint8_t *attr,
149
				int attr_len);
148 150
int abis_nm_ipaccess_set_attr(struct gsm_bts *bts, uint8_t obj_class,
149 151
				uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr,
150 152
				uint8_t *attr, uint8_t attr_len);
151
int abis_nm_ipaccess_rsl_connect(struct gsm_bts_trx *trx, 
153
int abis_nm_ipaccess_rsl_connect(struct gsm_bts_trx *trx,
152 154
				 uint32_t ip, uint16_t port, uint8_t stream);
153 155
void abis_nm_ipaccess_cgi(uint8_t *buf, struct gsm_bts *bts);
154 156
int ipac_parse_bcch_info(struct ipac_bcch_info *binf, uint8_t *buf);
src/ipaccess/ipaccess-config.c
59 59

  
60 60
static int net_listen_testnr;
61 61
static int restart;
62
static char *prim_oml_ip;
62
static bool get_prim_oml_ip;
63
static char *set_prim_oml_ip;
63 64
static char *bts_ip_addr, *bts_ip_mask, *bts_ip_gw;
64 65
static char *unit_id;
65 66
static uint16_t nv_flags;
......
493 494

  
494 495
static void bootstrap_om(struct gsm_bts_trx *trx)
495 496
{
496
	struct msgb *nmsg = msgb_alloc(1024, "nested msgb");
497
	int need_to_set_attr = 0;
497
	struct msgb *nmsg_get = msgb_alloc(1024, "nested get msgb");
498
	struct msgb *nmsg_set = msgb_alloc(1024, "nested set msgb");
499
	int need_to_get_attr = 0, need_to_set_attr = 0;
498 500
	int len;
499 501

  
500 502
	printf("OML link established using TRX %d\n", trx->nr);
501 503

  
504
	if (get_prim_oml_ip) {
505
		printf("getting primary OML link IP\n");
506
		msgb_put_u8(nmsg_get, NM_ATT_IPACC_PRIM_OML_CFG);
507
		need_to_get_attr = 1;
508
	}
502 509
	if (unit_id) {
503 510
		len = strlen(unit_id);
504
		if (len > nmsg->data_len-10)
511
		if (len > nmsg_set->data_len-10)
505 512
			goto out_err;
506 513
		printf("setting Unit ID to '%s'\n", unit_id);
507
		nv_put_unit_id(nmsg, unit_id);
514
		nv_put_unit_id(nmsg_set, unit_id);
508 515
		need_to_set_attr = 1;
509 516
	}
510
	if (prim_oml_ip) {
517
	if (set_prim_oml_ip) {
511 518
		struct in_addr ia;
512 519

  
513
		if (!inet_aton(prim_oml_ip, &ia)) {
520
		if (!inet_aton(set_prim_oml_ip, &ia)) {
514 521
			fprintf(stderr, "invalid IP address: %s\n",
515
				prim_oml_ip);
522
				set_prim_oml_ip);
516 523
			goto out_err;
517 524
		}
518 525

  
519 526
		printf("setting primary OML link IP to '%s'\n", inet_ntoa(ia));
520
		nv_put_prim_oml(nmsg, ntohl(ia.s_addr), 0);
527
		nv_put_prim_oml(nmsg_set, ntohl(ia.s_addr), 0);
521 528
		need_to_set_attr = 1;
522 529
	}
523 530
	if (nv_mask) {
524 531
		printf("setting NV Flags/Mask to 0x%04x/0x%04x\n",
525 532
			nv_flags, nv_mask);
526
		nv_put_flags(nmsg, nv_flags, nv_mask);
533
		nv_put_flags(nmsg_set, nv_flags, nv_mask);
527 534
		need_to_set_attr = 1;
528 535
	}
529 536
	if (bts_ip_addr && bts_ip_mask) {
......
542 549
		}
543 550

  
544 551
		printf("setting static IP Address/Mask\n");
545
		nv_put_ip_if_cfg(nmsg, ntohl(ia_addr.s_addr), ntohl(ia_mask.s_addr));
552
		nv_put_ip_if_cfg(nmsg_set, ntohl(ia_addr.s_addr), ntohl(ia_mask.s_addr));
546 553
		need_to_set_attr = 1;
547 554
	}
548 555
	if (bts_ip_gw) {
......
556 563

  
557 564
		printf("setting static IP Gateway\n");
558 565
		/* we only set the default gateway with zero addr/mask */
559
		nv_put_gw_cfg(nmsg, 0, 0, ntohl(ia_gw.s_addr));
566
		nv_put_gw_cfg(nmsg_set, 0, 0, ntohl(ia_gw.s_addr));
560 567
		need_to_set_attr = 1;
561 568
	}
562 569

  
570
	if (need_to_get_attr) {
571
		printf("abis_nm_get_attr (%d): %s\n", nmsg_get->len, osmo_hexdump(msgb_data(nmsg_get), msgb_length(nmsg_get)));
572
		abis_nm_get_attr(trx->bts, NM_OC_BASEB_TRANSC, 0, trx->nr, 0xff, nmsg_get->head, nmsg_get->len);
573
		oml_state = 1;
574
	}
575

  
563 576
	if (need_to_set_attr) {
564
		abis_nm_ipaccess_set_nvattr(trx, nmsg->head, nmsg->len);
577
		printf("abis_nm_ipaccess_set_nvattr\n");
578
		abis_nm_ipaccess_set_nvattr(trx, nmsg_set->head, nmsg_set->len);
565 579
		oml_state = 1;
566 580
	}
567 581

  
568
	if (restart && !prim_oml_ip && !software) {
582
	if (restart && !set_prim_oml_ip && !software) {
569 583
		printf("restarting BTS\n");
570 584
		abis_nm_ipaccess_restart(trx);
571 585
	}
572 586

  
573 587
out_err:
574
	msgb_free(nmsg);
588
	msgb_free(nmsg_get);
589
	msgb_free(nmsg_set);
575 590
}
576 591

  
577 592
static int nm_state_event(int evt, uint8_t obj_class, void *obj,
......
833 848
	printf("Commands for writing to the BTS:\n");
834 849
	printf("  -u --unit-id UNIT_ID\t\tSet the Unit ID of the BTS\n");
835 850
	printf("  -o --oml-ip IP\t\tSet primary OML IP (IP of your BSC)\n");
851
	printf("  -O --get-oml-ip IP\t\tGet primary OML IP (IP of your BSC)\n");
836 852
	printf("  -i --ip-address IP/MASK\tSet static IP address + netmask of BTS\n");
837 853
	printf("  -g --ip-gateway IP\t\tSet static IP gateway of BTS\n");
838 854
	printf("  -r --restart\t\t\tRestart the BTS (after other operations)\n");
......
911 927
		char *slash;
912 928
		static struct option long_options[] = {
913 929
			{ "unit-id", 1, 0, 'u' },
930
			{ "get-oml-ip", 0, 0, 'O' },
914 931
			{ "oml-ip", 1, 0, 'o' },
915 932
			{ "ip-address", 1, 0, 'i' },
916 933
			{ "ip-gateway", 1, 0, 'g' },
......
931 948
			{ 0, 0, 0, 0 },
932 949
		};
933 950

  
934
		c = getopt_long(argc, argv, "u:o:i:g:rn:S:U:l:L:hs:d:f:wcpH", long_options,
951
		c = getopt_long(argc, argv, "u:Oo:i:g:rn:S:U:l:L:hs:d:f:wcpH", long_options,
935 952
				&option_index);
936 953

  
937 954
		if (c == -1)
......
943 960
				exit(2);
944 961
			unit_id = optarg;
945 962
			break;
963
		case 'O':
964
			get_prim_oml_ip = true;
965
			break;
946 966
		case 'o':
947
			prim_oml_ip = optarg;
967
			set_prim_oml_ip = optarg;
948 968
			break;
949 969
		case 'i':
950 970
			slash = strchr(optarg, '/');
......
1044 1064
	gsm_bts_trx_alloc(bts);
1045 1065
	gsm_bts_trx_alloc(bts);
1046 1066
	bts->oml_tei = stream_id;
1047
	
1067

  
1048 1068
	osmo_signal_register_handler(SS_NM, nm_sig_cb, NULL);
1049 1069
	osmo_signal_register_handler(SS_IPAC_NWL, nwl_sig_cb, NULL);
1050 1070

  
......
1060 1080
		perror("Error connecting to the BTS");
1061 1081
		exit(1);
1062 1082
	}
1063
	
1083

  
1064 1084
	bts->oml_link->ts->sign.delay = 10;
1065 1085
	bts->c0->rsl_link->ts->sign.delay = 10;
1066 1086
	while (1) {
src/osmo-bsc/abis_nm.c
544 544
	DEBUGPFOH(DNM, foh, "Get Attributes Response for BTS%u\n", bts->nr);
545 545

  
546 546
	abis_nm_tlv_parse(&tp, bts, foh->data, oh->length-sizeof(*foh));
547
	if (TLVP_PRES_LEN(&tp, NM_ATT_IPACC_PRIM_OML_CFG_LIST, 1)) {
548
		data = TLVP_VAL(&tp, NM_ATT_IPACC_PRIM_OML_CFG_LIST);
549
		//uint16_t cfg_list_len = osmo_load16be(data+1);
550
		OSMO_ASSERT(NM_ATT_IPACC_PRIM_OML_CFG == *data);
551
		uint32_t ip = osmo_load32be(data+1);
552
		uint16_t port = osmo_load16be(data+5);
553
		struct in_addr ia = {0};
554
		ia.s_addr = htonl(ip);
555
		LOGP(DNM, LOGL_NOTICE, "%s Get Attributes Response: OML IP is %s:%u\n", gsm_trx_name(trx), inet_ntoa(ia), port);
556
	} else {
557
		LOGPFOH(DNM, LOGL_ERROR, foh, "BTS%u: Get Attr Response without List of Required Attributes?!\n",
558
			bts->nr);
559
	}
560

  
547 561
	if (!TLVP_PRES_LEN(&tp, NM_ATT_GET_ARI, 1)) {
548 562
		LOGPFOH(DNM, LOGL_ERROR, foh, "BTS%u: Get Attr Response without Response Info?!\n",
549 563
			bts->nr);
......
1649 1663
	if (bts->type != GSM_BTS_TYPE_OSMOBTS) {
1650 1664
		LOGPC(DNM, LOGL_NOTICE, "Getting attributes from BTS%d type %s is not supported.\n",
1651 1665
		      bts->nr, btstype2str(bts->type));
1652
		return -EINVAL;
1666
	      fprintf(stderr, "Getting attributes from BTS%d type %s is not supported.\n",
1667
		    bts->nr, btstype2str(bts->type));
1668
		//return -EINVAL;
1653 1669
	}
1654 1670

  
1655
	DEBUGP(DNM, "Get Attr (bts=%d)\n", bts->nr);
1671
	 fprintf(stderr, "Get Attr (bts=%d)\n", bts->nr);
1656 1672

  
1657 1673
	msg = nm_msgb_alloc();
1658 1674
	oh = (struct abis_om_hdr *) msgb_put(msg, ABIS_OM_FOM_HDR_SIZE);
......
2779 2795
}
2780 2796

  
2781 2797
/* set some attributes in NVRAM */
2782
int abis_nm_ipaccess_set_nvattr(struct gsm_bts_trx *trx, uint8_t *attr,
2798
	int abis_nm_ipaccess_set_nvattr(struct gsm_bts_trx *trx, uint8_t *attr,
2783 2799
				int attr_len)
2784 2800
{
2785 2801
	return abis_nm_ipaccess_msg(trx->bts, NM_MT_IPACC_SET_NVATTR,
......
2787 2803
				    attr_len);
2788 2804
}
2789 2805

  
2806
/* get some attributes from NVRAM */
2807
int abis_nm_ipaccess_get_nvattr(struct gsm_bts_trx *trx, uint8_t *attr,
2808
				int attr_len)
2809
{
2810
	return abis_nm_ipaccess_msg(trx->bts, NM_MT_IPACC_GET_NVATTR,
2811
				    NM_OC_BASEB_TRANSC, 0, trx->nr, 0xff, attr,
2812
				    attr_len);
2813
}
2814

  
2790 2815
static void rsl_connect_timeout(void *data)
2791 2816
{
2792 2817
	struct gsm_bts_trx *trx = data;
(2-2/5)
Add picture from clipboard (Maximum size: 48.8 MB)