MCPcopy Create free account
hub / github.com/EIPStackGroup/OpENer / main

Function main

source/src/ports/POSIX/main.c:47–185  ·  view source on GitHub ↗

/

Source from the content-addressed store, hash-verified

45
46/******************************************************************************/
47int main(int argc,
48 char *arg[]) {
49
50 cap_t capabilities;
51 cap_value_t capabilies_list[1];
52
53 capabilities = cap_get_proc();
54 if (NULL == capabilities) {
55 printf("Could not get capabilities\n");
56 exit(0);
57 }
58
59 capabilies_list[0] = CAP_NET_RAW;
60 if (-1
61 == cap_set_flag(capabilities, CAP_EFFECTIVE, 1, capabilies_list,
62 CAP_SET) ) {
63 cap_free(capabilities);
64 printf("Could not set CAP_NET_RAW capability\n");
65 exit(0);
66 }
67
68 if (-1 == cap_set_proc(capabilities) ) {
69 cap_free(capabilities);
70 printf("Could not push CAP_NET_RAW capability to process\n");
71 exit(0);
72 }
73
74 if (-1 == cap_free(capabilities) ) {
75 printf("Could not free capabilites value\n");
76 exit(0);
77 }
78
79 if (argc != 2) {
80 printf("Wrong number of command line parameters!\n");
81 printf("The correct command line parameters are:\n");
82 printf("./OpENer interfacename\n");
83 printf(" e.g. ./OpENer eth1\n");
84 exit(0);
85 } else {
86 DoublyLinkedListInitialize(&connection_list,
87 CipConnectionObjectListArrayAllocator,
88 CipConnectionObjectListArrayFree);
89 /* fetch Internet address info from the platform */
90 if (kEipStatusError == ConfigureNetworkInterface(arg[1]) ) {
91 printf("Network interface %s not found.\n", arg[1]);
92 exit(0);
93 }
94 ConfigureDomainName();
95 ConfigureHostName();
96
97 ConfigureMacAddress(arg[1]);
98 }
99
100 /* for a real device the serial number should be unique per device */
101 SetDeviceSerialNumber(123456789);
102
103 /* unique_connection_id should be sufficiently random or incremented and stored
104 * in non-volatile memory each time the device boots.

Callers

nothing calls this directly

Calls 11

ConfigureMacAddressFunction · 0.85
SetDeviceSerialNumberFunction · 0.85
CipStackInitFunction · 0.85
NetworkHandlerInitializeFunction · 0.85
executeEventLoopFunction · 0.85
NetworkHandlerFinishFunction · 0.85
ShutdownCipStackFunction · 0.85
ConfigureDomainNameFunction · 0.70
ConfigureHostNameFunction · 0.70

Tested by

no test coverage detected