當前位置:首頁 » 操作系統 » linuxiff

linuxiff

發布時間: 2022-06-10 10:20:35

1. 如何偽造tcp數據包,並進行正確的校驗的例子演示及源碼linux gc

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
下面的程序是在linux下進行tcp偽造的一個例子:涉及原始套接字和tcp的校驗演算法

/************************tcp_pseudo.c********************/
/** Author :cbchen. */
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define INTERFACE "eth0"
#define IP ""
/*Prototype area*/
int Open_Packet_Socket();
int Open_Raw_Socket();
int Set_Promisc(char *interface, int sock);
void send_tcp_ack(int sockfd,struct sockaddr_in *addr);
unsigned short check_sum(unsigned short *addr,int len);
struct ip *iprecv;
struct tcphdr *tcprecv;
struct sockaddr_in addr;

int main()
{
int sockfd,sendfd,bytes_recieved;

char buffer[1518];
u_char *buf2;
char saddr[20],daddr[20];

sockfd=Open_Packet_Socket();
sendfd=Open_Raw_Socket();
//printf("sockfd:%d/tsendfd:%d/n",sockfd,sendfd);

int on=1;
/******** 設置IP數據包格式,告訴系統內核模塊IP數據包由我們自己來填寫 ***/
setsockopt(sendfd,IPPROTO_IP,IP_HDRINCL,&on,sizeof(on));
Set_Promisc(INTERFACE, sockfd);
int count=1;

while(1)
{

bytes_recieved = recvfrom(sockfd, buffer, 1518, 0, NULL, NULL);

buf2=buffer;
buf2+=14;
iprecv=(struct ip *)buf2;
//iprecv+=sizeof(struct ethhdr*);
/*See if this is a TCP packet*/
if(iprecv->ip_v == 4&iprecv->ip_p == 6) {
printf("---------------------------Number %d packet-----------------------------------------------/n",count);
count++;
printf("/nBytes received ::: %5d/n",bytes_recieved);
printf("ip version:%u/n",iprecv->ip_v);

printf("IP包頭解碼:/n");
printf("Source ip:%s/t",inet_ntoa(iprecv->ip_src));
printf("Dest ip:%s/t",inet_ntoa(iprecv->ip_dst));
printf("proto:%u/n",iprecv->ip_p);
buf2+=iprecv->ip_hl<<2;
printf("TCP包頭解碼:/n");
tcprecv = (struct tcphdr*)buf2;
//tcprecv = (struct tcphdr *)(buffer + (iprecv->ip_hl<<2));
printf("Source port :::%d/n",ntohs(tcprecv->source));
printf("Dest port :::%d/n",ntohs(tcprecv->dest));
printf("seq num:%u/n",ntohl(tcprecv->seq));
printf("ack num:%u/n",ntohl(tcprecv->ack_seq));
printf("urg:%x/tack:%x/tpsh:%x/trst:%x/tsyn:%x/tfin:%x/n",tcprecv->urg,tcprecv->ack,tcprecv->psh,tcprecv->rst,tcprecv->syn,tcprecv->fin);
bzero(&addr,sizeof(struct sockaddr_in));
addr.sin_family=AF_INET;
//addr2.sin_port=htons(thdr->source);
addr.sin_port=tcprecv->source;
//addr2.sin_addr=iphdr->ip_src;
addr.sin_addr=iprecv->ip_src;

/********* 發送阻隔包了!!!! ****/
if(tcprecv->syn==1&tcprecv->urg!=1&tcprecv->ack!=1&tcprecv->psh!=1&tcprecv->rst!=1&tcprecv->fin!=1)
{
//send_tcp_ack(sendfd,&addr);
//printf("It's a syn pocket!/n");
}
}
}
close(sockfd);
close(sendfd);
}
//end main

