Bind failed for same driver name in /proc/crypto - cryptography

In /proc/crypto I have 2 drivers with same name.
name : gcm(aes)
driver : xilinx-zynqmp-aes-gcm
module : kernel
priority : 200
refcnt : 1
selftest : passed
internal : no
type : aead
async : yes
blocksize : 1
ivsize : 12
maxauthsize : 16
geniv : <none>
name : gcm(aes)
driver : gcm-aes-ce
module : kernel
priority : 300
refcnt : 1
selftest : passed
internal : no
type : aead
async : no
blocksize : 1
ivsize : 12
maxauthsize : 16
geniv : <none>
In a code I am trying to bind my socket to driver.
struct sockaddr_alg sa = {
.salg_family = AF_ALG,
.salg_type = "aead",
.salg_name = "gcm(aes)"
};
tfmfd = socket(AF_ALG, SOCK_SEQPACKET, 0);
ret = bind(tfmfd, (struct sockaddr *)&sa, sizeof(sa));
if (ret == -1) {
printf("bind failed %s\n", strerror(errno));
close(tfmfd);
return -1;
}
I encountered with an error.
bind failed No such file or directory
Is it because if kernel finds two algorithm with same name?

Related

ESP32 Arduino: Guru Meditation Error: Core 1 panic'ed (StoreProhibited)

Sending data from (mesh network)smoke sensors to AWS. I am storing the node data using linked list.After passing data to AWS,i am try to de-allocate the memory and coming across following two errors in free().
#include <stdio.h>
#include<stdlib.h>
typedef struct Node
{
uint8_t node_data[15]; //stores node infomation
struct Node* next; //pointer to next node
}node;
node *head=NULL;
node*current=NULL;
static uint8_t k[15]; //this array keeps track of data received on UART port
static uint8_t node_count=0; //keeps the track of no. of nodes added to the system
void push_data(int []); /*this function pushes data present in array into
a node(memory allocated to node dynamically)*/
void delete_node(node*); //this function deletes the memory allocated to node
void pack_data(void); // send node data to aws
void loop()
{
if(Serial2.available()>0)
{
for( uint8_t i=0;i<15;i++)
{
k [i]= Serial2.read();
}
push_data(k);
}
delay(5000);
}
void push_data(uint8_t arr[])
{
if(head==NULL)
{
head=(node*)malloc(sizeof(node));
current=(node*)malloc(sizeof(node));
for(uint8_t i=0;i<15;i++)
{
head->node_data[i]=arr[i];
}
head->next=current;
node_count++;
return;
}
else
{
for(uint8_t i=0;i<15;i++)
{
current->node_data[i]=arr[i];
}
current->next=(struct Node*)malloc(sizeof(struct Node));
current=current->next;
current->next=NULL;
node_count++;
pack_data();
return;
}
}
void pack_data()
{
/*this function converts node data into data format
* and sends the data to aws.*/
/* Once the data is send to aws ,
the memory allocated to nodes is freed
*/
delete_node(head);
return;
}
void delete_node(node* n)
{
node* m=NULL;
while(n!=NULL)
{
m=n->next;
free(n);
n=NULL;
n = m;
}
// return;
}
Whenever is am trying to free the dynamically allocated memory,the delete_node function causes problem.Throwing the following errors
ERROR 1
assert failed: multi_heap_realloc multi_heap_poisoning.c:289 (head != NULL)
ERROR 2
Guru Meditation Error: Core 1 panic'ed (LoadStoreError). Exception was unhandled.
Core 1 register dump:
PC : 0x400f3fc4 PS : 0x00060330 A0 : 0x800efca4 A1 : 0x3ffb1920
A2 : 0x00000000 A3 : 0x3ffcc800 A4 : 0x00000005 A5 : 0x00000000
A6 : 0x00000005 A7 : 0x40000014 A8 : 0x800f3ff4 A9 : 0x3ffb1910
A10 : 0x3ffcc800 A11 : 0x88000028 A12 : 0x00000000 A13 : 0x3ffcc800
A14 : 0x00000008 A15 : 0x00000000 SAR : 0x00000004 EXCCAUSE: 0x00000003
EXCVADDR: 0x4000001e LBEG : 0x40088f8c LEND : 0x40088fa2 LCOUNT : 0xffffffff

