<commit_before>/*
    This file is part of libcapwap.

    libcapwap is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    libcapwap is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Foobar.  If not, see <http://www.gnu.org/licenses/>.

*/

#include <stdio.h>
#include <stdlib.h>

#include "capwap.h"
#include "capwap_ieee80211.h"

#include "cw_util.h"

#include "sock.h"

int radioinfo_print(char * str, struct radioinfo * radioinfo)
{
	char * s = str;

	s += sprintf(s,"\t  RID %d\n",radioinfo->rid);
	s += sprintf(s,"\t  Modes: ");
	if(radioinfo->type & CW_IEEE80211_RADIO_TYPE_B){
		s+=sprintf(s,"B");
	}
	if(radioinfo->type & CW_IEEE80211_RADIO_TYPE_G){
		s+=sprintf(s,"G");
	}

	if(radioinfo->type & CW_IEEE80211_RADIO_TYPE_A){
		s+=printf(s,"A");
	}

	if(radioinfo->type & CW_IEEE80211_RADIO_TYPE_N){
		s+=sprintf(s,"N");
	}

	s+=sprintf(s,"\n");

	return s-str;

}


static int version_print(char *s, const uint8_t *version, int len, uint32_t vendor)
{
	
	if (!version)
		return sprintf(s,"Not set\n");


	int rs=0;	
	int i;


	if ( cw_is_printable(version,len)  ){
		rs+=sprintf(s+rs,"%s",version);
	}
	else{
		for (i=0; i<len && i<20; i++){
			rs+=sprintf(s+rs,"%02X",version[i]);
		}

		int dot=0;

		rs+=sprintf(s+rs," (");
		for (i=0; i<len && i<20; i++){
			if (dot) 
				rs+=sprintf(s+rs,".");
			dot=1;
			rs+=sprintf(s+rs,"%d",version[i]);
		}
		rs+=sprintf(s+rs,")");
	}


	rs+=sprintf(s+rs,", Vendor Id: %d",vendor);
	rs+=sprintf(s+rs,"\n");
	return rs;	
	
}

int wtpinfo_print(char *str, struct wtpinfo * wtpinfo)
{
	char hstr[64];

	char *s = str;




	s+=sprintf (s,"\tWTP Name: %s\n", (!wtpinfo->name ? (uint8_t*)"Not set" : wtpinfo->name) );
	s+=sprintf (s,"\tLocation: %s\n", (!wtpinfo->location ? (uint8_t*)"Not set" : wtpinfo->location) );

	s+=sprintf (s,"\tMAC Adress: ");
	if (wtpinfo->macaddress){
		sock_hwaddrtostr(wtpinfo->macaddress,wtpinfo->macaddress_len,hstr,":");
		s+=sprintf(s,"%s\n",hstr);

	}
	else
		s+=sprintf(s,"Not set\n");

	char disctypestr[32];<commit_msg>prints now iana vendor as string.<commit_after>/*
    This file is part of libcapwap.

    libcapwap is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    libcapwap is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Foobar.  If not, see <http://www.gnu.org/licenses/>.

*/

#include <stdio.h>
#include <stdlib.h>

#include "capwap.h"
#include "capwap_ieee80211.h"

#include "cw_util.h"

#include "sock.h"

int radioinfo_print(char * str, struct radioinfo * radioinfo)
{
	char * s = str;

	s += sprintf(s,"\t  RID %d\n",radioinfo->rid);
	s += sprintf(s,"\t  Modes: ");
	if(radioinfo->type & CW_IEEE80211_RADIO_TYPE_B){
		s+=sprintf(s,"B");
	}
	if(radioinfo->type & CW_IEEE80211_RADIO_TYPE_G){
		s+=sprintf(s,"G");
	}

	if(radioinfo->type & CW_IEEE80211_RADIO_TYPE_A){
		s+=printf(s,"A");
	}

	if(radioinfo->type & CW_IEEE80211_RADIO_TYPE_N){
		s+=sprintf(s,"N");
	}

	s+=sprintf(s,"\n");

	return s-str;

}


static int version_print(char *s, const uint8_t *version, int len, uint32_t vendor)
{
	
	if (!version)
		return sprintf(s,"Not set\n");


	int rs=0;	
	int i;


	if ( cw_is_printable(version,len)  ){
		if (len != 0 )
			rs+=sprintf(s+rs,"%s",version);
		else
			rs+=sprintf(s+rs,"''");
	}
	else{
		for (i=0; i<len && i<20; i++){
			rs+=sprintf(s+rs,"%02X",version[i]);
		}

		int dot=0;

		rs+=sprintf(s+rs," (");
		for (i=0; i<len && i<20; i++){
			if (dot) 
				rs+=sprintf(s+rs,".");
			dot=1;
			rs+=sprintf(s+rs,"%d",version[i]);
		}
		rs+=sprintf(s+rs,")");
	}


	rs+=sprintf(s+rs,", Vendor Id: %d, %s",vendor, cw_ianavendoridtostr(vendor));
	rs+=sprintf(s+rs,"\n");
	return rs;	
	
}

int wtpinfo_print(char *str, struct wtpinfo * wtpinfo)
{
	char hstr[64];

	char *s = str;




	s+=sprintf (s,"\tWTP Name: %s\n", (!wtpinfo->name ? (uint8_t*)"Not set" : wtpinfo->name) );
	s+=sprintf (s,"\tLocation: %s\n", (!wtpinfo->location ? (uint8_t*)"Not set" : wtpinfo->location) );

	s+=sprintf (s,"\tMAC Adress: ");
	if (wtpinfo->macaddress){
		sock_hwaddrtostr(wtpinfo->macaddress,wtpinfo->macaddress_len,hstr,":");
		s+=sprintf(s,"%s\n",hstr);

	}
	else
		s+=sprintf(s,"Not set\n");

	char disctypestr[32];
{'fraction_non_alphanumeric': 0.17573471008737093, 'fraction_numerical': 0.018467037331215252, 'mean_word_length': 3.9970238095238093, 'pattern_counts': {'":': 2, '<': 17, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '743916', 'n_tokens_mistral': 2180, 'n_tokens_neox': 2024, 'n_words': 481}