/******* 發送阻隔包的實現 *********/
/*
void send_tcp_ack(int sockfd,struct sockaddr_in *addr)
{
struct send_tcp
{
struct iphdr ip;
struct tcphdr tcp;
} send_tcp;

struct pseudo_header
{
unsigned int source_address;
unsigned int dest_address;
unsigned char placeholder;
unsigned char protocol;
unsigned short tcp_length;
struct tcphdr tcp;
} pseudo_header;

int tcp_socket;
struct sockaddr_in sin;
int sinlen;

// form ip packet
send_tcp.ip.ihl = 5;
send_tcp.ip.version = 4;
send_tcp.ip.tos = 0;
send_tcp.ip.tot_len = htons(40);
send_tcp.ip.frag_off = 0;
send_tcp.ip.ttl = 64;
send_tcp.ip.protocol = IPPROTO_TCP;
send_tcp.ip.check = 0;
send_tcp.ip.saddr = iprecv->ip_dst.s_addr;
send_tcp.ip.daddr = addr->sin_addr.s_addr;

// form tcp packet
send_tcp.tcp.dest = addr->sin_port;
send_tcp.tcp.source = tcprecv->dest;
send_tcp.tcp.ack_seq = htonl(ntohl(tcprecv->seq)+0x01);
send_tcp.tcp.res1 = 0;
send_tcp.tcp.doff = 5;
send_tcp.tcp.fin = 0;
send_tcp.tcp.syn = 1;
send_tcp.tcp.rst = 0;
send_tcp.tcp.psh = 0;
send_tcp.tcp.ack = 1;
send_tcp.tcp.urg = 0;
send_tcp.tcp.res2 = 0;
send_tcp.tcp.window = htons(512);
send_tcp.tcp.check = 0;
send_tcp.tcp.urg_ptr = 0;
send_tcp.tcp.seq = tcprecv->seq;

// set fields that need to be changed
//send_tcp.tcp.source++;
send_tcp.ip.id = 0 ;
//send_tcp.tcp.seq++;
send_tcp.tcp.check = 0;
send_tcp.ip.check = 0;

// calculate the ip checksum
send_tcp.ip.check = in_cksum((unsigned short *)&send_tcp.ip, 20);

// set the pseudo header fields
pseudo_header.source_address = send_tcp.ip.saddr;
pseudo_header.dest_address = send_tcp.ip.daddr;
pseudo_header.placeholder = 0;
pseudo_header.protocol = IPPROTO_TCP;
pseudo_header.tcp_length = htons(20);
b((char *)&send_tcp.tcp, (char *)&pseudo_header.tcp, 20);
send_tcp.tcp.check = in_cksum((unsigned short *)&pseudo_header, 32);
sinlen = sizeof(sin);
int count;
for(count=0;count<2;count++){
if(sendto(sockfd, &send_tcp, 40, 0, (struct sockaddr *)addr,sizeof(struct sockaddr))<0)
{
printf("sendto error!/n");
}
else
{
printf("send packet ok!/n");
}

}
*/

/* 下面是首部校驗和的演算法 */
unsigned short in_cksum(unsigned short *addr, int len) /* function is from ping.c */
{
register int nleft = len;
register u_short *w = addr;
register int sum = 0;
u_short answer =0;

while (nleft > 1)
{
sum += *w++;
nleft -= 2;
}
if (nleft == 1)
{
*(u_char *)(&answer) = *(u_char *)w;
sum += answer;
}
sum = (sum >> 16) + (sum & 0xffff);
sum += (sum >> 16);
answer = ~sum;
return(answer);
}
int Open_Packet_Socket()
{
int sock;
sock=socket(AF_INET,SOCK_PACKET,htons(ETH_P_ALL));
if (sock==-1)
{
perror("socket");
exit(errno);
}
printf("sockfd:%d/n",sock);
return(sock);
}
int Open_Raw_Socket()
{
int sock;
sock=socket(AF_INET,SOCK_RAW,IPPROTO_TCP);
if (sock==-1)
{
perror("socket");
exit(errno);
}
printf("sendfd:%d/n",sock);
return(sock);
}

int Set_Promisc(char *interface, int sockfd )
{
struct ifreq ifr;
strncpy(ifr.ifr_name,interface,strnlen(interface)+1);
if (ioctl(sockfd,SIOCGIFFLAGS,&ifr)==-1)
{
perror("ioctl1");
exit(errno);
}
ifr.ifr_flags |= IFF_PROMISC;
if (ioctl(sockfd,SIOCSIFFLAGS,&ifr))
{
perror("ioctl2");
exit(errno);
}

// printf("Setting interface ::: %s ::: to promisc...ok..../n", interface);
return(1);
}

2. 混雜模式的linux下通過C設置混雜模式(以eth0舉例)

char *eth_name = eth0; //對網卡eth0進行混雜設置
struct ifreq ethreq; //網路介面結構
strncpy(ethreq.ifr_name, eth_name, IFNAMSIZ); //指定網卡名稱if(-1 == ioctl(sock_raw_fd, SIOCGIFFLAGS, &ethreq)) //獲取網路介面{perror(ioctl);close(sock_raw_fd);exit(-1);}
/*此處用 | 是因為必須在保留原來設置的情況下,在標志位中加入「混雜」方式*/ ethreq.ifr_flags |= IFF_PROMISC;if(-1 == ioctl(sock_raw_fd, SIOCSIFFLAGS, &ethreq)) //將標志位設置寫入{perror(ioctl);close(sock_raw_fd);exit(-1);}