Guru Meditation Error: Core 0 panic'ed (LoadProhibited),(Interrupt wdt timeout on CPU1)

I was trying to record light intensity values for a Li-Fi project.
This is my code:
#include <soc/sens_reg.h>
#include <soc/sens_struct.h>
#include <driver/adc.h>
#include <SD.h>
#define ADC1_GPIO36_CHANNEL ADC1_CHANNEL_0
#include <adc_channel.h>
const char filename1[] = "/part1.dat";
const char filename2[] = "/part2.dat";
File file1, file2;
int local_adc1_read(int channel) {
uint16_t adc_value;
SENS.sar_meas_start1.sar1_en_pad = (1 << channel); // Only one channel is selected
while (SENS.sar_slave_addr1.meas_status != 0)
;
SENS.sar_meas_start1.meas1_start_sar = 0;
SENS.sar_meas_start1.meas1_start_sar = 1;
while (SENS.sar_meas_start1.meas1_done_sar == 0)
;
adc_value = SENS.sar_meas_start1.meas1_data_sar;
return adc_value;
}
#define ADC_SAMPLES_COUNT 1000
int16_t abuf[ADC_SAMPLES_COUNT];
int16_t abufPos = 0;
portMUX_TYPE DRAM_ATTR timerMux = portMUX_INITIALIZER_UNLOCKED;
TaskHandle_t complexHandlerTask;
hw_timer_t * adcTimer = NULL; // Our timer
void complexHandler(void *param) {
timerAlarmDisable(adcTimer);
timerDetachInterrupt(adcTimer);
timerEnd(adcTimer);
adcTimer = NULL;
file1 = SD.open(filename1, FILE_WRITE);
file2 = SD.open(filename2, FILE_WRITE);
file1.write((const byte*)abuf, abufPos);
file2.write((const byte*)abuf, abufPos);
file1.close();
file2.close();
}
int counter;
void IRAM_ATTR onTimer() {
portENTER_CRITICAL_ISR(&timerMux);
abuf[abufPos++] = local_adc1_read(ADC1_CHANNEL_0);
//abuf[abufPos++] = adc1_get_raw(ADC1_CHANNEL_0);
if (abufPos >= 8) {
if (abuf[abufPos-7] ==
abuf[abufPos-6] ==
abuf[abufPos-5] ==
abuf[abufPos-4] ==
abuf[abufPos-3] ==
abuf[abufPos-2] ==
abuf[abufPos-1] ==
abuf[abufPos])
{
// Notify adcTask that the buffer is full.
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
vTaskNotifyGiveFromISR(complexHandlerTask, &xHigherPriorityTaskWoken);
if (xHigherPriorityTaskWoken) {
portYIELD_FROM_ISR();
}
}
portEXIT_CRITICAL_ISR(&timerMux);
}
}
void setup() {
setCpuFrequencyMhz(240);
xTaskCreate(complexHandler, "Handler Task", 8192, NULL, 1, &complexHandlerTask);
adcTimer = timerBegin(3, 80, true); // 80 MHz / 80 = 1 MHz hardware clock for easy figuring
timerAttachInterrupt(adcTimer, &onTimer, true); // Attaches the handler function to the timer
timerAlarmWrite(adcTimer, 100, true); // Interrupts when counter == 45, i.e. 22.222 times a second
timerAlarmEnable(adcTimer);
Serial.begin(115200);
pinMode(2, OUTPUT);
//pinMode(36, INPUT);
if (!SD.begin())
Serial.println("SD begin failed");
while(!SD.begin()) {
Serial.print(".");
//delay(500);
SD.remove(filename1);
SD.remove(filename2);
}
}
void loop() {
}
I got this error:
Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled.
rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1100
load:0x40078000,len:10900
load:0x40080400,len:6388
entry 0x400806b4
Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled.
Core 0 register dump:
PC : 0x400f095f PS : 0x00060030 A0 : 0x800d1019 A1 : 0x3ffb3f80
A2 : 0x00000000 A3 : 0x3ffb2080 A4 : 0x00000020 A5 : 0x80000020
A6 : 0x00000000 A7 : 0x00000000 A8 : 0x00000005 A9 : 0x00000020
A10 : 0x00000020 A11 : 0x3ffbc0d0 A12 : 0x80087259 A13 : 0x3ffbc0d0
A14 : 0x00000000 A15 : 0x00000000 SAR : 0x00000000 EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000000 LBEG : 0x00000000 LEND : 0x00000000 LCOUNT : 0x00000000
ELF file SHA256: 0000000000000000
Backtrace: 0x400f095f:0x3ffb3f80 0x400d1016:0x3ffb3fa0 0x40088269:0x3ffb3fe0
I tried decreasing the interrupt frequency, using a huge app (3 MB), increasing the CPU clock to 240 Hz, but nothing changed.
By outcommenting
vTaskNotifyGiveFromISR(complexHandlerTask, &xHigherPriorityTaskWoken);
and
xTaskCreate(complexHandler, "Handler Task", 8192, NULL, 1, &complexHandlerTask);
now the error is
Guru Meditation Error: Core 1 panic'ed (Interrupt wdt timeout on CPU1)
And some register dumps of core 1 and core 0. There isn't any change doing something in the loop.

