C

22K

Solutions

13K

Contributors

C is a general-purpose, imperative computer programming language, supporting structured programming, lexical variable scope and recursion, while a static type system prevents many unintended operations. By design, C provides constructs that map efficiently to typical machine instructions, so it has found lasting use in applications that had formerly been coded in assembly language, including operating systems as well as various application software for computers ranging from supercomputers to embedded systems. It is distinct from C++ (which has its roots in C) and C#, and many later languages have borrowed directly or indirectly from C.

Share tech news, updates, or what's on your mind.

Sign up to Post

hello,

Need help in how to do a vbs file for doing the below procedure:

Fixing DameWare to run on Windows10
            a. Copy file from //myDomain/Support/DameWare/dwdrvinst64.exe to c:/MyLogFile/
            b. Run CMD as Administrator
            c. cd ..
            d. cd /MyLogFile
            e. dwdrvinst64 -remove smartcard
            f. dwdrvinst64 -install smartcard


Don't know of a better way, or even run an *exe to do this...

Please help.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE
LVL 4
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

It means that there are 88 things in the sky.
0
Hello ,

I want to appy a system command with arguments from variables but i could not find an example any body has experience about this ?


This is what i want to do
system("/bin/bash  /etc/a.sh   %d %d",val1,val2);
0
I am testing the authorized.net captureprviouslyauthorizedamount i can get an transaction type as authorization only but can not get the capture amount. it is saying invalied transaction id. Do i need to change from test to production and than cancel the credit card amount
0
A  wonderful new day.

Am wriiting a window service application in C# and its supposed to call  a C programme from its OnStart() function.

My question is this :

(1 ) Can i develop a C WIN32API in Visual Studio 2017, if yes, how can i please.

(2) Starting from the OnStart() function  how  do i call the C application


Thank you
0
Hello ,


Any body knows a sample for re-calculate checksums and drop packets on netfilter module ?

Thank you
0
How do I move a space between Disc- D to Disc C in a virtual machine?
0
 
LVL 122
You've already posted a Question to the VMware Topic area, which I've answered!

https://www.experts-exchange.com/questions/29050158/Place-on-disk.html#a42252780
0
How to write test case for c program
0
Hello ,

We want to create fork subroutines on runtime and let it die after 180 seconds. But ;
We do not want to let the mirror all global variables that should cause high memory usage on the system , we just want to pass the variables to the fork and it will do a few small jobs then will end it self after 180 seconds is it possible to isolate from the other app ?
As far as i know when a fork start it completely clone the existing maps / arrays etc. and work in another road.
0
Hello ,

For a project we are using ip.h library of the linux.
As far as i check the library , http://www.cse.scu.edu/~dclark/am_256_graph_theory/linux_2_6_stack/linux_2ip_8h-source.html  , i could not find a way to check Window size , is there any way to read complete packet hex with this library and get the window size of packet hex like given below :

			long dec_Window_size = std::stol (packet_hex.substr(96,4),nullptr,16);

Open in new window

0
Independent Software Vendors: We Want Your Opinion
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Hello ,

We are building an IDS/IPS/Waf system that reads the packets from PF_Ring and apply rules to IPTables / Netfilter / Ntuple .
That software needs to access to userspace for iptables and kernelspace for netfilter. So we already pipe the both side.
But our main concern is about the performace issue. Time is our biggest enemy and need to solve the problem in mikro / mili seconds.
So where is the best place working area for our  main core of software for performance ? kernel area or user area ? and why .

Thanks for information
0
How should i solve this :)


	std::string RANGE ;
			std::stringstream RANGEstream;
			for (std::pair<long int, int> element : TTL) {
				RANGEstream <<  element.first;
				RANGE = RANGE + RANGEstream;
			}

Open in new window



dinleyici.c:352:19: error: no match for ‘operator+’ (operand types are ‘std::string {aka std::basic_string<char>}’ and ‘std::stringstream {aka std::basic_stringstream<char>}’)
     RANGE = RANGE + RANGEstream;
                   ^

Open in new window

0
Hello ,


Is there any body know a way to send live message to kernel module like the given below. I want to send a message to it and let it write to logs the message
My message will be sended from the user space and the kernel module is working on kernel space




#include <linux/module.h>	/* Needed by all modules */
#include <linux/kernel.h>	/* Needed for KERN_INFO */

int init_module(void)
{
	printk(KERN_INFO "Hello world 1.\n");
	return 0;
}

void cleanup_module(void)
{
	printk(KERN_INFO "Goodbye world 1.\n");
}

Open in new window

0
Hello ,

I want to know if there is a possible way to apply BPF filter to drop packets on netfilter  