3. linux下裡面如何獲取網卡的實時網速

#include <time.h>
#include "tspeed.h"
int main ()
{
struct if_speed ndev;
int ret = 0;
bzero(&ndev,sizeof(ndev));
sprintf(ndev.ifs_name,"eth0");
ndev.ifs_us = 100000;
printf("Get %s Speed",ndev.ifs_name);
#if 1
ret = get_if_speed(&ndev);
if(ret < 0)
printf("[Fail]\n");
else
printf("[OK]\n");
float ispeed ,ospeed;
while(1){
time_t *timep = malloc(sizeof(*timep));
time(timep);
char *s = ctime(timep);
ispeed = ndev.ifs_ispeed * 1.0/(ndev.ifs_us/1000 * 0.001);
ospeed = ndev.ifs_ospeed * 1.0/(ndev.ifs_us/1000 * 0.001);
#if 0
printf("%s: Up Speed: %fMB/s || Down Speed: %fMB/s\r",
ndev.ifs_name,ispeed/(1024.0*1024.0),ospeed/(1024.0*1024.0));
#endif
sleep(3);
#if 1
printf("*****************************************************\n");
printf("*****************************************\n");
printf("***************************\n");
printf("*************\n");
printf("Time is %s || Down Speed: %fKB/s\n",s,ospeed/(1024.0));
#endif
get_if_speed(&ndev);
}
#endif
return 0;
} /* ----- End of main() ----- */
----------------------------------------------------------------------------
#include "tspeed.h"
int get_if_dbytes(struct if_info* ndev)
{
assert(ndev);
struct ifaddrs *ifa_list = NULL;
struct ifaddrs *ifa = NULL;
struct if_data *ifd = NULL;
int ret = 0;
ret = getifaddrs(&ifa_list);
if(ret < 0) {
perror("Get Interface Address Fail:");
goto end;
}
for(ifa=ifa_list; ifa; ifa=ifa->ifa_next){
if(!(ifa->ifa_flags & IFF_UP) && !(ifa->ifa_flags & IFF_RUNNING))
continue;
if(ifa->ifa_data == 0)
continue;
ret = strcmp(ifa->ifa_name,ndev->ifi_name);
if(ret == 0){
ifd = (struct if_data *)ifa->ifa_data;
ndev->ifi_ibytes = ifd->ifi_ibytes;
ndev->ifi_obytes = ifd->ifi_obytes;
break;
}
}
freeifaddrs(ifa_list);
end:
return (ret ? -1 : 0);
}
int get_if_speed(struct if_speed *ndev)
{
assert(ndev);
struct if_info *p1=NULL,*p2=NULL;
p1 = (struct if_info *)malloc(sizeof(struct if_info));
p2 = (struct if_info *)malloc(sizeof(struct if_info));
bzero(p1,sizeof(struct if_info));
bzero(p2,sizeof(struct if_info));
strncpy(p1->ifi_name,ndev->ifs_name,strlen(ndev->ifs_name));
strncpy(p2->ifi_name,ndev->ifs_name,strlen(ndev->ifs_name));
int ret = 0;
ret = get_if_dbytes(p1);
if(ret < 0) goto end;
usleep(ndev->ifs_us);
ret = get_if_dbytes(p2);
if(ret < 0) goto end;
ndev->ifs_ispeed = p2->ifi_ibytes - p1->ifi_ibytes;
ndev->ifs_ospeed = p2->ifi_obytes - p1->ifi_obytes;
end:
free(p1);
free(p2);
return 0;
}
------------------------------------------
#ifndef __TSPEED_H__
#define __TSPEED_H__

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <error.h>
#include <ifaddrs.h>
#include <net/if.h> /* for ifconf */
#include <linux/sockios.h> /* for net status mask */
#include <netinet/in.h> /* for sockaddr_in */
#include <sys/socket.h>
#include <sys/ioctl.h>
/* For "open" function */
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
struct if_data
{
/* generic interface information */
u_long ifi_opackets; /* packets sent on interface */
u_long ifi_ipackets; /* packets received on interface */
u_long ifi_obytes; /* total number of octets sent */
u_long ifi_ibytes; /* total number of octets received */
};

struct if_info
{
char ifi_name[16];
unsigned long ifi_ibytes;
unsigned long ifi_obytes;
};
struct if_speed
{
char ifs_name[16];
unsigned long ifs_ispeed;
unsigned long ifs_ospeed;
unsigned long ifs_us;
};
int get_if_dbytes(struct if_info *ndev);
int get_if_speed(struct if_speed *ndev);
#endif
------------------------
純手打 代碼都給你了