Why do I get an error like this in promela?

I am a beginner with promela and SPIN. I have a small code in promela but I do not understand why I have the error mentioned below:
chan config =[16] of {short};
bool get_type = false;
short car_type = 4;
active proctype control() {
start:
do
:: get_type == false ->
config!car_type;
printf("type sent");
:: printf("type not received");
od
}
active proctype robot() {
sleep:
config?car_type ->
get_type = true ;
printf("type received= %d", car_type);
}
Error:
using statement merging
1: proc 0, no matching stmnt 91
#processes: 2
1: proc 1 (robot:1) mytest.pml:16 (state 1)
1: proc 0 (control:1) mytest.pml:7 (state 5)
2 processes created
Exit-Status 0

How do I get the currently connected network interface name using Cocoa or Foundation?

I need to know the network interface name of the currently connected network interface, as in en0, lo0 and so on.
Is there a Cocoa/Foundation function that is going to give me this information?
You can cycle through network interfaces and get their names, IP addresses, etc.
#include <ifaddrs.h>
// you may need to include other headers
struct ifaddrs* interfaces = NULL;
struct ifaddrs* temp_addr = NULL;
// retrieve the current interfaces - returns 0 on success
NSInteger success = getifaddrs(&interfaces);
if (success == 0)
{
// Loop through linked list of interfaces
temp_addr = interfaces;
while (temp_addr != NULL)
{
if (temp_addr->ifa_addr->sa_family == AF_INET) // internetwork only
{
NSString* name = [NSString stringWithUTF8String:temp_addr->ifa_name];
NSString* address = [NSString stringWithUTF8String:inet_ntoa(((struct sockaddr_in *)temp_addr->ifa_addr)->sin_addr)];
NSLog(#"interface name: %#; address: %#", name, address);
}
temp_addr = temp_addr->ifa_next;
}
}
// Free memory
freeifaddrs(interfaces);
There are many other flags and data in the above structures, I hope you will find what you are looking for.
Since iOS works slightly differently to OSX, we had luck using the following code based on Davyd's answer to see the names of all available network interfaces on an iPhone: (also see here for full documentation on ifaddrs)
#include <ifaddrs.h>
struct ifaddrs* interfaces = NULL;
struct ifaddrs* temp_addr = NULL;
// retrieve the current interfaces - returns 0 on success
NSInteger success = getifaddrs(&interfaces);
if (success == 0)
{
// Loop through linked list of interfaces
temp_addr = interfaces;
while (temp_addr != NULL)
{
NSString* name = [NSString stringWithUTF8String:temp_addr->ifa_name];
NSLog(#"interface name: %#", name);
temp_addr = temp_addr->ifa_next;
}
}
// Free memory
freeifaddrs(interfaces);
Alternatively you can also utilize if_indextoname() to get available interface names. Here is how Swift implementation would look like:
public func interfaceNames() -> [String] {
let MAX_INTERFACES = 128;
var interfaceNames = [String]()
let interfaceNamePtr = UnsafeMutablePointer<Int8>.alloc(Int(IF_NAMESIZE))
for interfaceIndex in 1...MAX_INTERFACES {
if (if_indextoname(UInt32(interfaceIndex), interfaceNamePtr) != nil){
if let interfaceName = String.fromCString(interfaceNamePtr) {
interfaceNames.append(interfaceName)
}
} else {
break
}
}
interfaceNamePtr.dealloc(Int(IF_NAMESIZE))
return interfaceNames
}
Ported the sample code of #ambientlight to iOS 13:
public func interfaceNames() -> [String] {
let MAX_INTERFACES = 128;
var interfaceNames = [String]()
let interfaceNamePtr = UnsafeMutablePointer<Int8>.allocate(capacity: Int(Int(IF_NAMESIZE)))
for interfaceIndex in 1...MAX_INTERFACES {
if (if_indextoname(UInt32(interfaceIndex), interfaceNamePtr) != nil){
let interfaceName = String(cString: interfaceNamePtr)
interfaceNames.append(interfaceName)
} else {
break
}
}
interfaceNamePtr.deallocate()
return interfaceNames
}
Most likely leaking memory - Use with caution.
Output:
▿ 20 elements
- 0 : "lo0"
- 1 : "pdp_ip0"
- 2 : "pdp_ip1"
- 3 : "pdp_ip2"
- 4 : "pdp_ip3"
- 5 : "pdp_ip5"
- 6 : "pdp_ip4"
- 7 : "pdp_ip6"
- 8 : "pdp_ip7"
- 9 : "ap1"
- 10 : "en0"
- 11 : "en1"
- 12 : "en2"
- 13 : "ipsec0"
- 14 : "ipsec1"
- 15 : "ipsec2"
- 16 : "ipsec3"
- 17 : "awdl0"
- 18 : "utun0"
- 19 : "utun1"

How to generate flipped text like this - ʍoႨɟɹәʌoʞɔɐʇs

I want to make a script which can flip the text upside down like if I type
stackoverflow it should make it to - ʍoႨɟɹәʌoʞɔɐʇs.
Many sites do this like this one link text and this one link text
JavaScript Code. It will be easy to convert this code to Java or C#
function flip() {
var result = flipString(document.f.original.value.toLowerCase());
document.f.flipped.value = result;
}
function flipString(aString) {
var last = aString.length - 1;
var result = new Array(aString.length)
for (var i = last; i >= 0; --i) {
var c = aString.charAt(i)
var r = flipTable[c]
result[last - i] = r != undefined ? r : c
}
return result.join('')
}
var flipTable = {
a : '\u0250',
b : 'q',
c : '\u0254', //open o -- from pne
d : 'p',
e : '\u01DD',
f : '\u025F', //from pne
g : '\u0183',
h : '\u0265',
i : '\u0131', //from pne
j : '\u027E',
k : '\u029E',
//l : '\u0283',
m : '\u026F',
n : 'u',
r : '\u0279',
t : '\u0287',
v : '\u028C',
w : '\u028D',
y : '\u028E',
'.' : '\u02D9',
'[' : ']',
'(' : ')',
'{' : '}',
'?' : '\u00BF', //from pne
'!' : '\u00A1',
"\'" : ',',
'<' : '>',
'_' : '\u203E',
';' : '\u061B',
'\u203F' : '\u2040',
'\u2045' : '\u2046',
'\u2234' : '\u2235'
}
for (i in flipTable) {
flipTable[flipTable[i]] = i
}