Thank you



#define __KERNEL__
#define MODULE
#include <linux/ip.h>             
#include <linux/kernel.h> 
#include <linux/module.h> 
#include <linux/netdevice.h>      
#include <linux/netfilter.h>
#include <linux/netfilter_ipv4.h> 
#include <linux/skbuff.h>         
#include <linux/udp.h>      

#include <linux/ip.h>


              
static struct nf_hook_ops netfilter_ops;                        
static unsigned char *ip_address = "\x5D\xBB\xCD\x73"; 
static char *interface = "p1p2";                          
unsigned char *port = "\x00\x17";                       
struct sk_buff *sock_buff;                              
struct udphdr *udp_header;                              
unsigned int main_hook(unsigned int hooknum,
                  struct sk_buff **skb,
                  const struct net_device *in,
                  const struct net_device *out,
                  int (*okfn)(struct sk_buff*))
{
  if(strcmp(in->name,interface) == 0){ return NF_DROP; }  
  struct iphdr* iph = ip_hdr(skb);
  if(iph->saddr == *(unsigned int*)ip_address){ return NF_DROP; }   
        
        
        
	/**sock_buff = *skb;
	if(!sock_buff){ return NF_ACCEPT; }                   
	if(!(iph)){ return NF_ACCEPT; }              
	if(iph->protocol != 17){ return NF_ACCEPT; }                 
	udp_header = (struct udphdr *)(sock_buff->data + (iph->ihl *4)); 
	

Open in new window

0
on the C++2011 compiler why that warnings happens for this code part and how should i do the legal app.
(*((unsigned int*)&ip4[0]))




dinleyici.c: In constructor ‘IP4::IP4(const char*)’:
dinleyici.c:36:28: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
   *((unsigned int *)&ip4[0]) = 0;
                            ^
dinleyici.c: In function ‘bool operator<(const IP4&, const IP4&)’:
dinleyici.c:44:96: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
  friend bool operator<(const IP4 & ip1, const IP4 & ip2) { return *((unsigned int *)&ip1.ip4[0]) < *((unsigned int *)&ip2.ip4[0]); }
                                                                                                ^
dinleyici.c:44:129: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
  friend bool operator<(const IP4 & ip1, const IP4 & ip2) { return *((unsigned int *)&ip1.ip4[0]) < *((unsigned int *)&ip2.ip4[0]); }
                                                                                                                                 ^
dinleyici.c: In member function ‘IP4::operator unsigned int()’:
dinleyici.c:51:67: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
         operator unsigned int() { return (*((unsigned int*)&ip4[0])); }  // cast the pointer to low byte to unsigned int  }
                    

Open in new window

0
hello

static std::map<Log, int> Logmap_;
static std::map<Log, int> Logmap_new;


Is there any possible way to search in a hash table which has values like given below 16-24. char for 4F94CFAE  and put founded lines to Logmap_new from  Logmap_ with values



DC38E1AC9B89A0369F557CAA080045100104FC62400040069BD5257B628A4EAFCAF70016F273CA35B6FD50ED7F8D50180094CE830000BC2411DB2762C01F5AE797C64F94CFAE2833E406D8376DB4005717643E0DBA31A7D5BA073799AB93CEE4E22A357C
DC38E1AC9B89A0369F557CAA080045100338FC634000400699A0257B628A4EAFCAF70016F273CA35B7D950ED7F8D501800940CEE0000974CEDC48B7C50744D96523A13FBD77D4CCAE45BF24F9FB91E7B43600A7397E2DD9788F7E7837D69170BD5A94E83
A0369F557CAADC38E1AC9B8908004500004CCC3440003A06D2CB4EAFCAF7257B628AF273001650ED7F8DCA35B2B150182000D53900003068613A5E81D88EEB70EC9A0B45304A8266890A03CB36E112653052C767CCFEC9281625
DC38E1AC9B89A0369F557CAA08004510004CFC64400040069C8B257B628A4EAFCAF70016F273CA35BAE950ED7FB15018009413FA0000E1FC591EA86C2AEA5245848504E41776637B03D3261D943B020BA01464A715C32B4E4610
A0369F557CAADC38E1AC9B89080045000028014040003A069DE44EAFCAF7257B628AF273001650ED7FB1CA35B4CD50101FEFAC0D0000000000000000
A0369F557CAADC38E1AC9B89080045000028DDF640003A06C12D4EAFCAF7257B628AF273001650ED7FB1CA35B6FD50101FEEA9DE0000000000000000
A0369F557CAADC38E1AC9B8908004500002807BA40003A06976A4EAFCAF7257B628AF273001650ED7FB1CA35B7D950101FF9A8F70000000000000000

Open in new window

0
Hello

Is there any body knows ready to use sub routine when we send an array it will draw sth. like that :

value |-------------------------------------------------- count
    0 |                                                     32167
    1 |                                                      9999
    2 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@  1723569
    4 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@                        973472
    8 |@@@                                                 111055
   16 |                                                     14777
   32 |                                                       376
   64 |                                                       585
  128 |                                                        19
  256 |                                                         0
  512 |                                                         0

Open in new window

0
Hello ,

The given code below returns an answer as given at the bottom . I need to put each line into an array .  how should i do it ? I mean i need to build line in for i loop and then need to add to array.

Thank you


	for (int i = 0; i < (bpf_u_int32) pkthdr->caplen; i++) {
		printf("%02X%s", (uint8_t)packet[i], (i + 1)%2 ? "" : "");
	}
	printf("\n");

Open in new window



DC 38E1 AC9B 89A0 369F 557C AA08 0045 C002 40B1 6900 0040 01ED A925 7B62 8A3B C115 2403 0337 A600 0000 0045 0004 1846 F000 00FD 1199 FA3B C115 2425 7B62 8AC1 3B00 1704 0400 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 00
A0 369F 557C AADC 38E1 AC9B 8908 0045 0004 1846 E900 00FD 11B0 6759 7DE1 0125 7B62 8A7D 5900 1704 0400 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 00
A0 369F 557C AADC 38E1 AC9B 8908 0045 0004 1847 7600 00FD 1188 6C7E 94E3 5825 7B62 8A94 7E00 1704 0400 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 00
A0 369F 557C AADC 38E1 AC9B 8908 0045 0004 1847 9100 00FD 1168 74B4 AECD 1B25 7B62 8AAE B400 1704 0400 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 00
A0 369F 557C AADC 38E1 AC9B 8908 0045 0004 1847 8C00 00FD 1147 4C4D D055 2725 7B62 8AD0 4D00 1704 0400 

Open in new window

0
Hello ,

I got a code like the given below , there is no begin and end values but it enters the if statement different parts but i could not understand why or how , should somebody tell me how this values changes on incrementIp function

	
struct SharedData
{
	bool done;
	pthread_mutex_t mutex;
	unsigned int ip_ring[100];
	int begin;
	int end;
	void shared_data() { memset(this, 0, sizeof(SharedData));}
	void incrementIp(unsigned int ip4){
		
		pthread_mutex_lock(&mutex);
		if ((end+1)%100 == begin)
		{			
			pthread_mutex_unlock(&mutex);
			incrementIp(ip4);
		}
		else
		{
			ip_ring[end] = ip4;
			end = (++end)%100;	
		
		}
		pthread_mutex_unlock(&mutex);

	}
	void synchronizeIps(std::map<IP4, int> & ip4map)
	
	{  
		pthread_mutex_lock(&mutex);
		for (int n = begin; n != (end+1)%100; n = (n+1)%100)
		{
			int ipaddress_decimal;
			memcpy(&ipaddress_decimal, &ip_ring[n], sizeof(unsigned int));
			struct in_addr dst_addr;
			dst_addr.s_addr = __bswap_32(ipaddress_decimal);
			char *dot_dst_ip = inet_ntoa(dst_addr);
			ip4map[dot_dst_ip]++;
			begin = n;
		}
		pthread_mutex_unlock(&mutex);
	}
};

Open in new window

0
What does it mean to be "Always On"?
LVL 4
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

when i add an ip to my hashtable from main process before start fork or in the forked process child it count independantly num_entries then the normal process in the program.

How should i solve to not behave them independently ?

	void child(){
		int j = 0;
		for (; j < 5000; ++j)
		{
		    int num_entries = ip4map.size();
		    printf("%d   \n",num_entries);
			usleep(500000);
	            
		}
	}

Open in new window


	struct IP4
	{
	    unsigned char ip4[4];
	    IP4(const char * szip) 
	    {
	        const char * psz = &szip[0]; int n = 4;
	        *((unsigned int *)&ip4[0]) = 0;
	        do 
	        {
	            ip4[--n] = (unsigned char)atoi(psz);
	            psz = (const char*)strchr(psz, '.');
	        }
	        while (n > 0 && NULL != psz++);
	    }   
	    friend bool operator<(const IP4 & ip1, const IP4 & ip2) { return *((unsigned int *)&ip1.ip4[0]) < *((unsigned int *)&ip2.ip4[0]); }
	    operator std::string() 
	    { 
	        std::ostringstream oss; 
	        oss << (int)ip4[3] << '.' << (int)ip4[2] << '.' << (int)ip4[1] << '.' << (int)ip4[0]; 
	        return oss.str(); 
	    }
	};
	std::map<IP4, int> ip4map;

Open in new window

0
Hello


printf("0x%02X%02X", (uint8_t)packet[56], (uint8_t)packet[57]);

Open in new window


That returns me the hex of 1460 decimal value.   (0x05B4)  how should i get the value as integer 1460 ?

Thank you
0
I'm programming Infineon TC29x Aurix Tricore Microcontroller based embedded system in 'C' language.
 
Consider stack starting at address 0x5000 0000.  The stack size is 0x1000.  

If I add 0x1000 to current stack pointer(Register A10) and store result in A10, then I should get underflow error.

What might be the code in assembly to change stack pointer?  something like following:

stw a10, 0x1000(a10)   # I'm not sure if stw is correct opcode ?

what are other options to create stack undeflow exception?
0
I'm attempting to integrate some functionality into a C-Language DLL that I use with my PowerBuilder application in order to manipulate Active Directory users without having to buy an expensive package or do the work manually.  I basically copied the following code (found on more than one web site) and the results of the compile return errors that both the "CreateDSObject" and "Release" functions are not members of the "IDirectoryObject" or "IDispatch" structures.  Here's the code I'm using:

        HRESULT                  hr;
      IDirectoryObject              *pDirObject;
      ADSVALUE                  sAMValue;
      ADSVALUE                  uPNValue;
      ADSVALUE                  classValue;
      LPDISPATCH                  pDisp;
      REFIID                        IID_IDirectoryObject;
      
      ADS_ATTR_INFO  attrInfo[] =
      {  
            { L"objectClass",            ADS_ATTR_UPDATE, ADSTYPE_CASE_IGNORE_STRING, &classValue,      1 },
            { L"sAMAccountName",      ADS_ATTR_UPDATE, ADSTYPE_CASE_IGNORE_STRING, &sAMValue,            1 },
            { L"userPrincipalName", ADS_ATTR_UPDATE, ADSTYPE_CASE_IGNORE_STRING, &uPNValue,            1 },
      };
      DWORD dwAttrs = sizeof(attrInfo)/sizeof(ADS_ATTR_INFO);
      
      classValue.dwType                        =      ADSTYPE_CASE_IGNORE_STRING;
      classValue.CaseIgnoreString            =      L"user";
      
      sAMValue.dwType                              =      ADSTYPE_CASE_IGNORE_STRING;
      sAMValue.CaseIgnoreString            =      L"browvick";
      
      uPNValue.dwType                              =      ADSTYPE_CASE_IGNORE_STRING;
      uPNValue.CaseIgnoreString            =      L"Vicky_Brown@gmail.com";
      
      hr = ADsGetObject(      L"LDAP://DC=domainname,DC=com",
                                    IID_IDirectoryObject,
                                    (void**) …
0
Ok, I need to write a program in a class named "whatever" and ignore the main method for a moment.

In this class, I need to create a static method with one parameter of type int[ ] and Inside the method
a. Keep all output on one line I guess using System.out.print( )
b. Display an opening square bracket character.
c. Loop through the array that was passed into the method, display the values in the array, add a comma
and a space after every value except the last one.
d. then display a closing square bracket character...I guess using System.out.println().

Then, in my main method I've got to create an array and pass the reference to this array to the "printArray" method.
    int[ ] oneD = {5, 6, 7, 8};
Then in my main method, I need to add a blank println() statement after the method call just made.
and in the class, create an overloaded static method  with one parameter of type int[ ] [] named "arr" and inside:
a. Use println() to display an opening square bracket character.
b. Loop through the two-­dimensional array that was passed into the method.
     i. First, use System.out.print() to display two space characters.
     ii. Every element of this two­-dimensional array that you are looping through is a one­-dimensional
         array of int. Call the other printArray method and pass to it each one­-dimensional array in the
         two­-dimensional array.
c. Using println(), display a closing square bracket character.

Then in the main method, I need …
0
I would like  to delete this account Basem Test from the users  list in C drive it wont let me delete it,  it says it is open in another program. How can i delete it ?
0

C

22K

Solutions

13K

Contributors

C is a general-purpose, imperative computer programming language, supporting structured programming, lexical variable scope and recursion, while a static type system prevents many unintended operations. By design, C provides constructs that map efficiently to typical machine instructions, so it has found lasting use in applications that had formerly been coded in assembly language, including operating systems as well as various application software for computers ranging from supercomputers to embedded systems. It is distinct from C++ (which has its roots in C) and C#, and many later languages have borrowed directly or indirectly from C.