4. linux 3.10 kernel bridge 泛洪包會發到包的入口介面上嗎

網橋介面的混雜模式取決於三個因素,一個是自身的混雜模式設置;第二是vlan過濾是否開啟;最後是處於自動狀態(auto_port)的子介面的數量。網橋的混雜模式管理函數br_manage_promisc如下:
void br_manage_promisc(struct net_bridge *br)
{
if ((br->dev->flags & IFF_PROMISC) || !br_vlan_enabled(br))
set_all = true;

list_for_each_entry(p, &br->port_list, list) {
if (set_all) {
br_port_set_promisc(p);
} else {
if (br->auto_cnt == 0 ||
(br->auto_cnt == 1 && br_auto_port(p)))
br_port_clear_promisc(p);
else
br_port_set_promisc(p);
}
}
}
混雜模式設置
如下通過命令設置網橋br_2為混雜模式,此時,所有網橋子介面都將處於混雜模式(eth1與eth2 promiscuity mode):
ip link add br_2 type bridge
ip link set eth1 master br_2
ip link set eth2 master br_2
通過ip命令設置介面的混雜模式:
ip link set br_2 promisc on
或者ioctl系統調用設置混雜模式:
int set_bridge_promiscuity(void)
{
sockfd = socket(AF_INET, SOCK_DGRAM, 0);

strncpy(ifr.ifr_name, "br_2", IFNAMSIZ);
ioctl(sockfd, SIOCGIFFLAGS, &ifr);

ifr.ifr_flags |= IFF_PROMISC;
ioctl(sockfd, SIOCSIFFLAGS, &ifr);
}
VLAN過濾
如果網橋的VLAN filtering過濾功能沒有開啟,即使網橋沒有設置混雜模式,也需開啟所有子介面的混雜模式。
/sys/devices/virtual/net/br_2/bridge/vlan_filtering
自動狀態介面AUTO_PORT
內核中對自動狀態介面的定義如下,即設置了學習(learning)或者單播泛洪(flood)標志的介面。
#define BR_AUTO_MASK (BR_FLOOD | BR_LEARNING)
#define br_auto_port(p) ((p)->flags & BR_AUTO_MASK)
可通過bridge或者ip命令設置網橋介面的flood/learning等標志:
bridge link set dev eth1 flood on/off
bridge link set dev eth1 learning on/off
ip link set dev eth1 type bridge_slave flood on/off
ip link set dev eth1 type bridge_slave learning on/off
網橋添加網路設備時,新介面的flags賦值為BR_LEARNING與BR_FLOOD標志,即新介面為自動狀態介面。
static struct net_bridge_port *new_nbp(struct net_bridge *br, struct net_device *dev)
{
struct net_bridge_port *p;
p->flags = BR_LEARNING | BR_FLOOD;
}
BR_LEARNING標志,在函數br_handle_frame_finish中判斷,用來決定是否使用數據包的源MAC地址更新網橋的FDB轉發表。
int br_handle_frame_finish(struct net *net, struct sock *sk, struct sk_buff *skb)
{
struct net_bridge_port *p = br_port_get_rcu(skb->dev);
struct net_bridge *br;

br = p->br;
if (p->flags & BR_LEARNING)
br_fdb_update(br, p, eth_hdr(skb)->h_source, vid, false);
}
BR_FLOOD標志用來控制是否在介面上泛洪單播數據包,如果沒有設置此標志,不能在此介面泛洪單播包。
void br_flood(struct net_bridge *br, struct sk_buff *skb, ...)
{
struct net_bridge_port *p;

list_for_each_entry_rcu(p, &br->port_list, list) {
switch (pkt_type) {
case BR_PKT_UNICAST:
if (!(p->flags & BR_FLOOD))
continue;
break;
}
網橋結構體中保存了自動狀態介面的數量auto_cnt,在向網橋添加介面或者刪除介面的時候,調用nbp_update_port_count更新自動狀態介面的數量。通過遍歷網橋的介面列表,獲取自動介面數量。
static void nbp_update_port_count(struct net_bridge *br)
{
struct net_bridge_port *p;
u32 cnt = 0;

list_for_each_entry(p, &br->port_list, list) {
if (br_auto_port(p))
cnt++;
}
if (br->auto_cnt != cnt) {
br->auto_cnt = cnt;
br_manage_promisc(br);
}
}
所謂非自動介面,即此介面不自動學習數據包的源MAC地址,或者不泛洪單播包。對於此類介面,要正常轉發報文,必須靜態指定其在FDB轉發表中的轉發表項。由上文br_manage_promisc函數中的條件判斷可知,當網橋下都是非自動介面時(auto_cnt=0),關閉混雜模式,因為此時所有介面都已經配置好了轉發表項,不需要混雜模式。當只有一個介面時自動介面的時候,從這個介面接收到的數據包無非是要轉發到系統剩餘的其它介面,而其它介面都是非自動的,這就反向決定了此自動介面的轉發路徑也被確定下了,此時也不需要混雜模式。
所以當自動介面大於1時,開啟混雜模式。
更多Linux信息可參考《Linux就該這么學》

5. 我在虛擬機下安裝 linux 出現錯誤,安裝不了,出現以下錯誤!怎麼解決啊!

它的安裝說是就是./setup
不過它說unix下的
我在freebsd也試了一下,還是不行
應該是腳本來的吧
#!/bin/sh -f
#=============================================================
# MODIFICATIONS
# ---------------------------------------------------------
# 06-Oct-97 $$1 JJE Created.
# 28-Oct-97 $$2 JJE Use -dirs
# 05-Dec-97 $$3 JJE Remove -vrdirs, set LC_NUMERIC to C
# 22-Dec-97 $$4 JJE Check DISPLAY
# 05-Jan-98 $$5 JJE ignore
# 13-Jan-98 $$6 JJE Use delta lib
# 22-Jan-98 $$7 JJE Add . to path on sgi
# 23-Jan-98 $$8 JJE Add startup messages
# 27-Jan-98 $$9 JJE Add cr
# 31-Jan-98 $$10 JJE Don't echo argv
# 23-Feb-98 $$11 ZRL Added remote install
# 06-Apr-98 $$12 JJE Add sgi_mips4
# 22-Jun-98 $$13 ZRL removed galaxy library
# 29-Jun-98 ##14 ZRL use galaxy library only on sgi_elf2
# 11-Aug-98 $$14 JJE Fix remote install for mips4
# 22-Oct-98 $$15 TWH Fixed remote install
# 11-Nov-98 TWH Fixed cleanup
# 20-Nov-98 $$16 TWH Fixed Trusted login check for Sun
# 08-Sep-99 $$17 JJE Migrate to new installer
# 20-Oct-99 $$18 MYA Add DPS_DIRECTORY
# 07-Aug-00 TWH Check if hpux11_pa32 exists
# 22-Aug-00 $$19 TWH rewritten to /bin/sh for multicd
# 18-Sep-00 $$20 TWH support non \c echo; -multicd iff using redirect
# 09-Oct-00 $$21 TWH Fix command-line args; fix PROSETUP_EXE bug
# 31-Oct-00 $$22 TWH Fix for $0 == "setup"
# 17-Jan-01 $$23 TWH always run sun4_solaris instead of _64 this script
# 16-May-01 $$24 TWH always run hpux11_pa32 instead of hpux_pa64
# 13-Jun-02 $$25 JJE Support -64 arg
# 16-Jul-02 $$26 TWH Set TMP & TEMP if not set
# 20-Aug-02 $$27 TWH Fix #26
# 26-Aug-02 $$28 TWH Another fix for #26
#=============================================================

rundir=`pwd`
fullscrname=$0
# :t
scrname=`echo $fullscrname | awk -F"/" '{ print $NF}'`
# :h
fullscrpath=`echo $fullscrname | awk -F"/" '{ ORS="/"} { n=split($0,A)} { for (i = 1; i < n; i++) print A[i] }'`
if [ "$fullscrpath" = "" ]
then
fullscrpath=$0
else
fullscrpath=`echo $fullscrpath | awk '{ n=length($0)} { n -= 1} { print substr($0,1,n)}'`
fi

if [ "$fullscrpath" = "$fullscrname" ]
then
fullscrpath=`pwd`
else
cd $fullscrpath
fullscrpath=`pwd`
fi

echostr=`echo "test \c"`
if [ "$echostr" = "test \c" ]
then
alt_echo=true
fi

bit_mode_64=false
other_args=""
i=1
while [ "$i" -le $# ]
do
if [ "$1" = "-display" ]
then
shift
echo "setting DISPLAY to: $1"
DISPLAY="$1"
export DISPLAY
shift
elif [ "$1" = "?" -o "$1" = "-h" -o "$1" = "-help" ]
then
echo ""
echo "Usage: $scrname [ -display unix:0 ]"
exit 0
elif [ "$1" = "-remote" ]
then
echo ""
echo "Sorry, remote installation is not supported in this release."
exit 1
elif [ "$1" = "-cdrom" ]
then
shift
echo "setting CDROM path to: $1"
fullscrpath="$1"
shift
elif [ "$1" = "-64" ]
then
shift
bit_mode_64=true
else
other_args="$other_args $1"
shift
fi
done

cd $rundir
prodir=$fullscrpath
imagedir=$fullscrpath
getpmtscr="getpmt.csh"

if [ ! -x "$imagedir/$getpmtscr" ]
then
echo ""
echo "ERROR: $imagedir/$getpmtscr - file is missing."
echo " Check the name of the CD mount directory."
exit 1
fi

mctype=`$imagedir/$getpmtscr`
if [ "$mctype" = "UNKNOWN" ]
then
echo ""
echo "ERROR: OS name unknown."
exit 1
fi

test "$TMP"
if [ $? != 0 ]
then
if [ -x "/tmp" ]
then
TMP="/tmp"
export TMP
elif [ -x "/var/tmp" ]
then
TMP="/var/tmp"
export TMP
fi
fi
test "$TEMP"
if [ $? != 0 ]
then
if [ -x "/tmp" ]
then
TEMP="/tmp"
export TEMP
elif [ -x "/var/tmp" ]
then
TEMP="/var/tmp"
export TEMP
fi
fi
test "$DISPLAY"
if [ $? != 0 ]
then
echo ""
echo 'ERROR: The DISPLAY variable is not set - '
echo ""
echo " Options:"
echo " o Press <cr> to set DISPLAY to `hostname`:0.0"
echo " o Type a value to use for the DISPLAY variable"
echo " o Enter 'q' to abort prosetup"
echo " o Specify '-display <host>:0' on the command line"
echo ""
test "$alt_echo"
if [ $? = 0 ]
then
echo -n "Set it to (`hostname`:0.0): [q to abort] "
else
echo "Set it to (`hostname`:0.0): [q to abort] \c"
fi
read line
if [ "$line" = "q*" -o "$line" = "Q*" ]
then
exit -1
elif [ "$line" = "" ]
then
DISPLAY="`hostname`:0.0"
export DISPLAY
else
DISPLAY="$line"
export DISPLAY
fi
echo ""
echo " DISPLAY has been set to: $DISPLAY"
echo ""
fi

echo ""
test "$alt_echo"
if [ $? = 0 ]
then
echo -n "Starting PTC.Setup, please wait ..."
else
echo "Starting PTC.Setup, please wait ...\c"
fi

if [ "$mctype" = "sun4_solaris_64" -a "$bit_mode_64" = "false" ]
then
mctype="sun4_solaris"
fi
if [ "$mctype" = "sun4_solaris" ]
then
PATH=$PATH:/usr/ucb
export PATH
fi

if [ "$mctype" = "sgi_elf2" -o "$mctype" = "sgi_mips4" ]
then
PATH=.:$PATH
export PATH
fi
if [ "$mctype" = "hpux_pa64" -a "$bit_mode_64" = "false" ]
then
mctype="hpux11_pa32"
fi
if [ "$mctype" = "hpux11_pa32" ]
then
if [ ! -d "$imagedir/dsrc/$mctype" ]
then
mctype="hp8k"
fi
fi

PTC_CDHOME=$imagedir
export PTC_CDHOME
PS_DIRECTORY=$imagedir/dsrc
export PS_DIRECTORY
DPS_DIRECTORY=$imagedir/dsrc
export DPS_DIRECTORY
PRO_MACHINE_TYPE=$mctype
export PRO_MACHINE_TYPE
LC_NUMERIC=C
export LC_NUMERIC

test "$PROSETUP_EXE"
if [ $? != 0 ]
then
PROSETUP_EXE="$imagedir/dsrc/$mctype/obj/ptcsetup"
elif [ -x "$PROSETUP_EXE" ]
then
echo ""
test "$alt_echo"
if [ $? = 0 ]
then
echo -n "Using $PROSETUP_EXE ..."
else
echo "Using $PROSETUP_EXE ...\c"
fi
($PROSETUP_EXE $other_args ) &
exit 0
fi

if [ ! -x "$PROSETUP_EXE" ]
then
echo ""
echo "ERROR: $PROSETUP_EXE - file is missing."
echo " Check the name of the CD mount directory."
exit 1
fi

REDIRECT_EXE="$imagedir/dsrc/$mctype/obj/redirect"
if [ -x "$REDIRECT_EXE" ]
then
($REDIRECT_EXE $other_args -multicd ) &
else
($PROSETUP_EXE $other_args ) &
fi

echo ""
exit 0

6. 誰知道在linux下的常用後綴名啊

在Linux系統中,可執行文件沒有統一的後綴,系統從文件的屬性來區分可執行文件和不可執行文件。而gcc則通過後綴來區別輸入文件的類別,下面我們來介紹gcc所遵循的部分約定規則。
.c為後綴的文件,c語言源代碼文件;
.a為後綴的文件,是由目標文件構成的檔案庫文件;
.C,.cc或.cxx 為後綴的文件,是C++源代碼文件;
.h為後綴的文件,是程序所包含的頭文件;
.i 為後綴的文件,是已經預處理過的C源代碼文件;
.ii為後綴的文件,是已經預處理過的C++源代碼文件;
.m為後綴的文件,是Objective-C源代碼文件;
.o為後綴的文件,是編譯後的目標文件;
.s為後綴的文件,是匯編語言源代碼文件;
.S為後綴的文件,是經過預編譯的匯編語言源代碼文件。

7. 如何搭建基於Linux系統桌面環境的影音平台

視頻、音頻的處理加工一直是計算機在多媒體方面的重要應用,傳統上是 Unix 工作站的天下。由於 Linux 是 Unix 操作系統的變體,從某種程度上說,它天生適用於圖形市場。目前已有一大部分市場被 Linux 工作站所瓜分了。Linux 成為 Unix 系統在個人計算機上的一個代用品,並能用於替代那些較為昂貴的系統。因此,在家中使用 Linux 就能夠完成一些工作任務。本文就介紹一下在家裡就可以建立的一個基於 Linux 桌面環境的影音工作站。

MainActor 是一個處理視頻、音頻的優秀軟體,具有極好的動畫視頻格式轉換編輯剪接工具,並自帶編輯功能 AVI<-->MPG、MPG<-->AVI、動畫序列等。它可以用於許多文件格式的互相轉換,帶很多濾鏡,其中支持的文件格式包括 AVI、FLI、FLC、JPEG、MOV、TGA、GIF、MPEG-Ⅰ/Ⅱ等。目前最新的版本可以直接捕捉、處理數碼攝像機的信號。

由於處理視頻、音頻對於計算機的中央處理器、顯示系統、存儲系統等要求較高,所以應盡量提供一些高性能的硬體系統。下面就以我的硬體配置為例,介紹如何搭建影音平台。硬體配置:中央處理器為 AMD Duron 1.1G,內存為 256MB SDAM ,顯示卡為 nVIDIA GeForce2 MX 32MB,音效卡為創新 PCI 128 數碼版,硬碟為希捷酷魚三代 20GB(7200轉,2MB 緩存)。為了提高工作效率,在搭建基於 Linux 桌面環境的平台時要盡量提供高性能的硬體系統。

軟體下載與准備工作

1. 軟體下載

MainActor 軟體可以在它的主頁下載。地址:

2. 系統要求

軟體要求內核(Kenerl)至少在 2.4 以上。KDE 2.0,Window System XFree86 4.03,桌面解析度至少為800×600,桌面顏色至少 16 位增強色。

硬體中央處理器為奔騰Ⅲ450MHz 以上,內存為 128 MB,硬碟空間為 600MB,OSS/Linux 兼容音效卡,16MB 顯示內存。

3. 准備工作

由於工作時需要使用 zlib、Qt、gtk 及 libpng 函數,因此安裝前一定要檢查計算機中是否已經含有下列的軟體:zlib (zlib-1.1.3-xx以上) 、Qt (Qt-2.0.xx以上)、libpng gtk。可以使 rpm 分別來確認:

rpm -qa | grep gtk

rpm -qa | grep zlib

rpm -qa | grep qt

rpm -qa | grep libpng

檢測結果見圖 1 所示。

圖 7 預覽剛生成的新文件

◆ 預覽結束後,如果沒有問題就單擊 「File」 選單的 「Save」 選項,將文件以一個工程方式(Project)保存到一個文件夾中。

Linux 是一個真正的搶占式多任務、多線程、多用戶的操作系統,它構建影音平台在成本、技術上都有優勢。通過介紹 MainActor 中 mave、maseg 兩個主要軟體模塊的使用,基本上可以在 Linux 桌面環境上建立了一個低成本的影音工作平台。

8. linux 里通過想寫一個c語言的文件 ,通過執行文件可以修改ifcfg-eth0中的IPADDR的值

//獲取本機IP地址函數

view plain to clipboardprint?
01.QString GetLocalIp()
02.{
03.
04. int sock_get_ip;
05. char ipaddr[50];
06.
07. struct sockaddr_in *sin;
08. struct ifreq ifr_ip;
09.
10. if ((sock_get_ip=socket(AF_INET, SOCK_STREAM, 0)) == -1)
11. {
12. printf("socket create failse...GetLocalIp!\n");
13. return "";
14. }
15.
16. memset(&ifr_ip, 0, sizeof(ifr_ip));
17. strncpy(ifr_ip.ifr_name, "eth0", sizeof(ifr_ip.ifr_name) - 1);
18.
19. if( ioctl( sock_get_ip, SIOCGIFADDR, &ifr_ip) < 0 )
20. {
21. return "";
22. }
23. sin = (struct sockaddr_in *)&ifr_ip.ifr_addr;
24. strcpy(ipaddr,inet_ntoa(sin->sin_addr));
25.
26. printf("local ip:%s \n",ipaddr);
27. close( sock_get_ip );
28.
29. return QString( ipaddr );
30.}
QString GetLocalIp()
{

int sock_get_ip;
char ipaddr[50];

struct sockaddr_in *sin;
struct ifreq ifr_ip;

if ((sock_get_ip=socket(AF_INET, SOCK_STREAM, 0)) == -1)
{
printf("socket create failse...GetLocalIp!\n");
return "";
}

memset(&ifr_ip, 0, sizeof(ifr_ip));
strncpy(ifr_ip.ifr_name, "eth0", sizeof(ifr_ip.ifr_name) - 1);

if( ioctl( sock_get_ip, SIOCGIFADDR, &ifr_ip) < 0 )
{
return "";
}
sin = (struct sockaddr_in *)&ifr_ip.ifr_addr;
strcpy(ipaddr,inet_ntoa(sin->sin_addr));

printf("local ip:%s \n",ipaddr);
close( sock_get_ip );

return QString( ipaddr );
}

//修改本機IP地址的函數

int SetLocalIp( const char *ipaddr )
{

int sock_set_ip;

struct sockaddr_in sin_set_ip;
struct ifreq ifr_set_ip;

bzero( &ifr_set_ip,sizeof(ifr_set_ip));

if( ipaddr == NULL )
return -1;

if(sock_set_ip = socket( AF_INET, SOCK_STREAM, 0 ) == -1);
{
perror("socket create failse...SetLocalIp!\n");
return -1;
}

memset( &sin_set_ip, 0, sizeof(sin_set_ip));
strncpy(ifr_set_ip.ifr_name, "eth0", sizeof(ifr_set_ip.ifr_name)-1);

sin_set_ip.sin_family = AF_INET;
sin_set_ip.sin_addr.s_addr = inet_addr(ipaddr);
memcpy( &ifr_set_ip.ifr_addr, &sin_set_ip, sizeof(sin_set_ip));

if( ioctl( sock_set_ip, SIOCSIFADDR, &ifr_set_ip) < 0 )
{
perror( "Not setup interface\n");
return -1;
}

//設置激活標志
ifr_set_ip.ifr_flags |= IFF_UP |IFF_RUNNING;

//get the status of the device
if( ioctl( sock_set_ip, SIOCSIFFLAGS, &ifr_set_ip ) < 0 )
{
perror("SIOCSIFFLAGS");
return -1;
}

close( sock_set_ip );
return 0;
}

9. 在Linux下如果要使用介面標志要加什麼頭文件嗎因為我在使用IFF_UP時會出錯,說是未定義

頭文件一般放在/usr/include目錄下,
用grep 'IFF_UP' /usr/include/*.* |less
這個命令查找一下在哪個頭文件裡面有定義。

10. linux下設置網卡為混合模式中用到的ethreq在那個頭文件裡面

eth0
標識著網卡設備的ID值,告訴你有幾個設備、虛擬的也算

熱點內容
如何給word文件加密碼 發布:2024-11-02 06:21:10 瀏覽:717
台達模擬量編程 發布:2024-11-02 06:19:41 瀏覽:410
23456解壓 發布:2024-11-02 06:19:40 瀏覽:183
我的世界伺服器個人創造在哪裡 發布:2024-11-02 06:10:36 瀏覽:638
增霸卡的密碼是多少 發布:2024-11-02 06:06:18 瀏覽:813
傳奇天下第一完整腳本 發布:2024-11-02 06:04:03 瀏覽:586
javago性能 發布:2024-11-02 05:51:47 瀏覽:862
國內ip代理伺服器設置方式 發布:2024-11-02 05:42:42 瀏覽:842
線刷包文件夾 發布:2024-11-02 05:35:35 瀏覽:626
銀行家演算法的安全性演算法 發布:2024-11-02 05:20:15 瀏覽:598